📄 frmclient.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
Begin VB.Form frmClient
BackColor = &H00C0C0C0&
Caption = "聊天(客户端)"
ClientHeight = 7980
ClientLeft = 60
ClientTop = 345
ClientWidth = 9990
LinkTopic = "Form1"
ScaleHeight = 7980
ScaleWidth = 9990
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton cmdExit
Caption = "退出"
Height = 375
Left = 4200
TabIndex = 7
Top = 4920
Width = 1230
End
Begin VB.CommandButton cmdQuit
Caption = "断开"
Height = 375
Left = 4200
TabIndex = 6
Top = 4320
Width = 1230
End
Begin VB.TextBox txtOut
Height = 855
Left = 120
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 5
Top = 4320
Width = 3675
End
Begin VB.CommandButton cmdConnect
Caption = "连接"
Height = 375
Left = 4200
TabIndex = 3
Top = 1320
Width = 1230
End
Begin VB.CommandButton cmdLogin
Caption = "登录"
Height = 375
Left = 4200
TabIndex = 2
Top = 600
Width = 1230
End
Begin VB.TextBox txtPort
BackColor = &H00FFFFFF&
Height = 450
Left = 1200
Locked = -1 'True
TabIndex = 1
Top = 1200
Width = 2655
End
Begin VB.TextBox txtHost
BackColor = &H00FFFFFF&
Height = 390
Left = 1200
Locked = -1 'True
TabIndex = 0
Top = 600
Width = 2670
End
Begin RichTextLib.RichTextBox rtbIn
Height = 2295
Left = 120
TabIndex = 4
Top = 1800
Width = 4980
_ExtentX = 8784
_ExtentY = 4048
_Version = 393217
BackColor = 16777215
ReadOnly = -1 'True
ScrollBars = 2
TextRTF = $"frmClient.frx":0000
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin MSComctlLib.Toolbar Toolbar1
Align = 1 'Align Top
Height = 420
Left = 0
TabIndex = 10
Top = 0
Width = 9990
_ExtentX = 17621
_ExtentY = 741
ButtonWidth = 609
ButtonHeight = 582
Appearance = 1
ImageList = "ImageList1"
_Version = 393216
BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
NumButtons = 4
BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "Login"
ImageKey = "login"
EndProperty
BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "Connect"
ImageKey = "connect"
EndProperty
BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "Save"
ImageKey = "save"
EndProperty
BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628}
Key = "Quit"
ImageKey = "quit"
EndProperty
EndProperty
End
Begin VB.Label Label3
BackColor = &H00FF0000&
BackStyle = 0 'Transparent
Caption = "显示框"
ForeColor = &H00000000&
Height = 375
Left = 240
TabIndex = 9
Top = 1320
Width = 810
End
Begin VB.Label lblName
BackColor = &H00FF0000&
BackStyle = 0 'Transparent
Caption = "客户端"
ForeColor = &H00000000&
Height = 240
Left = 240
TabIndex = 8
Top = 720
Width = 615
End
End
Attribute VB_Name = "frmClient"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim NewClient As Boolean
Private Sub cmdConnect_Click()
On Error GoTo errhandle:
tcpClient.RemoteHost = txtHost.Text
tcpClient.RemotePort = txtPort.Text
tcpClient.Connect
NewClient = True
Exit Sub
errhandle:
MsgBox Err.Description
End Sub
Private Sub Command1_Click()
End Sub
Private Sub Command2_Click()
End Sub
Private Sub Command3_Click()
End Sub
Private Sub cmdExit_Click()
Unload frmClient
End Sub
Private Sub cmdLogin_Click()
Load frmClientLogIn
frmClientLogIn.Show
End Sub
Private Sub cmdQuit_Click()
On Error GoTo errhandle:
tcpClient.SendData "^q" & lblName.Caption & CStr(Now())
Exit Sub
errhandle:
MsgBox Err.Description
End Sub
Private Sub Form_Load()
'txtHost.Text = "166.111.162.179"
'txtPort.Text = "5000"
Me.cmdConnect.Enabled = False
Me.cmdQuit.Enabled = False
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
FrmWebBroswer.Show
End Sub
Private Sub tcpClient_Connect()
txtOut.Locked = False
tcpClient.SendData "/" + lblName.Caption
End Sub
Private Sub tcpClient_DataArrival(ByVal bytesTotal As Long)
Dim sData As String
If NewClient Then
MsgBox "has connected successfully"
NewClient = False
End If
tcpClient.GetData sData
rtbIn.Text = rtbIn.Text + sData
rtbIn.SelStart = Len(sData)
If sData = "you can quit." Then
tcpClient.Close
End If
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Key
Case Is = "Connect"
cmdConnect_Click
Case Is = "Login"
cmdLogin_Click
Case Is = "Quit"
cmdQuit_Click
Case Is = "Save"
' cmdSave_click
End Select
End Sub
Private Sub txtOut_KeyUp(KeyCode As Integer, Shift As Integer)
On Error GoTo errhandle:
If KeyCode = 13 Then
tcpClient.SendData lblName.Caption + ":" + txtOut.Text
'rtbIn.Text = rtbIn.Text + txtOut.Text
txtOut.Text = ""
End If
Exit Sub
errhandle:
MsgBox Err.Description
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -