-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathfrmNotepad.frm
265 lines (229 loc) · 7.3 KB
/
frmNotepad.frm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "ComDlg32.OCX"
Object = "{20D5284F-7B23-4F0A-B8B1-6C9D18B64F1C}#1.0#0"; "exlimiter.ocx"
Begin VB.Form frmNotepad
Caption = " Notepad"
ClientHeight = 5235
ClientLeft = 60
ClientTop = 345
ClientWidth = 5355
Icon = "frmNotepad.frx":0000
LinkTopic = "Form1"
ScaleHeight = 5235
ScaleWidth = 5355
Begin VB.Timer timWindowMove
Enabled = 0 'False
Interval = 250
Left = 0
Top = 0
End
Begin exlimiter.EL EL1
Left = 4560
Top = 4440
_ExtentX = 1270
_ExtentY = 1270
End
Begin MSComDlg.CommonDialog oComDag
Left = 3960
Top = 4680
_ExtentX = 847
_ExtentY = 847
_Version = 393216
CancelError = -1 'True
End
Begin VB.TextBox txtNotepad
BeginProperty Font
Name = "Terminal"
Size = 9
Charset = 255
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 4815
Left = 60
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 0
Top = 360
Width = 5235
End
Begin VB.CommandButton cmdDO
Cancel = -1 'True
Caption = "Cl&ose"
Height = 315
Index = 3
Left = 4020
TabIndex = 4
Top = 0
Width = 1275
End
Begin VB.CommandButton cmdDO
Caption = "&Paste"
Height = 315
Index = 2
Left = 2700
TabIndex = 3
Top = 0
Width = 1275
End
Begin VB.CommandButton cmdDO
Caption = "&Copy"
Height = 315
Index = 1
Left = 1380
TabIndex = 2
Top = 0
Width = 1275
End
Begin VB.CommandButton cmdDO
Caption = "&Save As..."
Height = 315
Index = 0
Left = 60
TabIndex = 1
Top = 0
Width = 1275
End
End
Attribute VB_Name = "frmNotepad"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Option Base 0
Public nLastPosTop As Long
Public nLastPosLeft As Long
Public nLastPosMoved As Long
Public nLastPosMonitor As Long
Public nLastTimerTop As Long
Public nLastTimerLeft As Long
Private Sub cmdDO_Click(Index As Integer)
Dim sTemp As String, sFile As String, nPos As Long, nLen As Long
Dim sSectionName As String, x As Integer, sCharFile As String
Dim fso As FileSystemObject, ts As TextStream
On Error GoTo error:
txtNotepad.SetFocus
nPos = txtNotepad.SelStart
nLen = txtNotepad.SelLength
sSectionName = RemoveCharacter(frmMain.lblDatVer.Caption, " ")
sCharFile = ReadINI(sSectionName, "LastCharFile")
If Len(sSessionLastCharFile) > 0 Then sCharFile = sSessionLastCharFile
If Not FileExists(sCharFile) Then
sCharFile = ""
sSessionLastCharFile = ""
End If
Select Case Index
Case 0: 'save
Set fso = CreateObject("Scripting.FileSystemObject")
If frmMain.bCharLoaded Then
sFile = sCharFile
If Not FileExists(sFile) Then
sFile = ""
sSessionLastCharFile = ""
Else
sSectionName = "PlayerInfo"
End If
End If
oComDag.Filter = "Text Files (*.txt)|*.txt"
oComDag.DialogTitle = "Save Notepad"
sTemp = ReadINI(sSectionName, "LastNotepadFile", sFile)
If Len(sTemp) < 4 Then
oComDag.FileName = "MME-Notepad.txt"
Else
oComDag.FileName = sTemp
End If
oComDag.InitDir = ReadINI(sSectionName, "LastNotepadDir", sFile)
saveagain:
On Error GoTo out:
oComDag.ShowSave
If oComDag.FileName = "" Then GoTo out:
If fso.FileExists(oComDag.FileName) Then
x = MsgBox("File Exists, Overwrite?", vbQuestion + vbYesNoCancel + vbDefaultButton2)
If x = vbCancel Then
Exit Sub
ElseIf x = vbYes Then
Call fso.DeleteFile(oComDag.FileName, True)
Else
GoTo saveagain:
End If
End If
Set ts = fso.OpenTextFile(oComDag.FileName, ForWriting, True)
ts.Write txtNotepad.Text
Call WriteINI(sSectionName, "LastNotepadFile", oComDag.FileTitle, sFile)
Call WriteINI(sSectionName, "LastNotepadDir", oComDag.FileName, sFile)
Case 1: 'copy
If txtNotepad.SelLength = 0 Then
Clipboard.SetText txtNotepad.Text
Else
Clipboard.SetText txtNotepad.SelText
End If
txtNotepad.SetFocus
txtNotepad.SelStart = nPos
txtNotepad.SelLength = nLen
Case 2: 'paste
If Clipboard.GetText = "" Then Exit Sub
If txtNotepad.SelLength = 0 Then
txtNotepad.Text = Left(txtNotepad.Text, txtNotepad.SelStart) & Clipboard.GetText _
& Right(txtNotepad.Text, Len(txtNotepad.Text) - txtNotepad.SelStart)
Else
txtNotepad.SelText = Clipboard.GetText
End If
nLen = Len(Clipboard.GetText)
txtNotepad.SetFocus
txtNotepad.SelStart = nPos + nLen
'txtNotepad.SelLength = nLen
Case 3: 'close
Unload Me
End Select
out:
Set fso = Nothing
Set ts = Nothing
Exit Sub
error:
Call HandleError("cmdDO_Click")
Resume out:
End Sub
Private Sub Form_Load()
On Error Resume Next
With EL1
.CenterOnLoad = False
.FormInQuestion = Me
.MinWidth = 365
.MinHeight = 100
.EnableLimiter = True
End With
Me.Top = ReadINI("Settings", "NotepadTOP")
Me.Left = ReadINI("Settings", "NotepadLeft")
If Me.Top < 2 Then Me.Top = frmMain.Top
If Me.Left < 2 Then Me.Left = frmMain.Left
Me.Height = ReadINI("Settings", "NotepadHeight", , 5000)
Me.Width = ReadINI("Settings", "NotepadWidth", , 9000)
timWindowMove.Enabled = True
If ReadINI("Settings", "NotepadMaxed") = "1" Then Me.WindowState = vbMaximized
End Sub
Private Sub Form_Resize()
On Error Resume Next
If Me.WindowState = vbMinimized Then Exit Sub
txtNotepad.Width = Me.Width - 240
txtNotepad.Height = Me.Height - TITLEBAR_OFFSET - 825
CheckPosition Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Me.WindowState = vbNormal Then
Call WriteINI("Settings", "NotepadTOP", Me.Top)
Call WriteINI("Settings", "NotepadLeft", Me.Left)
Call WriteINI("Settings", "NotepadHeight", Me.Height)
Call WriteINI("Settings", "NotepadWidth", Me.Width)
End If
If Me.WindowState = vbMaximized Then
Call WriteINI("Settings", "NotepadMaxed", 1)
Else
Call WriteINI("Settings", "NotepadMaxed", 0)
End If
End Sub
Private Sub timWindowMove_Timer()
Call MonitorFormTimer(Me)
End Sub