-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfrmTable.frm
1027 lines (919 loc) · 34.9 KB
/
frmTable.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
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Object = "{48E59290-9880-11CF-9754-00AA00C00908}#1.0#0"; "MSINET.OCX"
Begin VB.Form frmTable
AutoRedraw = -1 'True
BackColor = &H00000000&
BorderStyle = 0 'None
ClientHeight = 5400
ClientLeft = 120
ClientTop = 120
ClientWidth = 4740
ControlBox = 0 'False
Icon = "frmTable.frx":0000
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
NegotiateMenus = 0 'False
ScaleHeight = 5400
ScaleWidth = 4740
ShowInTaskbar = 0 'False
StartUpPosition = 3 '窗口缺省
Begin Othello.FlatButton fltbtnReload
Height = 330
Left = 3675
TabIndex = 6
Top = 2520
Width = 900
_ExtentX = 1588
_ExtentY = 582
Caption = "刷新"
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 fltbtnJoin
Height = 330
Left = 3675
TabIndex = 5
Top = 1170
Width = 900
_ExtentX = 1588
_ExtentY = 582
Caption = "加入"
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.PictureBox picResize
AutoRedraw = -1 'True
AutoSize = -1 'True
BackColor = &H00000000&
BorderStyle = 0 'None
Height = 240
Left = 4410
MousePointer = 8 'Size NW SE
ScaleHeight = 240
ScaleWidth = 240
TabIndex = 2
Top = 5100
Width = 240
End
Begin VB.Timer tmrReload
Enabled = 0 'False
Interval = 1000
Left = 3840
Top = 4095
End
Begin InetCtlsObjects.Inet ietTable
Left = 3885
Top = 240
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
URL = "http://"
RequestTimeout = 30
End
Begin MSComctlLib.ListView lvwTable
Height = 3360
Left = 240
TabIndex = 0
Top = 1170
Width = 3300
_ExtentX = 5821
_ExtentY = 5927
View = 3
LabelEdit = 1
LabelWrap = -1 'True
HideSelection = 0 'False
FullRowSelect = -1 'True
HotTracking = -1 'True
HoverSelection = -1 'True
_Version = 393217
ForeColor = 0
BackColor = 16777215
Appearance = 1
NumItems = 8
BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628}
Key = "TableName"
Text = "棋局名"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 1
Key = "Creator"
Text = "创建人"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 2
Key = "Visitor"
Text = "访问者"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(4) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 3
Key = "CanJoin"
Text = "加入"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(5) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 4
Key = "TableType"
Text = "棋局类型"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(6) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 5
Key = "Timer"
Text = "计时器"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(7) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 6
Key = "UpLevel"
Text = "晋级"
Object.Width = 2540
EndProperty
BeginProperty ColumnHeader(8) {BDD1F052-858B-11D1-B16A-00C0F0283628}
SubItemIndex = 7
Key = "TableTime"
Text = "更新时间"
Object.Width = 2540
EndProperty
End
Begin Othello.FlatButton fltbtnHide
Height = 240
Left = 3000
TabIndex = 3
Top = 45
Width = 240
_ExtentX = 423
_ExtentY = 423
Caption = ""
MousePointer = 99
Style = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BackColor = 255
ForeColor = 0
AutoSize = -1 'True
End
Begin Othello.FlatButton fltbtnCreator
Height = 330
Left = 3675
TabIndex = 7
Top = 2070
Width = 900
_ExtentX = 1588
_ExtentY = 582
Caption = "创建人"
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 fltbtnView
Height = 330
Left = 3675
TabIndex = 8
Top = 1620
Width = 900
_ExtentX = 1588
_ExtentY = 582
Caption = "查看"
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.Label lblTitle
Alignment = 2 'Center
AutoSize = -1 'True
BackColor = &H000000FF&
BackStyle = 0 'Transparent
Caption = "-- 棋局列表 --"
ForeColor = &H00FFFFFF&
Height = 180
Left = 825
TabIndex = 4
Top = 75
Width = 1455
End
Begin VB.Line linBorder
BorderColor = &H00FFFFFF&
Index = 8
X1 = 585
X2 = 1800
Y1 = 4905
Y2 = 4905
End
Begin VB.Line linBorder
BorderColor = &H00FFFFFF&
Index = 7
X1 = 2025
X2 = 3240
Y1 = 5175
Y2 = 5175
End
Begin VB.Line linBorder
BorderColor = &H00FFFFFF&
Index = 6
X1 = 1980
X2 = 3195
Y1 = 5040
Y2 = 5040
End
Begin VB.Line linBorder
BorderColor = &H00FFFFFF&
Index = 5
X1 = 540
X2 = 1755
Y1 = 5175
Y2 = 5175
End
Begin VB.Line linBorder
BorderColor = &H00FFFFFF&
Index = 4
X1 = 495
X2 = 1710
Y1 = 5040
Y2 = 5040
End
Begin VB.Line linBorder
BorderColor = &H00FFFFFF&
Index = 3
X1 = 2070
X2 = 3285
Y1 = 4770
Y2 = 4770
End
Begin VB.Line linBorder
BorderColor = &H00FFFFFF&
Index = 2
X1 = 2025
X2 = 3240
Y1 = 4635
Y2 = 4635
End
Begin VB.Line linBorder
BorderColor = &H00FFFFFF&
Index = 1
X1 = 585
X2 = 1800
Y1 = 4770
Y2 = 4770
End
Begin VB.Line linBorder
BorderColor = &H00FFFFFF&
Index = 0
X1 = 540
X2 = 1755
Y1 = 4635
Y2 = 4635
End
Begin VB.Label lblTips
AutoSize = -1 'True
BackColor = &H00000000&
BackStyle = 0 'Transparent
Caption = "请选择棋局:"
ForeColor = &H00E0E0E0&
Height = 180
Left = 240
TabIndex = 1
Top = 765
Width = 990
End
Begin VB.Shape shpTitle
BackColor = &H000000FF&
BackStyle = 1 'Opaque
BorderStyle = 0 'Transparent
Height = 285
Left = 480
Top = 30
Width = 2895
End
End
Attribute VB_Name = "frmTable"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public DockStyle As eDockStyle
Public DockPosition As Single
Public DockingLevel As Single
Public Parent As Form
Dim mMouseX As Single
Dim mMouseY As Single
Dim FormMoving As Boolean
Dim FormResizing As Boolean
Dim FormVisible As Boolean
Dim mlngSecond As Long
Dim mblnServerOK As Boolean
Private Sub fltbtnCreator_Click(Button As Integer)
If Not gblnLogin Then Exit Sub
If lvwTable.SelectedItem Is Nothing Then Exit Sub
fltbtnCreator.Enabled = False
Call frmUserInfo.ShowEx(lvwTable.SelectedItem.Tag, lvwTable.SelectedItem.SubItems(1))
fltbtnCreator.Enabled = True
End Sub
Private Sub fltbtnView_Click(Button As Integer)
' 查看棋局详细信息。
If Not gblnLogin Then Exit Sub
If lvwTable.SelectedItem Is Nothing Then Exit Sub
fltbtnView.Enabled = False
Call frmTableInfo.ShowEx(lvwTable.SelectedItem.Text, False)
fltbtnView.Enabled = True
End Sub
Private Sub Form_Activate()
shpTitle.BackColor = CLR_ACTIVATE
End Sub
Private Sub Form_Deactivate()
shpTitle.BackColor = CLR_DEACTIVATE
End Sub
Private Sub Form_Load()
Dim i As Long
On Error Resume Next
Set picResize.Picture = frmResource.imgResResizer.Picture
Set fltbtnHide.Picture = frmResource.imgResHide1.Picture
Set fltbtnHide.DownPicture = frmResource.imgResHide2.Picture
Set lvwTable.ColumnHeaderIcons = frmResource.ilsResSortIcon
DockingLevel = GetTwipX(10)
'FormMoving = False
'FormResizing = False
'ReloadTimer.Enabled = True
'Set lvwTable.ColumnHeaderIcons = ilsIcon
'Call ShowHeaderIcon(lvwTable, 1, 0, HDF_IMAGE)
linBorder(0).BorderColor = vbWhite
linBorder(1).BorderColor = vbWhite
linBorder(2).BorderColor = vbWhite
linBorder(3).BorderColor = vbWhite
linBorder(4).BorderColor = RGB(210, 220, 210)
linBorder(5).BorderColor = RGB(180, 180, 180)
linBorder(6).BorderColor = RGB(180, 180, 180)
linBorder(7).BorderColor = RGB(210, 220, 210)
linBorder(8).BorderColor = vbWhite
If gwifSave_TableWindow.DockStyle = dsDockNone Then
Call Me.Move(gwifSave_TableWindow.Left, gwifSave_TableWindow.Top, gwifSave_TableWindow.Width, gwifSave_TableWindow.Height)
Else
DockPosition = gwifSave_TableWindow.DockPosition
Me.Width = gwifSave_TableWindow.Width
Me.Height = gwifSave_TableWindow.Height
End If
For i = 1 To MAX_TABLE_ITEM
lvwTable.ColumnHeaders(i).Width = gsngSave_TableItemWidth(i)
Call ShowHeaderIcon(lvwTable, i - 1, 0, 0)
Next i
If glngSave_TableSort > 0 Then
With lvwTable
.Sorted = True
.SortOrder = glngSave_TableSort - 1
.SortKey = glngSave_TableSortKey
End With
Call ShowHeaderIcon(lvwTable, lvwTable.SortKey, lvwTable.SortOrder, HDF_IMAGE)
Else
With lvwTable
.Sorted = False
.SortOrder = lvwDescending
.SortKey = 0
End With
End If
If gblnSave_TableAutoReload Then
tmrReload.Enabled = True
End If
End Sub
Public Sub ShowEx(ByRef Frm As Form)
On Error Resume Next
Set Parent = Frm
FormVisible = True
Call FormMove(True)
'If (Not Started) And gblnLogin Then StartTimer.Enabled = True
Call Me.Show(vbModeless)
End Sub
Public Sub HideEx()
FormVisible = False
MainForm.fltbtnTable.Value = False
Call Me.Hide
End Sub
Private Sub fltbtnReload_Click(Button As Integer)
'If Not fltbtnReload.Enabled Or Not Me.Visible Then Exit Sub
If Not gblnLogin Then Exit Sub
Call ReloadTable(True)
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button And vbLeftButton) = vbLeftButton And FormMoving Then
' 停靠到左边
If Abs(Left + Width - (Parent.Left + gsngBorderX)) < DockingLevel And (Top + Height > Parent.Top + gsngCaptionHeight + gsngBorderY And Top < Parent.Top + gsngCaptionHeight + gsngBorderY + WindowHeight) Then
Call Me.Move(Parent.Left + gsngBorderX - Width, Y - mMouseY + Me.Top)
DockStyle = dsDockLeft
DockPosition = Me.Top - Parent.Top
If Abs(X - mMouseX) > DockingLevel Then
GoTo FreeMove
End If
Exit Sub
End If
' 停靠到右边
If Abs(Me.Left - (Parent.Left + gsngBorderX + WindowWidth + GetTwipX(1))) < DockingLevel And (Top + Height > Parent.Top + gsngCaptionHeight + gsngBorderY And Top < Parent.Top + gsngCaptionHeight + gsngBorderY + WindowHeight) Then
Call Me.Move(Parent.Left + gsngBorderX + WindowWidth + GetTwipX(1), Y - mMouseY + Me.Top)
DockStyle = dsDockRight
DockPosition = Me.Top - Parent.Top
If Abs(X - mMouseX) > DockingLevel Then
GoTo FreeMove
End If
Exit Sub
End If
' 停靠到上边
If Abs(Top + Height - (Parent.Top + gsngCaptionHeight + gsngBorderY)) < DockingLevel And (Left + Width > Parent.Left + gsngBorderX And Left < Parent.Left + gsngBorderX + WindowWidth) Then
Call Me.Move(X - mMouseX + Left, Parent.Top + gsngCaptionHeight + gsngBorderY - Height)
DockStyle = dsDockTop
DockPosition = Me.Left - Parent.Left
If Abs(Y - mMouseY) > DockingLevel Then
GoTo FreeMove
End If
Exit Sub
End If
' 停靠到下面
If Abs(Me.Top - (Parent.Top + gsngCaptionHeight + gsngBorderY + WindowHeight + GetTwipY(1))) < DockingLevel And (Left + Width > Parent.Left + gsngBorderX And Left < Parent.Left + gsngBorderX + WindowWidth) Then
Call Me.Move(X - mMouseX + Left, Parent.Top + gsngCaptionHeight + gsngBorderY + WindowHeight + GetTwipY(1))
DockStyle = dsDockBottom
DockPosition = Me.Left - Parent.Left
If Abs(Y - mMouseY) > DockingLevel Then
GoTo FreeMove
End If
Exit Sub
End If
' 自由移动
FreeMove:
Call Me.Move(X - mMouseX + Me.Left, Y - mMouseY + Me.Top)
DockStyle = dsDockNone
'Debug.Print x / Screen.TwipsPerPixelX, mMouseX, Me.left
Else
If X < lblTitle.Left Or X > lblTitle.Left + lblTitle.Width Or Y < lblTitle.Top Or Y > lblTitle.Top + lblTitle.Height Then
Call ReleaseCapture
End If
End If
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Call SetControlFocus(Me)
If (Button And vbLeftButton) = vbLeftButton Then
Call SetCapture(Me.hWnd)
mMouseX = X: mMouseY = Y
FormMoving = True
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button And vbLeftButton) = vbLeftButton And FormMoving Then
Call ReleaseCapture
FormMoving = False
End If
End Sub
Private Sub Form_Resize()
Call LinePosition(linBorder(0), 0, 0, ScaleWidth, 0)
Call LinePosition(linBorder(1), ScaleWidth - GetTwipX(1), 0, 0, ScaleHeight)
Call LinePosition(linBorder(2), 0, ScaleHeight - GetTwipY(1), ScaleWidth, 0)
Call LinePosition(linBorder(3), 0, 0, 0, ScaleHeight)
Call LinePosition(linBorder(4), GetTwipX(1), GetTwipY(1), ScaleWidth - GetTwipX(2), 0)
Call LinePosition(linBorder(5), ScaleWidth - GetTwipX(2), GetTwipY(1), 0, ScaleHeight - GetTwipY(2))
Call LinePosition(linBorder(6), GetTwipX(1), ScaleHeight - GetTwipY(2), ScaleWidth - GetTwipX(2), 0)
Call LinePosition(linBorder(7), GetTwipX(1), GetTwipY(1), 0, ScaleHeight - GetTwipY(2))
Call LinePosition(linBorder(8), GetTwipX(2), shpTitle.Height + GetTwipY(1), ScaleWidth - GetTwipX(4), 0)
Call shpTitle.Move(GetTwipX(2), GetTwipY(2), ScaleWidth - GetTwipX(3))
Call lblTitle.Move((shpTitle.Width - lblTitle.Width - fltbtnHide.Width - GetTwipX(2)) \ 2)
Call fltbtnHide.Move(shpTitle.Width - fltbtnHide.Width - GetTwipX(1))
Call lblTips.Move(210, 600)
Call lvwTable.Move(200, 900, ScaleWidth - GetTwipX(90), ScaleHeight - GetTwipY(80))
'Call ColumnSize(lvwTable, 1, 30)
'Call ColumnSize(lvwTable, 2, 30)
'Call ColumnSize(lvwTable, 3, 20)
'Call ColumnSize(lvwTable, 4, 19)
Call fltbtnJoin.Move(lvwTable.Left + lvwTable.Width + GetTwipX(7), lvwTable.Top)
Call fltbtnView.Move(lvwTable.Left + lvwTable.Width + GetTwipX(7), fltbtnJoin.Top + fltbtnJoin.Height + GetTwipY(5))
Call fltbtnCreator.Move(lvwTable.Left + lvwTable.Width + GetTwipX(7), fltbtnView.Top + fltbtnView.Height + GetTwipY(5))
Call fltbtnReload.Move(lvwTable.Left + lvwTable.Width + GetTwipX(7), fltbtnCreator.Top + fltbtnCreator.Height + GetTwipY(5))
Call picResize.Move(Me.ScaleWidth - picResize.Width - GetTwipX(3), Me.ScaleHeight - picResize.Height - GetTwipY(3))
End Sub
Public Sub FormMove(Optional ByVal AlwaysMove As Boolean = False)
If Me.Visible Or AlwaysMove Then
Select Case DockStyle
Case dsDockLeft
Call Me.Move(Parent.Left + gsngBorderX - Width, Parent.Top + DockPosition)
Case dsDockRight
Call Me.Move(Parent.Left + gsngBorderX + WindowWidth + GetTwipX(1), Parent.Top + DockPosition)
Case dsDockTop
Call Me.Move(Parent.Left + DockPosition, Parent.Top + gsngCaptionHeight + gsngBorderY - Height)
Case dsDockBottom
Call Me.Move(Parent.Left + DockPosition, Parent.Top + gsngCaptionHeight + gsngBorderY + WindowHeight + GetTwipY(1))
Case dsDockNone
FormMoving = True
mMouseX = 0: mMouseY = 0
Call Form_MouseMove(vbLeftButton, 0, 0, 0)
FormMoving = False
End Select
End If
End Sub
Public Sub FormMinimize()
If Me.Visible Then
Call Me.Hide
End If
End Sub
Public Sub FormNormal()
If FormVisible Then
Call Me.Show(vbModeless)
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
Call ietTable.Cancel
tmrReload.Enabled = False
End Sub
Private Sub lblTitle_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Call Form_MouseDown(Button, Shift, X + lblTitle.Left, Y + lblTitle.Top)
End Sub
Private Sub lblTitle_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Call SetCapture(Me.hWnd)
End Sub
Private Sub ietTable_StateChanged(ByVal State As Integer)
'Dim strMess As String '消息变量。
On Error Resume Next
Select Case State
Case icResponseReceived
mblnServerOK = True
Case icError '11
mblnServerOK = False
tmrReload.Enabled = True
'得到错误文本。
'strMess = "ErrorCode: " & ietRegister.ResponseCode & " : " & ietRegister.ResponseInfo
Case icResponseCompleted
mblnServerOK = True
Dim strStatus As String
Dim strData As String
If GetServerExecute(ietTable, strStatus, strData) Then
Select Case strStatus
Case STATUS_OK
Dim lngSelected As Long
Dim itmX As ListItem
If Not (lvwTable.SelectedItem Is Nothing) Then
lngSelected = lvwTable.SelectedItem.Index
End If
'MsgBox GetRecord(GetField(msg, 2), 1), vbExclamation, "正确"
Call AddListView(strData)
If lngSelected > 0 And lngSelected <= lvwTable.ListItems.Count Then
Set itmX = lvwTable.ListItems.Item(lngSelected)
End If
If Not (itmX Is Nothing) Then
itmX.Selected = True
End If
Case STATUS_NONE
Call lvwTable.ListItems.Clear
End Select
End If
tmrReload.Enabled = True
End Select
End Sub
Private Sub fltbtnJoin_Click(Button As Integer)
Dim strUrl As String
Dim strStatus As String
Dim strData As String
On Error Resume Next
If (Not gblnLogin) Or gblnCreator Or gblnConnect Or (lvwTable.SelectedItem Is Nothing) Then Exit Sub
fltbtnJoin.Enabled = False
If Not ReloadTable(False) Then Exit Sub
strUrl = gstrSave_ServerUrl & SERVER_ACTION_TABLE_VIEW & _
"?username=" & ToUrlString(gMyUserInfo.UserName) & _
"&password=" & MD5(gMyUserInfo.Password) & _
"&name=" & ToUrlString(lvwTable.SelectedItem.Text) & _
"&" & MakeServerPassword() & _
"&" & MakeVersion()
If ServerCommand(ietTable, mblnServerOK, strUrl, strStatus, strData) Then
Select Case strStatus
Case STATUS_OK
'lvwTable_GotFocus
Dim TableInfo As tagTableInfo
Call LoadTableInfo(TableInfo, strData)
If TableInfo.Visitor = "" Then
' 临时存储棋局名及类型
gMainTableInfo.TableName = TableInfo.TableName
gMainTableInfo.TableType = TableInfo.TableType
Call SetControlFocus(MainForm)
If Len(TableInfo.LANIP) > 5 Then
' 试所有IP。
'MsgBox GetRecord(strData, 13) & ";" & TableInfo.IP
Call MainForm.ReadyTryJoin(TableInfo.LANIP, TableInfo.ip, TableInfo.Port)
Else
Call MainForm.ReadyJoinTable(TableInfo.ip, TableInfo.Port)
End If
Else
Call MessageBox(Me.hWnd, LoadString(160), vbExclamation, LoadString(181))
End If
'MsgBox GetRecord(GetField(msg, 2), 1), vbExclamation, "正确"
'Call AddListView(Msg)
Case STATUS_ERROR
Call MessageBox(Me.hWnd, LoadString(143) & strData, vbExclamation, LoadString(181))
'Case STATUS_NONE
'lvwTable.ListItems.Clear
'Call MessageBox(Me.hWnd, strData, vbExclamation, "加入棋局")
Case Else
Call MessageBox(Me.hWnd, LoadString(144), vbExclamation, LoadString(181))
End Select
'Else
'Call MessageBox(hWnd, "加入棋局列表错误!" & vbCr & vbCr & LoadString(101), vbCritical, "棋局")
End If
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' 子程序: AddListView
'''
''' 描述: 把接收到的数据显示到列表中。
'''
''' 参数: strInfo - 接收字符串
'''
''' 日期: 2002.6.17
'''
''' 作者: 赵畅
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub AddListView(ByVal strInfo As String)
'Dim strRecord As String
Dim OldSorted As Boolean
Dim TempTableInfo As tagTableInfo
Dim itmX As ListItem
Dim i As Long
On Error Resume Next
OldSorted = lvwTable.Sorted
lvwTable.Sorted = False
Call lvwTable.ListItems.Clear
For i = 1 To GetFieldCount(strInfo)
Call LoadTableInfo(TempTableInfo, GetField(strInfo, i))
Set itmX = lvwTable.ListItems.Add(, , TempTableInfo.TableName)
' 把自己创建的或加入的棋局显示为蓝色。
If itmX.Text = gMainTableInfo.TableName Then
itmX.ForeColor = vbBlue
End If
With itmX
.Tag = TempTableInfo.Creator
.SubItems(1) = GetDisplayName(TempTableInfo.Creator, TempTableInfo.CreatorName)
.SubItems(2) = GetDisplayName(TempTableInfo.Visitor, TempTableInfo.VisitorName)
.SubItems(3) = IIf(TempTableInfo.Visitor = "", LoadString(211), LoadString(212))
If TempTableInfo.TableType = TABLE_PUBLIC Then
.SubItems(4) = LoadString(213)
Else
.SubItems(4) = LoadString(214)
End If
If TempTableInfo.Timer > 0 Then
.SubItems(5) = CStr(TempTableInfo.Timer) & LoadString(215)
Else
.SubItems(5) = LoadString(216)
End If
.SubItems(6) = IIf(TempTableInfo.UpLevel, LoadString(217), LoadString(218))
.SubItems(7) = Format(TempTableInfo.LastTime, "yyyy年m月d日 hh:mm:ss")
End With
Next i
lvwTable.Sorted = OldSorted
End Sub
Private Sub lvwTable_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader)
Dim i As Long
On Error Resume Next
For i = 0 To lvwTable.ColumnHeaders.Count - 1
Call ShowHeaderIcon(lvwTable, i, 0, 0)
Next i
If lvwTable.SortKey = ColumnHeader.Index - 1 Then
' 交换升降序!
lvwTable.SortOrder = ToPartner(lvwTable.SortOrder, 1)
Else
lvwTable.SortOrder = lvwAscending
End If
Call ShowHeaderIcon(lvwTable, ColumnHeader.Index - 1, lvwTable.SortOrder, HDF_IMAGE)
lvwTable.SortKey = ColumnHeader.Index - 1
lvwTable.Sorted = True
End Sub
Private Sub lvwTable_DblClick()
If fltbtnJoin.Enabled Then
Call fltbtnJoin_Click(vbLeftButton)
End If
End Sub
Private Sub lvwTable_ItemClick(ByVal Item As MSComctlLib.ListItem)
If Item.SubItems(2) = "" And (Not gblnCreator) And (Not gblnConnect) Then
fltbtnJoin.Enabled = True
Else
fltbtnJoin.Enabled = False
End If
End Sub
Private Sub fltbtnHide_Click(Button As Integer)
Call Me.HideEx
End Sub
Private Sub picResize_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button And vbLeftButton) = vbLeftButton Then
Call SetCapture(picResize.hWnd)
mMouseX = X: mMouseY = Y
FormResizing = True
End If
End Sub
Private Sub picResize_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button And vbLeftButton) = vbLeftButton And FormResizing Then
If X - mMouseX + Me.Width < lblTitle.Width + fltbtnHide.Width + 100 And Y - mMouseY + Me.Height < LIMIT_HEIGHT Then
Call Me.Move(Me.Left, Me.Top, lblTitle.Width + fltbtnHide.Width + 100, LIMIT_HEIGHT)
Exit Sub
End If
If X - mMouseX + Me.Width < lblTitle.Width + fltbtnHide.Width + 100 Then
Call Me.Move(Me.Left, Me.Top, lblTitle.Width + fltbtnHide.Width + 100, Y - mMouseY + Me.Height)
Exit Sub
End If
If Y - mMouseY + Me.Height < LIMIT_HEIGHT Then
Call Me.Move(Me.Left, Me.Top, X - mMouseX + Me.Width, LIMIT_HEIGHT)
Exit Sub
End If
Call Me.Move(Me.Left, Me.Top, X - mMouseX + Me.Width, Y - mMouseY + Me.Height)
End If
End Sub
Private Sub picResize_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button And vbLeftButton) = vbLeftButton And FormResizing Then
Call ReleaseCapture
mMouseX = X: mMouseY = Y: FormMoving = True
Call Form_MouseMove(vbLeftButton, Shift, X, Y)
FormMoving = False
FormResizing = False
End If
End Sub
Public Function ReloadTable(ByVal Async As Boolean) As Boolean
Dim strUrl As String
Dim strStatus As String
Dim strData As String
On Error Resume Next
If Not gblnLogin Then
Call lvwTable.ListItems.Clear
ReloadTable = True
Exit Function
End If
tmrReload.Enabled = False
strUrl = gstrSave_ServerUrl & SERVER_ACTION_TABLE_GET & _
"?username=" & ToUrlString(gMyUserInfo.UserName) & _
"&" & MakeServerPassword() & _
"&" & MakeVersion()
If Async Then
ReloadTable = ServerExecute(ietTable, strUrl)
Else
If ServerCommand(ietTable, mblnServerOK, strUrl, strStatus, strData, True) Then
tmrReload.Enabled = True
Select Case strStatus
Case STATUS_OK
Dim lngSelected As Long
Dim itmX As ListItem
If Not (lvwTable.SelectedItem Is Nothing) Then
lngSelected = lvwTable.SelectedItem.Index
End If
'MsgBox GetRecord(GetField(msg, 2), 1), vbExclamation, "正确"
Call AddListView(strData)
If lngSelected > 0 And lngSelected <= lvwTable.ListItems.Count Then
Set itmX = lvwTable.ListItems.Item(lngSelected)
End If
If Not (itmX Is Nothing) Then
itmX.Selected = True
End If
ReloadTable = True
Exit Function
'Case STATUS_ERROR
'Call MessageBox(Me.hwnd, strData, vbCritical, "棋局")
Case STATUS_NONE
Call lvwTable.ListItems.Clear
'Call MessageBox(Me.hwnd, msg, vbCritical, "棋局")
'Case Else
'Call MessageBox(Me.hwnd, strData, vbCritical, "棋局")
'Call MessageBox(Me.hwnd, "错误!请重试!", vbCritical, "棋局")
End Select
'Else
'MsgBox "刷新棋局列表错误!" & vbCr & vbCr & LoadString(101), vbCritical, "棋局"
End If
tmrReload.Enabled = True
ReloadTable = False
End If
End Function
Public Function AutoJoin() As Boolean
Dim strUrl As String
Dim strStatus As String
Dim strData As String
On Error Resume Next
If (Not ReloadTable(False)) Or lvwTable.ListItems.Count < 1 Then
AutoJoin = False
Exit Function
End If
strUrl = gstrSave_ServerUrl & SERVER_ACTION_TABLE_AUTOJOIN & _
"?username=" & ToUrlString(gMyUserInfo.UserName) & _
"&password=" & MD5(gMyUserInfo.Password) & _
"&" & MakeServerPassword() & _
"&" & MakeVersion()
If ServerCommand(ietTable, mblnServerOK, strUrl, strStatus, strData, True) Then
Select Case strStatus
Case STATUS_OK
AutoJoin = BestJoin(strData)
Case Else
AutoJoin = False
Exit Function
End Select
Else
AutoJoin = False
End If
End Function
Private Function BestJoin(ByVal strInfo As String) As Boolean
Dim TableInfo() As tagTableInfo
Dim CreatorInfo() As tagUserInfo
Dim Count As Long
Dim i As Long
Dim Temp As String
Dim BestTableInfo As tagTableInfo
Dim BestCreatorInfo As tagUserInfo
On Error Resume Next
Count = GetFieldCount(strInfo) \ 2
If Count < 1 Then
BestJoin = False
Exit Function
End If
ReDim TableInfo(Count) As tagTableInfo
ReDim CreatorInfo(Count) As tagUserInfo
For i = 1 To GetFieldCount(strInfo) Step 2
If GetField(strInfo, i) <> "" Then
Call LoadTableInfo(TableInfo(i \ 2 + 1), GetField(strInfo, i))
End If
If GetField(strInfo, i + 1) <> "" Then
Call LoadUserInfo(CreatorInfo(i \ 2 + 1), GetField(strInfo, 1 + 1))
End If
Next i
If TableInfo(1).Visitor <> "" Or CreatorInfo(1).UserName = gMyUserInfo.UserName Then
BestJoin = False
Exit Function
End If
BestTableInfo = TableInfo(1)
BestCreatorInfo = CreatorInfo(1)
For i = 2 To Count
If CreatorInfo(i).UserName <> gMyUserInfo.UserName _
And TableInfo(i).Visitor = "" _
And (TableInfo(i).LANIP = "" Or TableInfo(i).ip = gstrIP) _
And Abs(CreatorInfo(i).Score - gMyUserInfo.Score) < Abs(BestCreatorInfo.Score - gMyUserInfo.Score) Then
BestTableInfo = TableInfo(i)
BestCreatorInfo = CreatorInfo(i)
End If
Next i