Global gfInsertMode As Integer ' insert mode : True=insert, False=Overwrite
Global gfBlockType As Integer ' block type : 0=Stream, 1=Line, 2=Column
Global gfRecursiveSearch As Integer
' API functions used to read and write to EMEDIT.INI.
' Used for handling the recent files list.
Declare Function GetPrivateProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
Declare Function WritePrivateProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lplFileName As String) As Integer
' Key Codes
Global Const KEY_LBUTTON = &H1
Global Const KEY_RBUTTON = &H2
Global Const KEY_CANCEL = &H3
Global Const KEY_MBUTTON = &H4 ' NOT contiguous with L & RBUTTON
Global Const KEY_BACK = &H8
Global Const KEY_TAB = &H9
Global Const KEY_CLEAR = &HC
Global Const KEY_RETURN = &HD
Global Const KEY_SHIFT = &H10
Global Const KEY_CONTROL = &H11
Global Const KEY_MENU = &H12
Global Const KEY_PAUSE = &H13
Global Const KEY_CAPITAL = &H14
Global Const KEY_ESCAPE = &H1B
Global Const KEY_SPACE = &H20
Global Const KEY_PRIOR = &H21
Global Const KEY_NEXT = &H22
Global Const KEY_END = &H23
Global Const KEY_HOME = &H24
Global Const KEY_LEFT = &H25
Global Const KEY_UP = &H26
Global Const KEY_RIGHT = &H27
Global Const KEY_DOWN = &H28
Global Const KEY_SELECT = &H29
Global Const KEY_PRINT = &H2A
Global Const KEY_EXECUTE = &H2B
Global Const KEY_SNAPSHOT = &H2C
Global Const KEY_INSERT = &H2D
Global Const KEY_DELETE = &H2E
Global Const KEY_HELP = &H2F
' KEY_A thru KEY_Z are the same as their ASCII equivalents: 'A' thru 'Z'
' KEY_0 thru KEY_9 are the same as their ASCII equivalents: '0' thru '9'
Global Const KEY_NUMPAD0 = &H60
Global Const KEY_NUMPAD1 = &H61
Global Const KEY_NUMPAD2 = &H62
Global Const KEY_NUMPAD3 = &H63
Global Const KEY_NUMPAD4 = &H64
Global Const KEY_NUMPAD5 = &H65
Global Const KEY_NUMPAD6 = &H66
Global Const KEY_NUMPAD7 = &H67
Global Const KEY_NUMPAD8 = &H68
Global Const KEY_NUMPAD9 = &H69
Global Const KEY_MULTIPLY = &H6A
Global Const KEY_ADD = &H6B
Global Const KEY_SEPARATOR = &H6C
Global Const KEY_SUBTRACT = &H6D
Global Const KEY_DECIMAL = &H6E
Global Const KEY_DIVIDE = &H6F
Global Const KEY_F1 = &H70
Global Const KEY_F2 = &H71
Global Const KEY_F3 = &H72
Global Const KEY_F4 = &H73
Global Const KEY_F5 = &H74
Global Const KEY_F6 = &H75
Global Const KEY_F7 = &H76
Global Const KEY_F8 = &H77
Global Const KEY_F9 = &H78
Global Const KEY_F10 = &H79
Global Const KEY_F11 = &H7A
Global Const KEY_F12 = &H7B
Global Const KEY_F13 = &H7C
Global Const KEY_F14 = &H7D
Global Const KEY_F15 = &H7E
Global Const KEY_F16 = &H7F
Global Const KEY_NUMLOCK = &H90
'File Open/Save Dialog Flags
Global Const OFN_READONLY = &H1&
Global Const OFN_OVERWRITEPROMPT = &H2&
Global Const OFN_HIDEREADONLY = &H4&
Global Const OFN_NOCHANGEDIR = &H8&
Global Const OFN_SHOWHELP = &H10&
Global Const OFN_NOVALIDATE = &H100&
Global Const OFN_ALLOWMULTISELECT = &H200&
Global Const OFN_EXTENTIONDIFFERENT = &H400&
Global Const OFN_PATHMUSTEXIST = &H800&
Global Const OFN_FILEMUSTEXIST = &H1000&
Global Const OFN_CREATEPROMPT = &H2000&
Global Const OFN_SHAREAWARE = &H4000&
Global Const OFN_NOREADONLYRETURN = &H8000&
Function AnyPadsLeft () As Integer
Dim I As Integer
' Cycle throught the document array.
' Return True if there is at least one
' open document remaining.
For I = 1 To UBound(document)
If Not FState(I).Deleted Then
AnyPadsLeft = True
Exit Function
End If
Next
End Function
Sub CenterForm (frmParent As Form, frmChild As Form)
' This procedure centers a child form over a parent form.
' Calling this routine loads the dialog. Use the Show method
' to display the dialog after calling this routine ( ie MyFrm.Show 1)
Dim L, t
' get left offset
L = frmParent.Left + ((frmParent.Width - frmChild.Width) / 2)
If (L + frmChild.Width > screen.Width) Then
L = screen.Width = frmChild.Width
End If
' get top offset
t = frmParent.Top + ((frmParent.Height - frmChild.Height) / 2)
' Cycle throught the document array. If one of the
' documents has been deleted, then return that
' index.
For I = 1 To ArrayCount
If FState(I).Deleted Then
FindFreeIndex = I
FState(I).Deleted = False
document(I).Tag = I
Exit Function
End If
Next
' If none of the elements in the document array have
' been deleted, then increment the document and the
' state arrays by one and return the index to the
' new element.
ReDim Preserve document(ArrayCount + 1)
ReDim Preserve FState(ArrayCount + 1)
Dim FreeIndex As Integer
FreeIndex = UBound(document)
document(FreeIndex).Tag = FreeIndex
FindFreeIndex = FreeIndex
Else
'Initialize document form arrays, and show first document.
ReDim document(1)
ReDim FState(1)
document(1).Tag = 1
FindFreeIndex = 1
NotFirstTime = True
End If
End Function
Function FindIt (TargetText As String, MatchCase As Integer, WholeWordOnly As Integer, UpDirection As Integer, BeginScope As Integer, NewText As String, fReplace As Integer, IsRepeat As Integer) As Integer
Dim FindStartY As Long, FindStartX As Long ' point where search starts
Dim FindEndY As Long, FindEndX As Long ' point where search ends
Dim FoundY As Long, FoundX As Long ' found text
Dim FindText As String
Dim fInStrCase As Integer
FindIt = False
'make sure the current form's display is up to date...
frmMDI.ActiveForm.Refresh
FindText = TargetText
If MatchCase Then fInStrCase = 0 Else fInStrCase = 1
'If Not MatchCase Then FindText = UCase(FindText)
' Save the arguments to this subroutine for use when
' the find/relace is repeated
gTargetText = TargetText
gMatchCase = MatchCase
gWholeWordOnly = WholeWordOnly
gUpDirection = UpDirection
gBeginScope = BeginScope
gNewText = NewText
gfReplace = fReplace
' If we wern't given a string to look for then don't do anything...
If FindText = "" Then Exit Function
' Calculate starting point...
If BeginScope = False Then ' start at cursor
FindStartY = frmMDI.ActiveForm.Text1.CaretY
FindStartX = frmMDI.ActiveForm.Text1.CaretX
Else
If UpDirection Then ' start at end of file
FindStartY = frmMDI.ActiveForm.Text1.Count
frmMDI.ActiveForm.Text1.TextIndex = FindStartY
FindStartX = Len(frmMDI.ActiveForm.Text1.Text)
Else ' start at beginning of file
FindStartY = 1
FindStartX = 1
End If
End If
' Calculate ending point...
If UpDirection Then
FindEndY = 1
FindEndX = 1
Else ' end at bottom of file
FindEndY = frmMDI.ActiveForm.Text1.Count
frmMDI.ActiveForm.Text1.TextIndex = FindEndY
FindEndX = Len(frmMDI.ActiveForm.Text1.Text)
End If
' If the search is being repeated then don't start where we
' the search left off otherwise you'll just find the same
' text you found last time...
If IsRepeat And UpDirection = True Then
If gCurPosX = FindStartX And gCurPosY = FindStartY Then
FindStartX = FindStartX - Len(FindText) - 1
If FindStartX = 0 Then
If 1 < FindStartY Then
FindStartY = FindStartY - 1
frmMDI.ActiveForm.Text1.TextIndex = FindStartY
FindStartX = Len(frmMDI.ActiveForm.Text1.Text)
Else
FindStartX = 1
End If
End If
End If
End If
' In some special situations (like searching down selected text beginning at the
' cursor position when the cursor is at the end of the selection) don't do nothin...
If UpDirection Then
If FindStartY < FindEndY Then Exit Function
Else
If FindEndY < FindStartY Then Exit Function
End If
' change mousepointer to an hourglass
screen.MousePointer = 11
'do search in down direction...
If UpDirection = False Then
Dim I As Integer
For I = FindStartY To FindEndY
Dim SourceText As String
frmMDI.ActiveForm.Text1.TextIndex = I
SourceText = frmMDI.ActiveForm.Text1.Text
If Len(SourceText) Then
'If MatchCase = False Then SourceText = UCase(SourceText)