home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "Module1"
- '*** MDI ╝╟╩┬▒╛╙ª╙├│╠╨≥╩╛└²╚½╛╓─ú┐Θ ***
- '****************************************************
- 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 = "MDINote" ' ThisApp │ú╩²
- Public Const ThisKey = "Recent Files" ' ThisKey │ú╩²
-
-
- Function AnyPadsLeft() As Integer
- Dim i As Integer ' ╝╞╩²╞≈▒Σ┴┐
-
- ' ▒Θ└·╬─╡╡╩²╫Θ
- ' ╚τ╣√╓┴╔┘╙╨╥╗╕÷┤≥┐¬╡─╬─╡╡ú¼╖╡╗╪ True
- For i = 1 To UBound(Document)
- If Not FState(i).Deleted Then
- AnyPadsLeft = True
- Exit Function
- End If
- Next
- 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 = "╬▐▒Ω╠Γú║" & 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
-
- ' ╚τ╣√╫╙┤░╠σ╢╘╧≤╩²╫Θ╓╨╡─╥╗╕÷╘¬╦╪╢╝├╗╙╨╔╛│²ú¼
- ' ╬─╡╡╩²╫Θ╙δ╫┤╠¼╩²╫Θ╛∙╝╙ 1 ▓ó╖╡╗╪╨┬╘¬╦╪╡─╦≈╥²
- 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 = "╒╥▓╗╡╜ " & Chr(34) & gFindString & Chr(34)
- intResponse = MsgBox(strMsg, 0, App.Title)
- End If
-
- ' ╓╪╨┬╔Φ╓├╚½╛╓▒Σ┴┐
- gCurPos = frmMDI.ActiveForm.ActiveControl.SelStart
- gFirstTime = False
- End Sub
-
- Sub GetRecentFiles()
- ' ▒╛╣²│╠╤▌╩╛ GetAllSettings ║»╩²╡─╙├╖¿ú¼╦ⁿ┤╙ Windows ╫ó▓ß▒φ╓╨╖╡╗╪╓╡╡─╩²╫Θíú
- ' ╘┌╒Γ╓╓╟Θ┐÷╧┬ú¼╫ó▓ß▒φ░ⁿ║¼╫ε╜ⁿ┤≥┐¬╡─╬─╝■┴╨▒φíú
- ' ╩╣╙├ SaveSetting ╙∩╛Σ╝╟╧┬╫ε╜ⁿ╩╣╙├╡─╬─╝■├√íú
- ' ╕├╙∩╛Σ╘┌ WriteRecentFiles ╣²│╠╓╨íú
- Dim i, j As Integer
- Dim varFiles As Variant ' ┤µ┤ó╖╡╗╪╡─╩²╫Θ
-
- ' ╙├ GetAllSettings ╙∩╛Σ┤╙╫ó▓ß▒φ╓╨╖╡╗╪╫ε╜ⁿ╩╣╙├╡─╬─╝■íú
- ' ─ú┐Θ╓╨╢¿╥σ│ú╩² ThisApp ║═ ThisKey
- 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)
- ' ╟╨╗╗ Checked ╩⌠╨╘
- CurrentForm.mnuOptionsToolbar.Checked = Not CurrentForm.mnuOptionsToolbar.Checked
- ' ╚τ╣√▓╗╩╟ MDI ┤░╠σú¼╔Φ╓├ MDI ┤░╠σ╡─ 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
- Else
- frmMDI.picToolbar.Visible = False
- End If
- End Sub
-
- Sub WriteRecentFiles(OpenFileName)
- ' ▒╛╣²│╠╩╣╙├ SaveSettings ╙∩╛Σ╜½╫ε╜ⁿ╩╣╙├╡─╬─╝■├√╨┤╚δ╧╡═│╫ó▓ß▒φíú
- ' SaveSettings ╙∩╛Σ╥¬╟≤╚²╕÷▓╬╩²╞Σ╓╨┴╜╕÷┤µ┤ó╬¬│ú╩²▓ó╘┌▒╛─ú┐Θ─┌╢¿╥σíú
- ' GetRecentFiles ╣²│╠╓╨╩╣╙├ GetAllSettings ║»╩²└┤╝∞╦≈╘┌╒Γ╕÷╣²│╠╓╨┤µ┤ó╡─╬─╝■├√íú
-
- Dim i, j As Integer
- Dim strFile, key As String
-
- ' ╜½╬─╝■ RecentFile1 ╕┤╓╞╕° RecentFile2ú¼╡╚╡╚
- 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
-
-