-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFRMACT.frm
More file actions
304 lines (297 loc) · 11.4 KB
/
FRMACT.frm
File metadata and controls
304 lines (297 loc) · 11.4 KB
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
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form FRMACT
AutoRedraw = -1 'True
BackColor = &H00221C13&
BorderStyle = 0 'None
Caption = "活动"
ClientHeight = 9390
ClientLeft = 0
ClientTop = 0
ClientWidth = 6975
LinkTopic = "Form1"
ScaleHeight = 626
ScaleMode = 3 'Pixel
ScaleWidth = 465
ShowInTaskbar = 0 'False
StartUpPosition = 3 '窗口缺省
Begin VB.PictureBox X2
AutoRedraw = -1 'True
AutoSize = -1 'True
BorderStyle = 0 'None
Height = 705
Left = 6210
Picture = "FRMACT.frx":0000
ScaleHeight = 47
ScaleMode = 3 'Pixel
ScaleWidth = 50
TabIndex = 6
Top = 15
Visible = 0 'False
Width = 750
End
Begin VB.PictureBox X3
AutoRedraw = -1 'True
AutoSize = -1 'True
BorderStyle = 0 'None
Height = 705
Left = 6210
Picture = "FRMACT.frx":00E4
ScaleHeight = 47
ScaleMode = 3 'Pixel
ScaleWidth = 50
TabIndex = 5
Top = 15
Visible = 0 'False
Width = 750
End
Begin VB.PictureBox X1
AutoRedraw = -1 'True
AutoSize = -1 'True
BorderStyle = 0 'None
Height = 705
Left = 6210
Picture = "FRMACT.frx":01C8
ScaleHeight = 47
ScaleMode = 3 'Pixel
ScaleWidth = 50
TabIndex = 4
Top = 15
Width = 750
End
Begin ICEE.ICEE_WIN8 IW
Height = 2775
Index = 0
Left = 120
TabIndex = 1
Top = 960
Width = 6735
_extentx = 11880
_extenty = 4895
Begin MSWinsockLib.Winsock Winsock1
Index = 2
Left = 4560
Top = 240
_ExtentX = 741
_ExtentY = 741
_Version = 393216
End
Begin MSWinsockLib.Winsock Winsock1
Index = 1
Left = 5280
Top = 240
_ExtentX = 741
_ExtentY = 741
_Version = 393216
End
Begin MSWinsockLib.Winsock Winsock1
Index = 0
Left = 5880
Top = 240
_ExtentX = 741
_ExtentY = 741
_Version = 393216
End
End
Begin ICEE.ICEE_WIN8 IW
Height = 2775
Index = 1
Left = 120
TabIndex = 2
Top = 3720
Width = 6735
_extentx = 11880
_extenty = 4895
End
Begin ICEE.ICEE_WIN8 IW
Height = 2775
Index = 2
Left = 120
TabIndex = 3
Top = 6480
Width = 6735
_extentx = 11880
_extenty = 4895
End
Begin VB.Label LA
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "每月都有三次活动"
ForeColor = &H00FFFFFF&
Height = 180
Left = 240
TabIndex = 0
Top = 600
Width = 1440
End
End
Attribute VB_Name = "FRMACT"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'
Private FName As String, FNAME2 As String, FNAME3 As String
Private Sub Form_Load()
Call PaintPng(App.Path & "\SKIN\A_T.PNG", Me.hdc, 8, 8)
Me.Line (0, 0)-(ScaleWidth - 1, ScaleHeight - 1), &H404000, B
FName = App.Path & "\USER\ACT\ACTIVE1.Bmp" '指定接收文件完整路径
FNAME2 = App.Path & "\USER\ACT\ACTIVE2.Bmp" '指定接收文件完整路径
FNAME3 = App.Path & "\USER\ACT\ACTIVE3.Bmp" '指定接收文件完整路径
Call GETACT(0, frmma.Text3.Text)
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Call CMV(Me)
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
X1.Visible = True
X2.Visible = False
X3.Visible = False
End Sub
Private Sub LA_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Call CMV(Me)
End Sub
Private Sub x1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
X1.Visible = False
X2.Visible = True
End Sub
Private Sub x2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
X2.Visible = False
X3.Visible = True
End If
End Sub
Private Sub x3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
X3.Visible = False
X1.Visible = True
If X3.Visible = False Then Unload Me
End Sub
Sub GETACT(Index As Integer, IP As String)
If Winsock1(Index).State <> sckClosed Then Winsock1(Index).Close '关闭连接
Winsock1(Index).RemoteHost = IP '服务器地址
Winsock1(Index).RemotePort = 4567 '服务器端口
Winsock1(Index).Connect '连接
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim I As Integer
For I = 0 To Winsock1.Count - 1
Winsock1(I).Close '关闭连接
Next
End Sub
Private Sub Winsock1_Close(Index As Integer)
Winsock1(Index).Close '关闭连接
End Sub
Private Sub Winsock1_DataArrival(Index As Integer, ByVal bytesTotal As Long)
Dim TheFile() As Byte '接受数据的数组
ReDim TheFile(bytesTotal) '重定义数组下界
Static YNLen As Boolean '是否接收了文件长度
Dim I As Integer
Dim Strs As String '描述文件长度字符串
Select Case Index
Case 0
Winsock1(0).GetData TheFile '将接收的数据保存到数组
If bytesTotal = 2 And Chr(TheFile(0)) = "C" And Chr(TheFile(1)) = "S" Then '如果收到的是成功连接信息
'Me.Caption = "客户端-----成功连接" '提示信息
Winsock1(0).SendData "GetFileLen" '发送要求文件长度信息
Exit Sub '结束过程
End If
If bytesTotal = 3 And Chr(TheFile(0)) = "N" And Chr(TheFile(1)) = "o" And Chr(TheFile(2)) = "F" Then '如果收到的是无此文件的信息
Call SHOWWRONG("服务器并无此文件", 2)
Exit Sub '结束过程
End If
If bytesTotal = 3 And Chr(TheFile(0)) = "T" And Chr(TheFile(1)) = "h" And Chr(TheFile(2)) = "E" Then '如果收到文件传送结束信息
Close #1 '关闭文件
YNLen = False '未接收文件长度描述信息
Debug.Print "文件已成功接收" '提示信息
Winsock1(0).SendData "ConClose" '关闭连接
Exit Sub
End If
If YNLen = True Then '如果已经接收了文件长度信息
Put #1, , TheFile '将接收的数据包写入该文件
Winsock1(0).SendData "NextB" '发送要求下一数据包的信息
Debug.Print bytesTotal '接收文件进度
Else
Debug.Print "正在接收数据" '提示信息
For I = 0 To bytesTotal - 1
Strs = Strs & Chr(TheFile(I)) '组合文件长度描述字符串
Next I
YNLen = True '已经接收了文件长度描述信息
Winsock1(0).SendData "FLA" '发送已经收到文件长度描述信息的信息"FLA"
Open FName For Binary As #1
IW(0).IS_PIC = True
IW(0).SETPIC FName
Call GETACT(1, "127.0.0.1")
End If
Case 1
Winsock1(1).GetData TheFile '将接收的数据保存到数组
If bytesTotal = 2 And Chr(TheFile(0)) = "C" And Chr(TheFile(1)) = "S" Then '如果收到的是成功连接信息
'Me.Caption = "客户端-----成功连接" '提示信息
Winsock1(1).SendData "GETFILE2" '发送要求文件长度信息
Exit Sub '结束过程
End If
If bytesTotal = 3 And Chr(TheFile(0)) = "N" And Chr(TheFile(1)) = "o" And Chr(TheFile(2)) = "F" Then '如果收到的是无此文件的信息
Call SHOWWRONG("服务器并无此文件", 2)
Exit Sub '结束过程
End If
If bytesTotal = 3 And Chr(TheFile(0)) = "T" And Chr(TheFile(1)) = "h" And Chr(TheFile(2)) = "E" Then '如果收到文件传送结束信息
Close #1 '关闭文件
YNLen = False '未接收文件长度描述信息
Debug.Print "文件已成功接收" '提示信息
Winsock1(1).SendData "ConClose" '关闭连接
Exit Sub
End If
If YNLen = True Then '如果已经接收了文件长度信息
Put #1, , TheFile '将接收的数据包写入该文件
Winsock1(1).SendData "NextB" '发送要求下一数据包的信息
Debug.Print bytesTotal '接收文件进度
Else
Debug.Print "正在接收数据" '提示信息
For I = 0 To bytesTotal - 1
Strs = Strs & Chr(TheFile(I)) '组合文件长度描述字符串
Next I
YNLen = True '已经接收了文件长度描述信息
Winsock1(1).SendData "FLA" '发送已经收到文件长度描述信息的信息"FLA"
Open FNAME2 For Binary As #1
IW(1).IS_PIC = True
IW(1).SETPIC FNAME2
Call GETACT(2, "127.0.0.1")
End If
Case 2
Winsock1(2).GetData TheFile '将接收的数据保存到数组
If bytesTotal = 2 And Chr(TheFile(0)) = "C" And Chr(TheFile(1)) = "S" Then '如果收到的是成功连接信息
'Me.Caption = "客户端-----成功连接" '提示信息
Winsock1(2).SendData "GETFILE3" '发送要求文件长度信息
Exit Sub '结束过程
End If
If bytesTotal = 3 And Chr(TheFile(0)) = "N" And Chr(TheFile(1)) = "o" And Chr(TheFile(2)) = "F" Then '如果收到的是无此文件的信息
Call SHOWWRONG("服务器并无此文件", 2)
Exit Sub '结束过程
End If
If bytesTotal = 3 And Chr(TheFile(0)) = "T" And Chr(TheFile(1)) = "h" And Chr(TheFile(2)) = "E" Then '如果收到文件传送结束信息
Close #1 '关闭文件
YNLen = False '未接收文件长度描述信息
Debug.Print "文件已成功接收" '提示信息
Winsock1(2).SendData "ConClose" '关闭连接
Exit Sub
End If
If YNLen = True Then '如果已经接收了文件长度信息
Put #1, , TheFile '将接收的数据包写入该文件
Winsock1(2).SendData "NextB" '发送要求下一数据包的信息
Debug.Print bytesTotal '接收文件进度
Else
Debug.Print "正在接收数据" '提示信息
For I = 0 To bytesTotal - 1
Strs = Strs & Chr(TheFile(I)) '组合文件长度描述字符串
Next I
YNLen = True '已经接收了文件长度描述信息
Winsock1(2).SendData "FLA" '发送已经收到文件长度描述信息的信息"FLA"
Open FNAME3 For Binary As #1
IW(2).IS_PIC = True
IW(2).SETPIC FNAME3
End If
End Select
End Sub
Private Sub Winsock1_Error(Index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
Winsock1(Index).Close '关闭连接
Call SHOWWRONG("服务器繁忙,请稍后重试!", 2): Unload Me
End Sub