-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchat.frm
614 lines (566 loc) · 27.6 KB
/
chat.frm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form frmChat
BorderStyle = 1 'Fixed Single
Caption = "Inter Net Voice"
ClientHeight = 3030
ClientLeft = 2160
ClientTop = 2130
ClientWidth = 4950
FillColor = &H00808080&
Icon = "chat.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 3030
ScaleWidth = 4950
WhatsThisButton = -1 'True
WhatsThisHelp = -1 'True
Begin ComctlLib.Toolbar Tools
Align = 1 'Align Top
Height = 390
Left = 0
TabIndex = 6
Top = 0
Width = 4950
_ExtentX = 8731
_ExtentY = 688
ButtonWidth = 635
ButtonHeight = 582
ImageList = "ImgIcons"
_Version = 327682
BeginProperty Buttons {0713E452-850A-101B-AFC0-4210102A8DA7}
NumButtons = 5
BeginProperty Button1 {0713F354-850A-101B-AFC0-4210102A8DA7}
Key = ""
Object.Tag = ""
Style = 3
EndProperty
BeginProperty Button2 {0713F354-850A-101B-AFC0-4210102A8DA7}
Key = ""
Object.ToolTipText = "Call"
Object.Tag = ""
ImageIndex = 4
EndProperty
BeginProperty Button3 {0713F354-850A-101B-AFC0-4210102A8DA7}
Enabled = 0 'False
Key = ""
Object.ToolTipText = "Hangup"
Object.Tag = ""
ImageIndex = 5
EndProperty
BeginProperty Button4 {0713F354-850A-101B-AFC0-4210102A8DA7}
Key = ""
Object.Tag = ""
Style = 3
EndProperty
BeginProperty Button5 {0713F354-850A-101B-AFC0-4210102A8DA7}
Key = ""
Object.ToolTipText = "Auto Answering"
Object.Tag = ""
ImageIndex = 1
Style = 1
Value = 1
EndProperty
EndProperty
End
Begin VB.PictureBox Picture3
Height = 2565
Left = 60
ScaleHeight = 2505
ScaleWidth = 3945
TabIndex = 0
Top = 390
Width = 4005
Begin VB.CommandButton cmdTalk
Caption = "&Talk"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 345
Left = 540
TabIndex = 4
Top = 2130
Width = 2865
End
Begin VB.ListBox ConnectionList
Height = 1035
ItemData = "chat.frx":0442
Left = 60
List = "chat.frx":0444
TabIndex = 2
Top = 840
Width = 3825
End
Begin VB.ComboBox txtServer
Height = 315
ItemData = "chat.frx":0446
Left = 630
List = "chat.frx":0448
Sorted = -1 'True
TabIndex = 1
Top = 60
Width = 3255
End
Begin VB.Image outLight
Height = 345
Left = 3510
Picture = "chat.frx":044A
Stretch = -1 'True
Top = 2130
Width = 345
End
Begin VB.Image inLight
Height = 345
Left = 60
Picture = "chat.frx":0754
Stretch = -1 'True
Top = 2130
Width = 345
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "Conference List:"
Height = 195
Left = 60
TabIndex = 3
Top = 600
Width = 1425
End
Begin VB.Image imgStatus
Appearance = 0 'Flat
Height = 390
Left = 90
Picture = "chat.frx":0A5E
Stretch = -1 'True
Top = 30
Width = 420
End
End
Begin MSWinsockLib.Winsock TCPSocket
Index = 0
Left = 3720
Top = 3600
_ExtentX = 741
_ExtentY = 741
_Version = 393216
End
Begin VB.Label Label3
Caption = "Label3"
Height = 375
Left = 4200
TabIndex = 7
Top = 840
Width = 495
End
Begin VB.Label Label1
Caption = "Label1"
Height = 375
Left = 4200
TabIndex = 5
Top = 1320
Width = 495
End
Begin ComctlLib.ImageList ImgIcons
Left = 4290
Top = 2070
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 16
ImageHeight = 16
_Version = 327682
BeginProperty Images {0713E8C2-850A-101B-AFC0-4210102A8DA7}
NumListImages = 11
BeginProperty ListImage1 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "chat.frx":0EA0
Key = ""
EndProperty
BeginProperty ListImage2 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "chat.frx":11BA
Key = ""
EndProperty
BeginProperty ListImage3 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "chat.frx":14D4
Key = ""
EndProperty
BeginProperty ListImage4 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "chat.frx":17EE
Key = ""
EndProperty
BeginProperty ListImage5 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "chat.frx":1B08
Key = ""
EndProperty
BeginProperty ListImage6 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "chat.frx":1E22
Key = ""
EndProperty
BeginProperty ListImage7 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "chat.frx":213C
Key = ""
EndProperty
BeginProperty ListImage8 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "chat.frx":2456
Key = ""
EndProperty
BeginProperty ListImage9 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "chat.frx":2770
Key = ""
EndProperty
BeginProperty ListImage10 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "chat.frx":2A8A
Key = ""
EndProperty
BeginProperty ListImage11 {0713E8C3-850A-101B-AFC0-4210102A8DA7}
Picture = "chat.frx":2DA4
Key = ""
EndProperty
EndProperty
End
End
Attribute VB_Name = "frmChat"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Nothing new here, give credits to AlexI (me)
'if you use this code.
'Enjoy
Option Explicit
Public CLOSINGAPPLICATION As Boolean ' Application status flag
Public wStream As Object
Dim cnt As Integer
Dim Iport1 As Integer
'--------------------------------------------------------------
Private Sub cmdTalk_Click() ' Activates Audio PlayBack
'--------------------------------------------------------------
Dim rc As Long ' Return Code Variable
Dim iPort As Integer ' Local Port
Dim itm As Integer ' Current listitem
'--------------------------------------------------------------
If (Not wStream.Playing And wStream.PlayDeviceFree And _
Not wStream.Recording And wStream.RecDeviceFree) Then ' Validate Audio Device Status
wStream.Playing = True ' Turn Playing Status On
cmdTalk.Caption = "&Playing" ' Modify Button Status Caption
Screen.MousePointer = vbHourglass ' Set Pointer To HourGlass
iPort = wStream.StreamInQueue
Iport1 = iPort
Do While (iPort <> NULLPORTID) ' While socket ports have data to playback
inLight.Picture = ImgIcons.ListImages(speakON).Picture ' Flash playback image
inLight.Refresh ' Repaint picture image
For itm = 0 To ConnectionList.ListCount - 1 ' Search for listitem currently playing sound data
If (ConnectionList.ItemData(itm) = iPort) Then ' If a match is found...
ConnectionList.TopIndex = itm ' Set that listitem to top of listbox
ConnectionList.Selected(itm) = True ' Select listitem to show who is currently talking...
Exit For ' Quit listitem search
End If
Next ' Check next listitem
If cnt = 1 Then cnt = 3
If cnt = 0 Then cnt = 1
rc = wStream.PlayWave(Me.hWnd, iPort) ' Play wave data in iPort...
Call wStream.RemoveStreamFromQueue(iPort) ' Remove PortID From PlayWave Queue
iPort = wStream.StreamInQueue
inLight.Picture = ImgIcons.ListImages(speakOFF).Picture ' Show done talking image...
inLight.Refresh ' Repaint image...
Loop ' Search for next socket in playback queue
ConnectionList.TopIndex = 0 ' Reset top image...
If (ConnectionList.ListCount > 0) Then
ConnectionList.Selected(0) = True ' Deselect previously listitem
ConnectionList.Selected(0) = False ' Deselect currently selected listitem
End If
Screen.MousePointer = vbDefault ' Set Pointer To Normal
cmdTalk.Caption = "&Talk" ' Modify Button Status Caption
wStream.Playing = False ' Turn Playing Status Off
End If
'--------------------------------------------------------------
End Sub
'--------------------------------------------------------------
'--------------------------------------------------------------
Private Sub cmdTalk_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
' Activates Audio Recording...
'--------------------------------------------------------------
Dim rc As Long ' Return Code Variable
'--------------------------------------------------------------
If (Not wStream.Playing And _
Not wStream.Recording And _
wStream.RecDeviceFree And _
wStream.PlayDeviceFree) Then ' Check Audio Device Status
wStream.Recording = True ' Set Recording Flag
cmdTalk.Caption = "&Talking" ' Update Button Status To "Talking"
Screen.MousePointer = vbHourglass ' Set Hourglass
outLight.Picture = ImgIcons.ListImages(mikeON).Picture ' Show outgoing message image
outLight.Refresh ' Repaint image
rc = wStream.RecordWave(Me.hWnd, TCPSocket) ' Record voice and send to all connected sockets
outLight.Picture = ImgIcons.ListImages(mikeOFF).Picture ' Show done image
outLight.Refresh ' Repaint image
Screen.MousePointer = vbDefault ' Reset Mouse Pointer
cmdTalk.Caption = "&Talk" ' Reset Button Status
If Not wStream.Playing And _
wStream.PlayDeviceFree And _
wStream.RecDeviceFree Then ' Is Audio Device Free?
Call cmdTalk_Click ' Active Playback Of Any Inbound Messages...
End If
End If
'--------------------------------------------------------------
End Sub
'--------------------------------------------------------------
Private Sub cmdTalk_MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single)
wStream.Recording = False ' Stop Recording
End Sub
Private Sub connectionlist_Click()
Tools.Buttons(tbHANGUP).Enabled = True
End Sub
'--------------------------------------------------------------
Private Sub ConnectionList_DblClick()
'--------------------------------------------------------------
Dim MemberID As String ' (Server)(TCPidx)(RemoteIP)
Dim Idx As Long ' TCP idx
'--------------------------------------------------------------
If (ConnectionList.Text = "") Then Exit Sub
MemberID = ConnectionList.List(ConnectionList.ListIndex) ' Get The Conversation MemberID String From List Box
Call GetIdxFromMemberID(TCPSocket, MemberID, Idx) ' Get TCP idx From Member ID
Call RemoveConnectionFromList(TCPSocket(Idx), ConnectionList) ' Clear ListBox Entry(s)...
Call Disconnect(TCPSocket(Idx)) ' Disconnect Socket Connection
Unload TCPSocket(Idx) ' Destroy socket instance
cmdTalk.Enabled = (ConnectionList.ListCount > 0) ' Enable/Disable Talk Button...
Tools.Buttons(tbHANGUP).Enabled = (ConnectionList.Text <> "")
If Not cmdTalk.Enabled Then
inLight.Picture = ImgIcons.ListImages(speakNO).Picture
outLight.Picture = ImgIcons.ListImages(mikeNO).Picture
End If
'--------------------------------------------------------------
End Sub
'--------------------------------------------------------------
'--------------------------------------------------------------
Private Sub Form_Load()
'--------------------------------------------------------------
Dim rc As Long ' Return Code Variable
Dim Idx As Long ' Current TCP idx variable
Dim TCPidx As Long ' Newly created TCP idx value
'--------------------------------------------------------------
CLOSINGAPPLICATION = False ' Set status to not closing
Call InitServerList(txtServer) ' Get Common Servers List
txtServer.Text = txtServer.List(0) ' Display First Name In The List
imgStatus = ImgIcons.ListImages(phoneHungUp).Picture ' Change Icon To Phone HungUp
Set wStream = CreateObject("WaveStreaming.WaveStream")
Call wStream.InitACMCodec(WAVE_FORMAT_GSM610, TIMESLICE)
' Call wStream.InitACMCodec(WAVE_FORMAT_ADPCM, TIMESLICE)
' Call wStream.InitACMCodec(WAVE_FORMAT_MSN_AUDIO, TIMESLICE)
' Call wStream.InitACMCodec(WAVE_FORMAT_PCM, TIMESLICE)
cmdTalk.Enabled = False ' Disable Until Connect
Tools.Buttons(tbHANGUP).Enabled = (ConnectionList.Text <> "")
inLight.Picture = ImgIcons.ListImages(speakNO).Picture
outLight.Picture = ImgIcons.ListImages(mikeNO).Picture
Call Listen(TCPSocket(0)) ' Listen For TCP Connection
'--------------------------------------------------------------
End Sub
'--------------------------------------------------------------
'--------------------------------------------------------------
Private Sub Form_Unload(Cancel As Integer)
'--------------------------------------------------------------
Dim Idx As Long ' TCP socket index
Dim Socket As Winsock ' TCP socket control
'--------------------------------------------------------------
'Call wStream.PlayWave1(Me.hWnd, Iport1, 2) ' Play wave data in iPort...
CLOSINGAPPLICATION = True ' Set status flag to closing...
For Each Socket In TCPSocket ' For each socket instance
Call Disconnect(Socket) ' Close connection/listen
Next ' Next Cntl
Set wStream = Nothing
End ' End Program
'--------------------------------------------------------------
End Sub
'--------------------------------------------------------------
'--------------------------------------------------------------
Private Sub TCPSocket_Close(Index As Integer)
' Closing Current TCP Connection...
'--------------------------------------------------------------
Call RemoveConnectionFromList(TCPSocket(Index), ConnectionList) ' Remove Connection From List
Call Disconnect(TCPSocket(Index)) ' Close Port Connection...
cmdTalk.Enabled = (ConnectionList.ListCount > 0) ' Enable/Disable Talk Button...
If Not cmdTalk.Enabled Then
inLight.Picture = ImgIcons.ListImages(speakNO).Picture
outLight.Picture = ImgIcons.ListImages(mikeNO).Picture
End If
Tools.Buttons(tbHANGUP).Enabled = (ConnectionList.Text <> "")
If cmdTalk.Enabled Then
imgStatus = ImgIcons.ListImages(phoneHungUp).Picture ' Show Phone HungUp Icon...
End If
Unload TCPSocket(Index) ' Destroy socket instance
'--------------------------------------------------------------
End Sub
'--------------------------------------------------------------
'--------------------------------------------------------------
Private Sub TCPSocket_Connect(Index As Integer)
' TCP Connection Has Been Accepted And Is Open...
'--------------------------------------------------------------
Call AddConnectionToList(TCPSocket(Index), ConnectionList) ' Add New Connection To List
imgStatus = ImgIcons.ListImages(phoneRingIng).Picture ' Show Phone Ringing Icon
Call ResPlaySound(RingOutId)
imgStatus = ImgIcons.ListImages(phoneAnswered).Picture ' Show Phone Answered Icon
cmdTalk.Enabled = True ' Enabled For Connection...
Tools.Buttons(tbHANGUP).Enabled = (ConnectionList.Text <> "")
'--------------------------------------------------------------
End Sub
'--------------------------------------------------------------
'--------------------------------------------------------------
Private Sub TCPSocket_ConnectionRequest(Index As Integer, ByVal requestID As Long)
' Accepting Inbound TCP Connection Request...
'--------------------------------------------------------------
Dim rc As Long
Dim Idx As Long
Dim RemHost As String
'--------------------------------------------------------------
If (TCPSocket(Index).RemoteHost <> "") Then
RemHost = UCase(TCPSocket(Index).RemoteHost)
Else
RemHost = UCase(TCPSocket(Index).RemoteHostIP)
End If
If (Tools.Buttons(tbAUTOANSWER).Value = tbrUnpressed) Then
rc = MsgBox("Incomming call from [" & RemHost & "]..." & vbCrLf & _
"Do you wish to answer?", vbYesNo) ' Prompt user to answer...
Else
rc = vbYes
End If
If (rc = vbYes) Then
Idx = InstanceTCP(TCPSocket) ' Instance TCP Control...
If (Idx > 0) Then ' Validate that control instance was created...
TCPSocket(Idx).LocalPort = 0 ' Set local port to 0, in order to get next available port.
Call TCPSocket(Idx).Accept(requestID) ' Accept connection
Call AddConnectionToList(TCPSocket(Idx), ConnectionList) ' Add New Connection To List
imgStatus = ImgIcons.ListImages(phoneRingIng).Picture ' Show Phone Ringing Icon
Call ResPlaySound(RingInId)
imgStatus = ImgIcons.ListImages(phoneAnswered).Picture ' Show Phone Answered Icon
cmdTalk.Enabled = True ' Enabled For Connection...
Tools.Buttons(tbHANGUP).Enabled = (ConnectionList.Text <> "")
End If
End If
'--------------------------------------------------------------
End Sub
'--------------------------------------------------------------
'--------------------------------------------------------------
Private Sub TCPSocket_DataArrival(Index As Integer, ByVal BytesTotal As Long)
' Incomming Buffer On...
'--------------------------------------------------------------
Dim rc As Long ' Return Code Variable
Dim WaveData() As Byte ' Byte array of wave data
Dim WaveData1() As Byte
Static ExBytes(MAXTCP) As Long ' Extra bytes in frame buffer
Static ExData(MAXTCP) As Variant ' Extra bytes from frame buffer
Dim ExData1(MAXTCP) As String
Dim i As Long
Dim x As Long
'--------------------------------------------------------------
With wStream
If (TCPSocket(Index).BytesReceived > 0) Then ' Validate that bytes where actually received
Do While (TCPSocket(Index).BytesReceived > 0) ' While data available...
If (ExBytes(Index) = 0) Then ' Was there leftover data from last time
If (.waveChunkSize <= TCPSocket(Index).BytesReceived) Then ' Can we get and entire wave buffer of data
Call TCPSocket(Index).GetData(WaveData, vbByte + vbArray, .waveChunkSize) ' Get 1 wave buffer of data
i = UBound(WaveData)
x = InstrBt(WaveData, 255)
'If i > 324 Then
Label3.Caption = "One " + Str(x)
Label1.Caption = "One " + Str(WaveData(i))
Call .SaveStreamBuffer(Index, WaveData) ' Save wave data to buffer
Call .AddStreamToQueue(Index) ' Queue current stream for playback
Else
ExBytes(Index) = TCPSocket(Index).BytesReceived ' Save Extra bytes
Call TCPSocket(Index).GetData(ExData(Index), vbByte + vbArray, ExBytes(Index)) ' Get Extra data
End If
Else
Call TCPSocket(Index).GetData(WaveData, vbByte + vbArray, .waveChunkSize - ExBytes(Index)) ' Get leftover bits
ExData(Index) = MidB(ExData(Index), 1) & MidB(WaveData, 1) ' Sync wave bits...
WaveData1 = ExData(Index)
i = UBound(WaveData1)
x = InstrBt(WaveData1, 255)
Label3.Caption = "Two " + Str(x)
Label1.Caption = "Two " + Str(WaveData1(i))
Call .SaveStreamBuffer(Index, WaveData1) ' Save the current wave data to the wave buffer
Call .AddStreamToQueue(Index) ' Queue the current wave stream
ExBytes(Index) = 0 ' Clear Extra byte count
ExData(Index) = "" ' Clear Extra data buffer
End If
Loop ' Look for next Data Chunk
If (Not .Playing And .PlayDeviceFree And _
Not .Recording And .RecDeviceFree) Then ' Check Audio Device Status
Call cmdTalk_Click ' Start PlayBack...
End If
End If
End With
'--------------------------------------------------------------
End Sub
'--------------------------------------------------------------
Private Sub TCPSocket_Error(Index As Integer, ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
TCPSocket(Index).Close ' Close down socket
Debug.Print "TCPSocket_Error: Number:", Number
Debug.Print "TCPSocket_Error: Scode:", Hex(Scode)
Debug.Print "TCPSocket_Error: Source:", Source
Debug.Print "TCPSocket_Error: HelpFile:", HelpFile
Debug.Print "TCPSocket_Error: HelpContext:", HelpContext
Debug.Print "TCPSocket_Error: Description:", Description
Call DebugSocket(TCPSocket(Index))
End Sub
'--------------------------------------------------------------
Private Sub Tools_ButtonClick(ByVal Button As Button)
'--------------------------------------------------------------
Dim rc As Long ' Return Code Variable
Dim Idx As Long ' TCP Socket control index
Dim LocalPort As Long ' LocalPort Setting
Dim RemotePort As Long ' RemotePort Setting
'--------------------------------------------------------------
Select Case Button.Index
Case tbCALL
Idx = InstanceTCP(TCPSocket) ' Instance TCP Control...
If (Idx > 0) Then ' Did control instance get created???
Button.Enabled = False ' Disable Connect Button
ConnectionList.Enabled = False ' Disable connection list box
On Error Resume Next
If Not Connect(TCPSocket(Idx), txtServer.Text, VOICEPORT) Then ' Attempt to connect
Unload TCPSocket(Idx) ' Connect failed unload control instance
End If
ConnectionList.Enabled = True ' Renable connection list box
Button.Enabled = True ' Enable Connect Button
End If
Case tbHANGUP
ConnectionList_DblClick
Case tbAUTOANSWER
If (Button.Value = tbrPressed) Then
Button.Image = phoneHungUp
Else
Button.Image = phoneAnswered
End If
End Select
End Sub
'--------------------------------------------------------------
Private Sub txtServer_KeyPress(KeyAscii As Integer)
'--------------------------------------------------------------
Dim Conn As Long ' Index counter
'--------------------------------------------------------------
If (KeyAscii = vbKeyReturn) Then ' If Return Key Was Pressed...
For Conn = 0 To txtServer.ListCount ' Search Each Entry In ListBox
If (UCase(txtServer.Text) = UCase(txtServer.List(Conn))) Then Exit Sub
Next ' If Found Then Exit
txtServer.AddItem UCase(txtServer.Text) ' Add Server To List
End If
'--------------------------------------------------------------
End Sub
'--------------------------------------------------------------
Function InstrBt(dt, chrb) As Long
Dim i As Long
Dim x As Long
i = LenB(dt) - 1
For x = 0 To i
If dt(x) = chrb Then
InstrBt = x
Exit Function
End If
Next x
End Function