Initial revision
[citadel.git] / wincit / chatwindow.frm
1 VERSION 4.00
2 Begin VB.Form ChatWindow 
3    AutoRedraw      =   -1  'True
4    BorderStyle     =   0  'None
5    Caption         =   "Chat"
6    ClientHeight    =   5940
7    ClientLeft      =   1485
8    ClientTop       =   1635
9    ClientWidth     =   6690
10    ControlBox      =   0   'False
11    Height          =   6345
12    Left            =   1425
13    LinkTopic       =   "Form1"
14    MaxButton       =   0   'False
15    MDIChild        =   -1  'True
16    MinButton       =   0   'False
17    ScaleHeight     =   5940
18    ScaleWidth      =   6690
19    Top             =   1290
20    Width           =   6810
21    Begin VB.CommandButton list_button 
22       Caption         =   "&List chat users"
23       Height          =   495
24       Left            =   3240
25       TabIndex        =   3
26       Top             =   5280
27       Width           =   1335
28    End
29    Begin VB.CommandButton quit_button 
30       Caption         =   "Exit Chat Mode"
31       Height          =   495
32       Left            =   4680
33       TabIndex        =   2
34       Top             =   5280
35       Width           =   1335
36    End
37    Begin VB.Timer ChatRefresh 
38       Interval        =   2000
39       Left            =   120
40       Top             =   5280
41    End
42    Begin VB.TextBox Outgoing 
43       Height          =   375
44       Left            =   120
45       MultiLine       =   -1  'True
46       TabIndex        =   1
47       Top             =   4680
48       Width           =   6495
49    End
50    Begin VB.TextBox Incoming 
51       BeginProperty Font 
52          name            =   "MS Sans Serif"
53          charset         =   0
54          weight          =   400
55          size            =   9.75
56          underline       =   0   'False
57          italic          =   0   'False
58          strikethrough   =   0   'False
59       EndProperty
60       Height          =   4095
61       Left            =   120
62       Locked          =   -1  'True
63       MultiLine       =   -1  'True
64       TabIndex        =   0
65       Top             =   120
66       Width           =   6495
67    End
68 End
69 Attribute VB_Name = "ChatWindow"
70 Attribute VB_Creatable = False
71 Attribute VB_Exposed = False
72
73 Dim LastUser$
74
75 Private Sub ChatRefresh_Timer()
76
77 Top:
78 If InStr(TCPinbuf$, Chr$(10)) > 0 Then
79     a$ = serv_gets()
80     If a$ = "000" Then
81         ChatRefresh.Enabled = False
82         end_trans
83         DoEvents
84         Unload ChatWindow
85         Load RoomPrompt
86         GoTo TheEnd
87         End If
88
89     p = InStr(a$, "|")
90     If p < 1 Then
91         a$ = "?|" + a$
92         p = 2
93         End If
94     ThisUser$ = Left$(a$, p - 1)
95     a$ = Right$(a$, Len(a$) - p)
96     If a$ = "NOOP" Then GoTo Top
97     If (ThisUser$ <> LastUser$) Then
98         Incoming.Text = Incoming.Text + Chr$(13) + Chr$(10) + ThisUser$ + ":"
99         LastUser$ = ThisUser$
100         End If
101     Incoming.Text = Incoming.Text + a$ + Chr$(13) + Chr$(10)
102     
103     ' Count the lines and strip down to 28
104     nl = 0
105     For b = 1 To Len(Incoming.Text)
106         If Mid$(Incoming.Text, b, 1) = Chr$(13) Then nl = nl + 1
107         Next b
108     Do While nl > 28
109         np = InStr(Incoming.Text, Chr$(13))
110         Incoming.Text = Right$(Incoming.Text, Len(Incoming.Text) - np - 2)
111         nl = nl - 1
112         Loop
113         
114     GoTo Top
115     End If
116     
117
118 ChatRefresh.Interval = 2000
119 ChatRefresh.Enabled = True
120
121 TheEnd: Rem - go here when done
122
123 End Sub
124
125
126 Private Sub Form_Load()
127
128 MainWin.MousePointer = 0
129 Show
130 LastUser$ = ""
131 Outgoing.SetFocus
132
133 End Sub
134
135
136
137
138
139 Private Sub Form_Resize()
140
141     ChatWindow.Left = 0
142     ChatWindow.Top = 0
143     ChatWindow.Width = MainWin.Width - 200
144     ChatWindow.Height = MainWin.Height - 450
145     
146     Incoming.Left = 100
147     Incoming.Width = ChatWindow.Width - 200
148     Incoming.Top = 100
149     Incoming.Height = ChatWindow.Height - 1200
150     
151     Outgoing.Left = 100
152     Outgoing.Width = ChatWindow.Width - 200
153     Outgoing.Top = ChatWindow.Height - 1100
154     Outgoing.Height = 400
155
156     quit_button.Top = ChatWindow.Height - 100 - quit_button.Height
157     quit_button.Left = ChatWindow.Width - 100 - quit_button.Width
158     list_button.Top = quit_button.Top
159     list_button.Left = quit_button.Left - quit_button.Width - 100
160
161 End Sub
162
163
164 Private Sub list_button_Click()
165
166 serv_puts ("/who")
167
168 End Sub
169
170 Private Sub Outgoing_Change()
171
172 a = InStr(Outgoing.Text, Chr$(13) + Chr$(10))
173 If (a > 0) Then
174     serv_puts (Left$(Outgoing.Text, a - 1))
175     Outgoing.Text = Right$(Outgoing.Text, Len(Outgoing.Text) - a - 1)
176     End If
177
178 If (Len(Outgoing.Text) > 55) Or (Len(Outgoing.Text) > 48 And Right$(Outgoing.Text, 1) = " ") Then
179     serv_puts (Outgoing.Text)
180     Outgoing.Text = ""
181     End If
182
183 End Sub
184
185
186 Private Sub quit_button_Click()
187
188     serv_puts ("/QUIT")
189     
190
191 End Sub
192
193