frmchat.frm

来自「使用vb寫出完美網頁遊戲外掛的原始碼分享」· FRM 代码 · 共 196 行

FRM
196
字号
VERSION 5.00
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
Begin VB.Form frmChat 
   Caption         =   "Chat"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4875
   Icon            =   "frmChat.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   4875
   StartUpPosition =   3  'Windows Default
   Begin VB.ListBox lstsay 
      Height          =   255
      Left            =   0
      TabIndex        =   4
      Top             =   0
      Visible         =   0   'False
      Width           =   1890
   End
   Begin VB.ComboBox lstChatMenu 
      Appearance      =   0  'Flat
      Height          =   315
      ItemData        =   "frmChat.frx":058A
      Left            =   0
      List            =   "frmChat.frx":058C
      Style           =   2  'Dropdown List
      TabIndex        =   3
      Top             =   2880
      Width           =   1095
   End
   Begin VB.TextBox txtsay 
      Appearance      =   0  'Flat
      BackColor       =   &H00FFFFFF&
      ForeColor       =   &H00000000&
      Height          =   285
      Left            =   1260
      MaxLength       =   100
      TabIndex        =   2
      Top             =   2880
      Width           =   3555
   End
   Begin VB.ComboBox cbWhisper 
      Height          =   315
      Left            =   1110
      TabIndex        =   1
      Top             =   2880
      Visible         =   0   'False
      Width           =   1155
   End
   Begin RichTextLib.RichTextBox rtbChat 
      Height          =   2355
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   4545
      _ExtentX        =   8017
      _ExtentY        =   4154
      _Version        =   393217
      BorderStyle     =   0
      Enabled         =   -1  'True
      ReadOnly        =   -1  'True
      ScrollBars      =   2
      Appearance      =   0
      TextRTF         =   $"frmChat.frx":058E
   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 Form_Load()
CreateChat
End Sub

Private Sub Form_Resize()
On Error Resume Next
rtbChat.Width = Me.ScaleWidth
rtbChat.Height = Me.ScaleHeight - lstChatMenu.Height
lstChatMenu.Top = rtbChat.Height + 15
cbWhisper.Top = lstChatMenu.Top
txtsay.Top = lstChatMenu.Top
If cbWhisper.Visible Then
txtsay.Width = rtbChat.Width - cbWhisper.Left - cbWhisper.Width
Else
txtsay.Width = rtbChat.Width - lstChatMenu.Left - lstChatMenu.Width
End If
End Sub

Private Sub lstChatMenu_Change()
lstChatMenu_Click
End Sub

Private Sub lstChatMenu_Click()
If lstChatMenu.ListIndex = 2 Or lstChatMenu.ListIndex = 7 Then
cbWhisper.Visible = True
txtsay.Left = cbWhisper.Left + cbWhisper.Width
txtsay.Width = rtbChat.Width - cbWhisper.Left - cbWhisper.Width
Else
cbWhisper.Visible = False
txtsay.Left = lstChatMenu.Left + lstChatMenu.Width
txtsay.Width = rtbChat.Width - lstChatMenu.Left - lstChatMenu.Width
End If
End Sub

Private Sub txtsay_KeyDown(KeyCode As Integer, Shift As Integer)
    If (KeyCode = 13) And (Trim(txtsay.Text) <> "") Then
        lstsay.AddItem txtsay.Text
        
Dim towhisper As String, numsay As Integer
towhisper = cbWhisper.Text
    Dim i As Integer
    If towhisper <> "" Then
        For i = 0 To cbWhisper.ListCount
            If cbWhisper.List(i) = towhisper Then GoTo z
        Next
        cbWhisper.AddItem towhisper
End If
z:
        SendChat
        If (lstsay.ListCount > 20) Then lstsay.RemoveItem (0)
        numsay = lstsay.ListCount
        txtsay.Text = ""
    ElseIf (KeyCode = 38) Then
        If (numsay > 0) Then
             txtsay.Text = lstsay.List(numsay - 1)
             numsay = numsay - 1
        End If
    ElseIf (KeyCode = 40) Then
        If (numsay < lstsay.ListCount) Then
             txtsay.Text = lstsay.List(numsay + 1)
             numsay = numsay + 1
        End If
    End If
End Sub

Public Sub SendChat()
If (lstChatMenu.Text = "Public") Then
    SendPacket Chr(&H1) & Chr(&H0) & Chr(&H8) & Chr(&H0) & Chr(&H68) & Chr(&H0) & Chr(&H0) & _
                              Chr(&H0) & Chr(&HF0) & Chr(&HBE) & Chr(&H1B) & Chr(&H0) & Chr(&HF2) & Chr(&HC) & _
                              Chr(&H13) & Chr(&H0) & Chr(&H91) & Chr(&H61) & Chr(&H73) & Chr(&HF) & Chr(&HFF) & _
                              Chr(&H0) & Chr(&H0) & Chr(&H0) & Chr(&HFF) & Chr(&H3F) & Chr(&H0) & Chr(&H0) & _
                              Chr(Len(txtsay.Text)) & txtsay.Text, 1
ElseIf (lstChatMenu.Text = "Whisper") Then
    SendPacket Chr(&H1) & Chr(&H0) & Chr(&H8) & Chr(&H0) & Chr(&H68) & Chr(&H0) & Chr(&H4) & _
    IncBuf(cbWhisper.Text, 17) & Chr(&HFF) & Chr(&H3F) & Chr(&H0) & Chr(&H0) & Chr(Len(txtsay.Text) + 1) & _
    Chr(&H20) & IncBuf(txtsay.Text, 62) & Chr(&H0) & Chr(&H2) & Chr(&H15) & Chr(&H50) & Chr(&H0) & _
    Chr(&H0) & Chr(&H70) & Chr(&HC) & Chr(&H0) & Chr(&H0) & Chr(&H70) & Chr(&HC4) & Chr(&H0) & _
    Chr(&H0) & Chr(&H34) & Chr(&H45) & Chr(&H0) & Chr(&H0), 1
End If

'AA 55 6E 00
'01 00 08 00 68 00 04 79 67 70 6C 75 73 00 00 00
'00 00 00 00 00 00 00 00 FF 3F 00 00 08 20 31 31
'31 31 31 31 31 00 08 00 47 ED 07 00 00 07 03 07
'00 03 03 03 00 03 03 03 37 00 00 00 37 00 00 00
'1F 00 00 00 00 08 00 00 00 08 00 00 00 04 00 00
'00 08 00 00 00 08 00 00 10 00 00 00 F9 02 15 50
'00 00 70 C4 00 00 70 C4 00 00 34 45 00 00
'55 AA

'AA 55 6E 00
'01 00 08 00 68 00 04 79 67 50 6C 75 73 00 00 00
'00 00 00 00 00 00 00 00 FF 3F 00 00 1D 20 31 31
'31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
'31 31 31 31 31 31 31 31 31 31 00 00 37 00 00 00
'1F 00 00 00 00 08 00 00 00 08 00 00 00 04 00 00
'00 08 00 00 00 08 00 00 10 00 00 00 F9 02 15 50
'00 00 70 C4 00 00 70 C4 00 00 34 45 00 00
'55 AA

'AA 55 6E 00
'01 00 08 00 68 00 04 79 67 50 6C 75 73 00 00 00
'00 00 00 00 00 00 00 00 FF 3F 00 00 3F 20 31 31
'31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31
'31 31 31 31 31 31 31 31 31 32 32 32 32 32 32 32
'32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
'32 32 32 32 32 32 32 32 32 32 32 32 00 02 15 50
'00 00 70 C4 00 00 70 C4 00 00 34 45 00 00
'55 AA

'AA 55 6E 00
'01 00 08 00 68 00 04 50 6C 75 73 73 73 73 00 00
'00 00 00 00 00 00 00 00 FF 3F 00 00 19 20 71 71
'71 71 71 71 71 71 71 71 71 71 71 71 71 71 71 71
'71 71 71 71 71 71 00 03 37 00 00 00 37 00 00 00
'1F 00 00 00 00 08 00 00 00 08 00 00 00 04 00 00
'00 08 00 00 00 08 00 00 10 00 00 00 F9 02 15 50
'00 00 70 C4 00 00 70 C4 00 00 34 45 00 00
'55 AA
End Sub

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?