-
Notifications
You must be signed in to change notification settings - Fork 1
/
frmLogin.frm
525 lines (485 loc) · 16.3 KB
/
frmLogin.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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
VERSION 5.00
Object = "{48E59290-9880-11CF-9754-00AA00C00908}#1.0#0"; "MSINET.OCX"
Begin VB.Form frmLogin
AutoRedraw = -1 'True
BorderStyle = 1 'Fixed Single
Caption = "用户登录"
ClientHeight = 3030
ClientLeft = 2835
ClientTop = 3480
ClientWidth = 7170
Icon = "frmLogin.frx":0000
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
NegotiateMenus = 0 'False
ScaleHeight = 3030
ScaleWidth = 7170
ShowInTaskbar = 0 'False
StartUpPosition = 2 '屏幕中心
Begin Othello.FlatButton fltbtnOption
Height = 360
Left = 5190
TabIndex = 9
Top = 2475
Width = 1410
_ExtentX = 2487
_ExtentY = 635
Caption = "网络设置(&S)"
MousePointer = 99
Style = 2
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
EnableHot = -1 'True
ForeColor = 0
End
Begin VB.Timer AutoLoginTimer
Enabled = 0 'False
Interval = 1
Left = 4635
Top = 1905
End
Begin Othello.FlatButton fltbtnRegister
Height = 360
Left = 3645
TabIndex = 8
Top = 2475
Width = 1410
_ExtentX = 2487
_ExtentY = 635
Caption = "注册向导(&W)"
MousePointer = 99
Style = 2
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
EnableHot = -1 'True
ForeColor = 0
End
Begin Othello.FlatButton fltbtnCancel
Cancel = -1 'True
Height = 360
Left = 2115
TabIndex = 7
Top = 2475
Width = 1410
_ExtentX = 2487
_ExtentY = 635
Caption = "取消(&C)"
MousePointer = 99
Style = 2
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
EnableHot = -1 'True
ForeColor = 0
End
Begin Othello.FlatButton fltbtnOK
Default = -1 'True
Height = 360
Left = 570
TabIndex = 6
Top = 2475
Width = 1410
_ExtentX = 2487
_ExtentY = 635
Caption = "确定(&O)"
MousePointer = 99
Style = 2
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
EnableHot = -1 'True
ForeColor = 0
End
Begin VB.ComboBox cboUserName
Height = 300
IntegralHeight = 0 'False
ItemData = "frmLogin.frx":000C
Left = 1710
List = "frmLogin.frx":000E
TabIndex = 1
Top = 240
Width = 2580
End
Begin VB.CheckBox chkSavePassword
Caption = "记住登录成功后的密码(&R)"
Height = 195
Left = 1710
TabIndex = 4
Top = 1695
Width = 2370
End
Begin VB.CheckBox chkAutoLogin
Caption = "程序启动后自动登录(&A)"
Height = 195
Left = 1710
TabIndex = 5
Top = 1995
Width = 2190
End
Begin InetCtlsObjects.Inet ietLogin
Left = 5145
Top = 1755
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
URL = "http://"
RequestTimeout = 30
End
Begin VB.TextBox txtPassword
Height = 300
IMEMode = 3 'DISABLE
Left = 1710
PasswordChar = "*"
TabIndex = 3
Top = 1170
Width = 2580
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "如果您是幸福家园BBS 的会员,可以使用BBS的用户名和密码登录。"
Height = 630
Left = 4620
TabIndex = 11
Top = 1170
Width = 2190
WordWrap = -1 'True
End
Begin VB.Label Label1
Caption = "在这里输入用户名,例如: Hex,幸福家园 等。"
Height = 405
Left = 1755
TabIndex = 10
Top = 615
Width = 2190
WordWrap = -1 'True
End
Begin VB.Image imgLogin
Height = 675
Left = 4620
MousePointer = 99 'Custom
Picture = "frmLogin.frx":0010
ToolTipText = "访问幸福家园BBS"
Top = 240
Width = 2175
End
Begin VB.Label lblUserName
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "用户名(&U):"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 240
Left = 315
TabIndex = 0
Top = 255
Width = 1305
End
Begin VB.Label lblPassword
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "密 码(&P):"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 240
Left = 330
TabIndex = 2
Top = 1185
Width = 1320
End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim Auto As Boolean
Dim mblnServerOK As Boolean
Dim mblnAutoLogin As Boolean
Dim mblnSavePassword As Boolean
Private Sub fltbtnOption_Click(Button As Integer)
Call frmOption.ShowEx(2)
End Sub
Private Sub Form_Load()
On Error Resume Next
Set Me.Icon = MainForm.Icon
Set imgLogin.MouseIcon = HandCursor
Auto = False
' 装载用户历史记录及其相关数据(是否自动登陆等)
Call LoadUserList
chkSavePassword.Value = Abs(mblnSavePassword)
chkAutoLogin.Value = Abs(mblnAutoLogin)
End Sub
Private Sub AutoLoginTimer_Timer()
AutoLoginTimer.Enabled = False
Call fltbtnOK_Click(vbLeftButton)
End Sub
Private Sub cboUserName_Click()
Call SetControlFocus(txtPassword)
End Sub
Private Sub fltbtnCancel_Click(Button As Integer)
'设置全局变量为 false
'不提示失败的登录
Call ietLogin.Cancel
Call Unload(Me)
End Sub
Public Sub fltbtnOK_Click(Button As Integer)
Dim strUrl As String
Dim strStatus As String
Dim strData As String
Dim strID As String
On Error Resume Next
If Len(cboUserName.Text) < 2 Or Len(cboUserName.Text) > 15 Or Not CheckString(cboUserName.Text) Then
If mblnAutoLogin And Auto Then
Call MessageBox(Me.hWnd, LoadString(102), vbExclamation, LoadString(181))
Call Unload(Me)
Else
Call MessageBox(Me.hWnd, LoadString(102), vbExclamation, LoadString(181))
Call SetControlFocus(cboUserName)
Call SendKeys("{Home}+{End}")
End If
Exit Sub
End If
If Len(txtPassword.Text) < 5 Or Len(txtPassword.Text) > 15 Or Not CheckString(txtPassword.Text) Then
If mblnAutoLogin And Auto Then
Call MessageBox(Me.hWnd, LoadString(103), vbExclamation, LoadString(181))
'Me.Hide
Call Unload(Me)
Else
Call MessageBox(Me.hWnd, LoadString(103), vbExclamation, LoadString(181))
Call SetControlFocus(txtPassword)
Call SendKeys("{Home}+{End}")
End If
Exit Sub
End If
Screen.MousePointer = vbHourglass
Me.Caption = LoadString(250)
cboUserName.Enabled = False
txtPassword.Enabled = False
' 首先获得登陆许可(获得安全检查数据)
strUrl = gstrSave_ServerUrl & SERVER_ACTION_GET
If ServerCommand(ietLogin, mblnServerOK, strUrl, strStatus, strData, True) Then
If strStatus = STATUS_OK Then
strID = GetRecord(strData, 1)
gstrSecurity1 = GetRecord(strData, 2)
gstrSecurity2 = GetRecord(strData, 3)
End If
End If
strUrl = gstrSave_ServerUrl & SERVER_ACTION_LOGIN & "?username=" & ToUrlString(cboUserName.Text) & _
"&password=" & MD5(txtPassword.Text) & _
"&lanip=" & gstrLocalIP & _
"&port=" & CStr(glngSave_GamePort) & _
"&id=" & strID & _
"&" & MakeServerPassword() & _
"&" & MakeVersion()
If ServerCommand(ietLogin, mblnServerOK, strUrl, strStatus, strData, Auto) Then
Screen.MousePointer = vbDefault
Me.Caption = LoadString(251)
Select Case strStatus
Case STATUS_OK
Me.Enabled = False
Call LoadUserInfo(gMyUserInfo, strData)
gMyUserInfo.UserName = cboUserName.Text
gMyUserInfo.Password = txtPassword.Text
gstrIP = GetRecord(strData, 15)
' 取得安全检查数据
gstrSecurity1 = GetRecord(strData, 16)
gstrSecurity2 = GetRecord(strData, 17)
gblnLogin = True
Call SaveUserList
If GetRecordCount(strData) > 17 Then
Call MessageBox(Me.hWnd, GetRecord(strData, 18), vbInformation, LoadString(187))
End If
' 播放音效
Call PlaySoundEffects(SOUND_LOGIN, gstrSave_SoundValue(SOUND_LOGIN))
Call MainForm.LoginSet
Call Unload(Me)
'If MessageBox(MainForm.hwnd, "您现在想立即创建棋局吗?", vbQuestion Or vbYesNo, "提问") = vbYes Then
' Call frmCreateTable.Show(vbModal)
'End If
Case STATUS_ERROR
cboUserName.Enabled = True
txtPassword.Enabled = True
If mblnAutoLogin And Auto Then
Call MessageBox(Me.hWnd, LoadString(167) & strData, vbExclamation, LoadString(181))
Call Unload(Me)
Else
Call MessageBox(Me.hWnd, LoadString(167) & strData, vbExclamation, LoadString(181))
Call SetControlFocus(txtPassword)
Call SendKeys("{Home}+{End}")
End If
Case Else
cboUserName.Enabled = True
txtPassword.Enabled = True
If mblnAutoLogin And Auto Then
Call MessageBox(Me.hWnd, LoadString(168), vbExclamation, LoadString(181))
Call Unload(Me)
Else
Call MessageBox(Me.hWnd, LoadString(168), vbExclamation, LoadString(181))
Call SetControlFocus(txtPassword)
Call SendKeys("{Home}+{End}")
End If
End Select
Else
Screen.MousePointer = vbDefault
Me.Caption = LoadString(251)
cboUserName.Enabled = True
txtPassword.Enabled = True
Call SetControlFocus(cboUserName)
If mblnAutoLogin And Auto Then
'Call MsgBox("登陆失败!" + vbCr + vbCr + LoadString(101), vbCritical, "自动登陆")
Call Unload(Me)
'Else
'Call MessageBox(Me.hWnd, "登陆失败!" + vbCr + vbCr + LoadString(101))
End If
End If
End Sub
Private Sub fltbtnRegister_Click(Button As Integer)
On Error Resume Next
Call Unload(Me)
Call frmRegister.Show(vbModal, MainForm)
End Sub
Private Sub Form_Activate()
If cboUserName.Text = "" Then
Call SetControlFocus(cboUserName)
Else
Call SetControlFocus(txtPassword)
End If
'MainForm.fltbtnUser.Reset
End Sub
' 装载用户历史记录及其相关数据
Private Sub LoadUserList()
Dim i As Integer
On Error Resume Next
' 装载用户历史记录
For i = 1 To MAX_USER_LIST
If gstrSave_UserList(i) <> "" Then
Call cboUserName.AddItem(gstrSave_UserList(i))
End If
Next i
cboUserName.Text = cboUserName.List(0)
' 装载相关数据
mblnAutoLogin = gblnSave_AutoLogin
mblnSavePassword = gblnSave_SavePassword
If gstrSave_UserName <> "" Then
cboUserName.Text = gstrSave_UserName
End If
txtPassword.Text = Decipher(gstrLocalPassword, gstrSave_Password)
End Sub
' 保存用户历史记录及其相关数据
Private Sub SaveUserList()
Dim i As Integer
Dim j As Integer
Dim Temp As String
Dim User(MAX_USER_LIST) As String
On Error Resume Next
For i = 1 To MAX_USER_LIST
Temp = gstrSave_UserList(i)
If Temp <> "" And Temp <> cboUserName.Text Then
User(i) = Temp
End If
Next i
For i = 1 To MAX_USER_LIST - 1
For j = i + 1 To MAX_USER_LIST
If User(i) = "" And User(j) <> "" Then
Call Swap(User(i), User(j))
Exit For
End If
Next j
Next i
For i = MAX_USER_LIST To 2 Step -1
User(i) = User(i - 1)
Next i
User(1) = cboUserName.Text
For i = 1 To MAX_USER_LIST
gstrSave_UserList(i) = User(i)
Next i
Call SaveData
End Sub
Private Sub SaveData()
If chkSavePassword.Value <> 0 And StrLen(txtPassword.Text) >= 5 Then
gblnSave_AutoLogin = chkAutoLogin.Value
gblnSave_SavePassword = chkSavePassword.Value
gstrSave_UserName = cboUserName.Text
gstrSave_Password = Cipher(gstrLocalPassword, txtPassword.Text)
Else
gblnSave_AutoLogin = False
gblnSave_SavePassword = False
gstrSave_UserName = ""
gstrSave_Password = ""
End If
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Call SaveData
End Sub
Private Sub ietLogin_StateChanged(ByVal State As Integer)
'Dim strMess As String '消息变量。
Select Case State
Case icResponseReceived
mblnServerOK = True
Case icError '11
mblnServerOK = False
'得到错误文本。
'strMess = "ErrorCode: " & ietRegister.ResponseCode & " : " & ietRegister.ResponseInfo
End Select
End Sub
Public Sub ShowEx()
On Error Resume Next
Call Load(frmLogin)
If mblnAutoLogin Then
'Me.Hide
Auto = True
AutoLoginTimer.Enabled = True
Else
Auto = False
Call Me.Show(vbModal)
End If
End Sub
Private Sub imgLogin_Click()
On Error Resume Next
Call ShellExecute(Me.hWnd, "open", HAPPY_FAMILY_BBS, 0, 0, 1)
End Sub
Private Sub txtPassword_GotFocus()
Call AutoSelectText(txtPassword)
End Sub