【VB开源代码栏目提醒】:网学会员VB开源代码为您提供frmChat.frm参考,解决您在frmChat.frm学习中工作中的难题,参考学习。
VERSION 5.00
Begin VB.Form frmChat
BorderStyle = 5 'Sizable ToolWindow
Caption = "Chat"
ClientHeight = 2040
ClientLeft = 4605
ClientTop = 300
ClientWidth = 5400
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2040
ScaleWidth = 5400
Begin VB.TextBox txtSend
Alignment = 1 'Right Justify
Height = 375
Left = 240
MaxLength = 40
TabIndex = 0
Top = 1440
Width = 3735
End
Begin VB.CommandButton cmdSend
Caption = "Send"
Height = 375
Left = 4200
TabIndex = 1
Top = 1440
Width = 735
End
Begin
VB.TextBox txtTalking
Alignment = 1 'Right Justify
Height = 1215
Left = 240
MousePointer = 1 'Arrow
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 2
TabStop = 0 'False
Top = 120
Width = 4695
End
End
Attribute VB_Name = "frmChat"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'
Option Explicit
Private Sub cmdSend_Click()
Dim s As String
s = txtSend.Text
If frmCOM.MSComm1.PortOpen Then
If frmCOM.isLegal_forMessage(s) Then
frmCOM.SendMsg ":CHT:" & s & ":"
' clear text box when sent:
txtSend.Text = ""
' in case button is clicked, focus set back to txtSend:
txtSend.SetFocus
If bRUNNING_AS_GUEST Then
frmChat.addTalking frmGuest.lblP2Name.Caption & ": " & s
Else
frmChat.addTalking frmGame.lblPlayerName.Caption & ": " & s
End If
Else
MsgBox "Message has wrong characters"
End If
Else
MsgBox "Cannot send, not connected to game."
End If
End Sub
Public Sub addTalking(ByRef sText As String)
If Len(txtTalking.Text) > 1000 Then txtTalking.Text = ""
txtTalking.Text = txtTalking.Text & sText & vbNewLine
txtTalking.SelStart = Len(txtTalking.Text)
txtTalking.SelLength = 0
Me.Show
End Sub
Private Sub Form_Resize()
On Error GoTo frmChat_resize_error
cmdSend.Left = Me.ScaleWidth - cmdSend.Width - 10
cmdSend.Top = Me.ScaleHeight - cmdSend.Height - 10
txtSend.Left = 0
txtSend.Top = Me.ScaleHeight - txtSend.Height - 10
txtSend.Width = Me.ScaleWidth - cmdSend.Width - 50
txtTalking.Left = 0
txtTalking.Top = 0
txtTalking.Width = Me.ScaleWidth
txtTalking.Height = Me.ScaleHeight - txtSend.Height - 100
Exit Sub
frmChat_resize_error:
Debug.Print "Error on resize of frmChat: " & Err.Description
End Sub
Private Sub txtSend_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then '13 is Key_Return
KeyAscii = 0
cmdSend_Click
End If
End Sub
Private Sub txtTalking_GotFocus()
txtSend.SetFocus
End Sub