home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "Module1"
- Option Explicit
- Type FormState
- Deleted As Integer
- Dirty As Integer
- Color As Long
- End Type
- Public FState() As FormState
- Public Document() As New frmNotePad
- Public gFindString As String
- Public gFindCase As Integer
- Public gFindDirection As Integer
- Public gCurPos As Integer
- Public gFirstTime As Integer
- Public gToolsHidden As Boolean
- Public Const ThisApp = "AGC"
- Public Const ThisKey = "Recent Files"
- Function AnyPadsLeft() As Integer
- End Function
- Sub EditCopyProc()
- Clipboard.SetText frmMDI.ActiveForm.ActiveControl.SelText
- End Sub
- Sub EditCutProc()
- Clipboard.SetText frmMDI.ActiveForm.ActiveControl.SelText
- frmMDI.ActiveForm.ActiveControl.SelText = ""
- End Sub
- Sub EditPasteProc()
- frmMDI.ActiveForm.ActiveControl.SelText = Clipboard.GetText()
- End Sub
- Sub FileNew()
- Dim fIndex As Integer
- fIndex = FindFreeIndex()
- Document(fIndex).Tag = fIndex
- Document(fIndex).Caption = "Untitled:" & fIndex
- Document(fIndex).Show
- frmMDI.imgCutButton.Visible = True
- frmMDI.imgCopyButton.Visible = True
- frmMDI.imgPasteButton.Visible = True
- End Sub
- Function FindFreeIndex() As Integer
- Dim i As Integer
- Dim ArrayCount As Integer
- ArrayCount = UBound(Document)
- For i = 1 To ArrayCount
- If FState(i).Deleted Then
- FindFreeIndex = i
- FState(i).Deleted = False
- Exit Function
- End If
- Next
- ReDim Preserve Document(ArrayCount + 1)
- ReDim Preserve FState(ArrayCount + 1)
- FindFreeIndex = UBound(Document)
- End Function
- Sub FindIt()
- Dim intStart As Integer
- Dim intPos As Integer
- Dim strFindString As String
- Dim strSourceString As String
- Dim strMsg As String
- Dim intResponse As Integer
- Dim intOffset As Integer
- If (gCurPos = frmMDI.ActiveForm.ActiveControl.SelStart) Then
- intOffset = 1
- Else
- intOffset = 0
- End If
- If gFirstTime Then intOffset = 0
- intStart = frmMDI.ActiveForm.ActiveControl.SelStart + intOffset
- If gFindCase Then
- strFindString = gFindString
- strSourceString = frmMDI.ActiveForm.ActiveControl.Text
- Else
- strFindString = UCase(gFindString)
- strSourceString = UCase(frmMDI.ActiveForm.ActiveControl.Text)
- End If
- If gFindDirection = 1 Then
- intPos = InStr(intStart + 1, strSourceString, strFindString)
- Else
- For intPos = intStart - 1 To 0 Step -1
- If intPos = 0 Then Exit For
- If Mid(strSourceString, intPos, Len(strFindString)) = strFindString Then Exit For
- Next
- End If
- If intPos Then
- frmMDI.ActiveForm.ActiveControl.SelStart = intPos - 1
- frmMDI.ActiveForm.ActiveControl.SelLength = Len(strFindString)
- Else
- strMsg = "Cannot find " & Chr(34) & gFindString & Chr(34)
- intResponse = MsgBox(strMsg, 0, App.Title)
- End If
- gCurPos = frmMDI.ActiveForm.ActiveControl.SelStart
- gFirstTime = False
- End Sub
- Sub GetRecentFiles()
- Dim i, j As Integer
- Dim varFiles As Variant
- If GetSetting(ThisApp, ThisKey, "RecentFile1") = Empty Then Exit Sub
- varFiles = GetAllSettings(ThisApp, ThisKey)
- For i = 0 To UBound(varFiles, 1)
- frmMDI.mnuRecentFile(0).Visible = True
- frmMDI.mnuRecentFile(i).Caption = varFiles(i, 1)
- frmMDI.mnuRecentFile(i).Visible = True
- For j = 1 To UBound(Document)
- If Not FState(j).Deleted Then
- Document(j).mnuRecentFile(0).Visible = True
- Document(j).mnuRecentFile(i + 1).Caption = varFiles(i, 1)
- Document(j).mnuRecentFile(i + 1).Visible = True
- End If
- Next j
- Next i
- End Sub
- Sub OptionsToolbarProc(CurrentForm As Form)
- CurrentForm.mnuOptionsToolbar.Checked = Not CurrentForm.mnuOptionsToolbar.Checked
- If Not TypeOf CurrentForm Is MDIForm Then
- frmMDI.mnuOptionsToolbar.Checked = CurrentForm.mnuOptionsToolbar.Checked
- End If
- If CurrentForm.mnuOptionsToolbar.Checked Then
- frmMDI.picToolbar.Visible = True
- frmMDI.CoolBar1.Visible = True
- Else
- frmMDI.picToolbar.Visible = False
- frmMDI.CoolBar1.Visible = False
- End If
- End Sub
- Sub WriteRecentFiles(OpenFileName)
- Dim i, j As Integer
- Dim strFile, key As String
- For i = 3 To 1 Step -1
- key = "RecentFile" & i
- strFile = GetSetting(ThisApp, ThisKey, key)
- If strFile <> "" Then
- key = "RecentFile" & (i + 1)
- SaveSetting ThisApp, ThisKey, key, strFile
- End If
- Next i
- SaveSetting ThisApp, ThisKey, "RecentFile1", OpenFileName
- End Sub
-
-