VERSION 2.00
Begin Form Form1 
   Caption         =   "VB FileCdr Window"
   ClientHeight    =   1935
   ClientLeft      =   1095
   ClientTop       =   1830
   ClientWidth     =   7125
   Height          =   2460
   Icon            =   VBLOG.FRX:0000
   Left            =   1035
   LinkTopic       =   "Form1"
   ScaleHeight     =   1935
   ScaleWidth      =   7125
   Top             =   1365
   Width           =   7245
   Begin Grid Grid1 
      Cols            =   5
      FixedCols       =   0
      FixedRows       =   0
      Height          =   615
      HighLight       =   0   'False
      Left            =   1920
      Rows            =   1
      TabIndex        =   1
      Top             =   120
      Width           =   2895
   End
   Begin TextBox Invisible_Text 
      Height          =   615
      Left            =   120
      TabIndex        =   0
      Text            =   "Invisible_Text"
      Top             =   120
      Visible         =   0   'False
      Width           =   1455
   End
End
' declarations for access to FileCdrL DLL
Declare Function FileCdrInstallVB% Lib "FILECDRL.DLL" (ByVal H%, ByVal TextH%)
Declare Function FileCdrUnInstall% Lib "FILECDRL.DLL" (ByVal H%)
' declarations for Windows API functions
Declare Function GetWinFlags& Lib "Kernel" ()
Declare Function GetPrivateProfileString% Lib "Kernel" (ByVal lpApplicationName$, ByVal lpKeyName$, ByVal lpDefault$, ByVal lpReturnedString$, ByVal nSize%, ByVal lpFileName$)
Declare Function WritePrivateProfileString% Lib "Kernel" (ByVal lpApplicationName$, ByVal lpKeyName$, ByVal lpstring$, ByVal lplFileName$)
Declare Function ExitWindows% Lib "User" (ByVal dwReturnCode&, ByVal Reserved%)
' constants used by Windows API functions
Const EW_RESTARTWINDOWS = &H42
Const WF_ENHANCED = &H20

Dim Loaded%

Sub Form_Load ()
  If GetWinFlags&() And WF_ENHANCED = 0 Then
    MsgBox "Because Windows is not in 386 Enhanced mode, VBLog will not be able to log file events occurring in DOS boxes", MB_OK + MB_ICONINFORMATION, "VBLog Message"
  Else
    Valu$ = String$(20, 0)
    Success% = GetPrivateProfileString("386Enh", "FileSysChange", "", Valu$, Len(Valu$), "SYSTEM.INI")
    Valu$ = Left$(Valu$, Success%)
    If Valu$ <> "ON" Then
      If MsgBox("Windows is not set up to receive notification of file activity in DOS boxes.  Enable this feature and restart Windows?", MB_YESNO + MB_ICONQUESTION, "VBLog Message") = IDYES Then
        Success% = WritePrivateProfileString("386Enh", "FileSysChange", "ON", "SYSTEM.INI")
        If Success% Then Success% = ExitWindows(EW_RESTARTWINDOWS, 0)
      End If
    End If
  End If
  'set up the first four grid column widths
  Grid1.ColWidth(0) = 1200
  Grid1.ColWidth(1) = 1000
  Grid1.ColWidth(2) = 400
  Grid1.ColWidth(3) = 1800
  ' first row initially NOT fixed, so we can use AddItem
  Grid1.AddItem "Date" + Chr$(9) + "Time" + Chr$(9) + "OS" + Chr$(9) + "Event" + Chr$(9) + "File name(s)"
  ' remove empty line
  Grid1.RemoveItem 0
  If FileCdrInstallVB(Form1.hWnd, Invisible_Text.hWnd) = 0 Then
    MsgBox "Unable to install VB Log.  FileCDR is in use by another program - probably File Manager", MB_OK + MB_ICONINFORMATION, "VB Log Message"
    Loaded% = False
    Unload Form1
  Else
    Loaded% = True
  End If
End Sub

Sub Form_Resize ()
  Grid1.Move 0, 0, ScaleWidth, ScaleHeight
  Grid1.ColWidth(4) = ScaleWidth
End Sub

Sub Form_Unload (Cancel As Integer)
  If Loaded% Then
    If FileCdrUnInstall(Form1.hWnd) = 0 Then
      MsgBox "The FileCdr function could not be uninstalled.  You may have to restart Windows to regain access to FileCdr.", MB_OK + MB_ICONINFORMATION, "VB Log Message"
    End If
  End If
End Sub

Sub Invisible_Text_Change ()
  Grid1.AddItem Date$ + Chr$(9) + Time$ + Chr$(9) + Invisible_Text.Text
  ' It is not possible for a grid to have just ONE row
  ' and have that row be a fixed row.  Thus we do not
  ' make it fixed until after another row has been added.
  If Grid1.FixedRows = 0 Then Grid1.FixedRows = 1
End Sub

