wuziclient.frm
来自「vb编程+从基础到实践光盘代码」· FRM 代码 · 共 2,139 行 · 第 1/5 页
FRM
2,139 行
End
Begin VB.Frame Frame2
BackColor = &H80000000&
Caption = "发送信息"
Height = 1215
Left = 6480
TabIndex = 9
Top = 6120
Visible = 0 'False
Width = 4335
Begin VB.ComboBox UserChoose
Height = 315
Left = 1080
TabIndex = 13
Top = 720
Visible = 0 'False
Width = 1455
End
Begin VB.ComboBox TalkWay
Height = 315
Left = 1080
TabIndex = 12
Text = "None"
Top = 360
Width = 1455
End
Begin VB.Label Label5
BackStyle = 0 'Transparent
Caption = "选择对象"
Height = 255
Left = 120
TabIndex = 11
Top = 720
Visible = 0 'False
Width = 735
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "选择方式"
Height = 255
Left = 120
TabIndex = 10
Top = 360
Width = 1095
End
End
Begin VB.Frame Frame1
BackColor = &H80000000&
Caption = "注册"
Height = 1215
Left = 6480
TabIndex = 1
Top = 6000
Visible = 0 'False
Width = 4335
Begin VB.CommandButton login
Caption = "登陆"
Default = -1 'True
Height = 975
Left = 3120
TabIndex = 8
Top = 240
Width = 1095
End
Begin VB.TextBox Email
Height = 285
Left = 1320
TabIndex = 4
Top = 960
Width = 1695
End
Begin VB.TextBox Password
Height = 285
IMEMode = 3 'DISABLE
Left = 1320
PasswordChar = "*"
TabIndex = 3
Top = 600
Width = 1695
End
Begin VB.TextBox Nickname
Height = 285
Left = 1320
TabIndex = 2
Top = 240
Width = 1695
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "e-mail"
Height = 255
Left = 240
TabIndex = 7
Top = 960
Width = 975
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "密 码"
Height = 255
Left = 240
TabIndex = 6
Top = 600
Width = 1335
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "昵 称"
Height = 195
Left = 240
TabIndex = 5
Top = 240
Width = 375
End
End
Begin MSWinsockLib.Winsock TCP2
Left = 6480
Top = 6480
_ExtentX = 741
_ExtentY = 741
_Version = 393216
RemoteHost = "caojw"
RemotePort = 2002
End
Begin VB.TextBox MessageBox
CausesValidation= 0 'False
Height = 4095
Left = 6360
Locked = -1 'True
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 0
Top = 480
Width = 4455
End
Begin MSComctlLib.ImageList ImageList1
Left = 6000
Top = 2400
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 16
ImageHeight = 16
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 5
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "WuziClient.frx":04BF
Key = ""
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "WuziClient.frx":0A03
Key = ""
EndProperty
BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "WuziClient.frx":0F47
Key = ""
EndProperty
BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "WuziClient.frx":148B
Key = ""
EndProperty
BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "WuziClient.frx":19CD
Key = ""
EndProperty
EndProperty
End
Begin VB.Label WhiteName
Alignment = 2 'Center
BackStyle = 0 'Transparent
BorderStyle = 1 'Fixed Single
BeginProperty Font
Name = "楷体_GB2312"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 375
Left = 3240
TabIndex = 31
Top = 480
Width = 1620
End
Begin VB.Label BlackName
Alignment = 2 'Center
BackStyle = 0 'Transparent
BorderStyle = 1 'Fixed Single
BeginProperty Font
Name = "楷体_GB2312"
Size = 14.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 375
Left = 1320
TabIndex = 30
Top = 480
Width = 1455
End
Begin VB.Menu mnuFile
Caption = "&File"
Begin VB.Menu mnuFileNew
Caption = "&New"
End
End
End
Attribute VB_Name = "WuziClient"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Dim AllUserNickname As String
Const MaxConnect = 8
Dim AllUserss(MaxConnect) As AllUserInfo
Dim Use(MaxConnect) As Boolean
Dim TimeCount As Integer
'标记用户是否已经注册成功
Dim Connected As Boolean
'保存棋盘中棋子的位置
Dim DataArray(14, 14) As Integer
'MyColor为黑棋的颜色标志
Dim MyColor As Integer
'othercolor为白棋使用的颜色
Dim OtherColor As Integer
'用来标致是否轮到你下棋
Dim Drawing As Boolean
'用来存放每步棋的信息
Dim Buffer As String
Dim ErrorCode As Integer
'表示正在观战的棋局号
Dim WatchQiJu As Integer
Dim IfPlaying As Boolean
Dim PlayingNum As Integer
'定义开始下棋的时间
Dim Mytime
'说明是否是第一个棋子
Dim FirstStep As Boolean
'该变量标志是否为在本地机上玩
Dim LocalPlay As Boolean
Dim LocalPlayColor As Boolean
Dim IfSucceed As Boolean
Dim IfWatching As Boolean
Dim CanUseTime As Integer
Dim EveryStepTime As Integer
Dim TimeCanUseCount As Integer
Dim Style As Integer
Dim MidVariant
Const SubWidth = 400
Private Sub CallPlayer_Click()
If IfPlaying Then
MessageBox.Text = MessageBox.Text & "你已经加入了一个棋局,你只有先退出," & _
"然后才能加入新的棋局!" & vbCrLf
Exit Sub
End If
If Opponent.Text <> "" Then
For i = 0 To MaxConnect
If Use(i) Then
If AllUserss(i).Nickname = Opponent.Text Then
Usernumber = AllUserss(i).IndexNum
Exit For
End If
End If
Next
Select Case PlayStyle.ListIndex
Case 0
Style = 0
Case 1
Style = 1
Case 2
Style = 2
Case 3
Style = 3
Case 4
Style = 4
End Select
Select Case Style
Case 1
CanUseTime = 60
EveryStepTime = 60
TimeCanUseCount = 60
Case 2
CanUseTime = 30
EveryStepTime = 30
TimeCanUseCount = 30
Case 3
CanUseTime = 10
EveryStepTime = 10
TimeCanUseCount = 10
Case 4
CanUseTime = 0
EveryStepTime = 10
TimeCanUseCount = 10
Case 5
End Select
TCP2.SendData "/P:" & YourNickName & ":" & Format(Usernumber, "000") & ":" & Style & ":" & ColorChoose.ListIndex
If ColorChoose.ListIndex = 0 Then
MyColor = 0
OtherColor = 1
Else
MyColor = 1
OtherColor = 0
End If
Else
MsgBox "请选择对手", vbCritical, "注意!"
Exit Sub
End If
End Sub
Private Sub Clear_Click()
MessageBox.Text = ""
End Sub
Private Sub CmdMessage_Click()
If MessageSend.Text <> "" Then
Select Case TalkWay.ListIndex
Case 0
TCP2.SendData "/3:" & YourNickName & "<shout>::" & MessageSend.Text
Case 1
For i = 0 To MaxConnect
If Use(i) Then
If AllUserss(i).Nickname = UserChoose.Text Then
Usernumber = AllUserss(i).IndexNum
Exit For
End If
End If
Next
TCP2.SendData "/4:" & YourNickName & "<only talk to " & _
UserChoose.Text & ">::" & MessageSend.Text & ":" & Format(Usernumber, "000")
str11 = YourNickName & "<only talk to " & _
UserChoose.Text & ">::" & MessageSend.Text & Format(Usernumber, "000")
Case 3
If IfWatching Then
TCP2.SendData "/5:" & MessageSend.Text & ":" & Format(WatchQiJu, "000")
Else
MsgBox "只有观战的时候才能够chat!", vbCritical
End If
End Select
End If
End Sub
Private Sub cmdPlay_Click()
Frame5.Visible = True
Frame1.Visible = False
Frame2.Visible = False
Frame6.Visible = False
End Sub
Private Sub Connect_Click()
If Connect.Tag = 1 Then
TCP2.Connect
' Connect.Enabled = False
' Register.Enabled = True
MessageBox.Text = "Connect the server..." & vbCrLf
Timer1.Enabled = True
Connect.Tag = 2
' Connect.Caption = "下网"
'Users.Enabled = True
Else
TCP2.SendData "/E:"
TCP2.Close
Connect.Caption = "上网"
Connect.Enabled = True
Connect.Tag = 1
Connected = False
IfPlaying = False
Register.Enabled = False
Users.Enabled = False
Sendmessage.Enabled = False
Timer1.Enabled = False
cmdPlay.Enabled = False
Watch.Enabled = False
WuziClient.Caption = "五子棋客户端程序"
End If
End Sub
Private Sub Form_Load()
Dim X As Integer
Dim Y As Integer
'X = Screen.Width
'Y = Screen.Height
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?