home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
- Begin VB.Form frmMain
- BorderStyle = 1 'Fixed Single
- Caption = "IP Chat"
- ClientHeight = 3180
- ClientLeft = 45
- ClientTop = 330
- ClientWidth = 4380
- LinkTopic = "Form1"
- MaxButton = 0 'False
- ScaleHeight = 3180
- ScaleWidth = 4380
- StartUpPosition = 3 'Windows Default
- Begin VB.CommandButton cmdConnect
- Caption = "Connect"
- Height = 415
- Left = 3390
- TabIndex = 13
- Top = 2420
- Width = 975
- End
- Begin MSWinsockLib.Winsock sckConnect
- Left = 3480
- Top = 2760
- _ExtentX = 741
- _ExtentY = 741
- _Version = 393216
- End
- Begin VB.TextBox txtIP
- Height = 285
- Left = 1960
- TabIndex = 12
- Text = "localhost"
- Top = 2880
- Width = 1415
- End
- Begin VB.TextBox txtPort
- Height = 285
- Left = 440
- TabIndex = 10
- Text = "400"
- Top = 2880
- Width = 1215
- End
- Begin VB.OptionButton optHostGuest
- Caption = "Guest"
- Height = 195
- Index = 1
- Left = 2520
- TabIndex = 8
- Top = 2520
- Value = -1 'True
- Width = 735
- End
- Begin VB.OptionButton optHostGuest
- Caption = "Host"
- Height = 195
- Index = 0
- Left = 1800
- TabIndex = 7
- Top = 2520
- Width = 735
- End
- Begin VB.TextBox txtNick
- Height = 285
- Left = 440
- TabIndex = 6
- Text = "NickName"
- Top = 2460
- Width = 1215
- End
- Begin VB.CommandButton cmdSend
- Caption = "Send"
- Height = 300
- Left = 3600
- TabIndex = 4
- Top = 1990
- Width = 735
- End
- Begin VB.TextBox txtText
- BeginProperty Font
- Name = "Arial"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 300
- Left = 80
- TabIndex = 3
- Top = 1990
- Width = 3495
- End
- Begin VB.Frame frmeSep
- Height = 135
- Left = 0
- TabIndex = 2
- Top = 2280
- Width = 4385
- End
- Begin VB.TextBox txtChat
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 9.75
- Charset = 0
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 1660
- Left = 80
- Locked = -1 'True
- MultiLine = -1 'True
- ScrollBars = 2 'Vertical
- TabIndex = 1
- Top = 190
- Width = 4215
- End
- Begin VB.Frame frmeChatWindow
- Caption = "Chat Window"
- Height = 1935
- Left = 0
- TabIndex = 0
- Top = 0
- Width = 4365
- End
- Begin VB.Shape shpGreen
- BackColor = &H00008000&
- BackStyle = 1 'Opaque
- BorderColor = &H00008000&
- Height = 255
- Left = 3960
- Shape = 3 'Circle
- Top = 2880
- Width = 255
- End
- Begin VB.Shape shpRed
- BackColor = &H000000FF&
- BackStyle = 1 'Opaque
- BorderColor = &H000000FF&
- FillColor = &H00000080&
- Height = 255
- Left = 3480
- Shape = 3 'Circle
- Top = 2880
- Width = 255
- End
- Begin VB.Label lblIP
- BackStyle = 0 'Transparent
- Caption = "IP:"
- Height = 255
- Left = 1710
- TabIndex = 11
- Top = 2910
- Width = 255
- End
- Begin VB.Label lblPort
- BackStyle = 0 'Transparent
- Caption = "Port:"
- Height = 255
- Left = 0
- TabIndex = 9
- Top = 2905
- Width = 375
- End
- Begin VB.Line lneSep3
- BorderColor = &H80000003&
- Index = 1
- X1 = 3350
- X2 = 3350
- Y1 = 2400
- Y2 = 2810
- End
- Begin VB.Line lneSep3
- BorderColor = &H00FFFFFF&
- Index = 0
- X1 = 3360
- X2 = 3360
- Y1 = 2400
- Y2 = 2820
- End
- Begin VB.Line lneSep2
- BorderColor = &H80000003&
- Index = 1
- X1 = 1680
- X2 = 1680
- Y1 = 2790
- Y2 = 2390
- End
- Begin VB.Line lneSep
- BorderColor = &H80000003&
- Index = 1
- X1 = 0
- X2 = 3360
- Y1 = 2790
- Y2 = 2790
- End
- Begin VB.Line lneSep2
- BorderColor = &H00FFFFFF&
- Index = 0
- X1 = 1690
- X2 = 1690
- Y1 = 2805
- Y2 = 2400
- End
- Begin VB.Line lneSep
- BorderColor = &H00FFFFFF&
- Index = 0
- X1 = 0
- X2 = 3360
- Y1 = 2805
- Y2 = 2805
- End
- Begin VB.Label lblNick
- BackStyle = 0 'Transparent
- Caption = "Nick: "
- Height = 255
- Left = 0
- TabIndex = 5
- Top = 2490
- Width = 495
- End
- Attribute VB_Name = "frmMain"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- '**********************************************************
- '* IP Chat by Joseph Huntley *
- '* joseph_huntley@email.com *
- '* http://joseph.vr9.com *
- '* *
- '* Made: October 4, 1999 *
- '* Level: Intermediate *
- '**********************************************************
- '* Notes: None *
- '**********************************************************
- Private Const vbDarkRed = &H80&
- Private Const vbDarkGreen = &H8000&
- Private Sub cmdSend_Click()
- ''Send text to other person and print it into our textbox
- sckConnect.SendData txtNick.Text & ":" & vbTab & txtText.Text
- txtChat.Text = txtChat.Text & txtNick.Text & ":" & vbTab & txtText.Text & vbCrLf
- ''clear textbox
- txtText.Text = ""
- ''show bottom half of textbox
- txtChat.SelStart = Len(txtChat.ytext)
- txtChat.SelLength = 0
- End Sub
- Private Sub sckConnect_Close()
- cmdConnect_Click 'Reset everything
- End Sub
- Private Sub sckConnect_Connect()
- txtChat.Text = txtChat.Text & "*** Connected" & vbCrLf
- ''change circles from red to green
- shpRed.BackColor = vbDarkRed
- shpRed.BorderColor = vbDarkRed
- shpGreen.BackColor = vbGreen
- shpGreen.BorderColor = vbGreen
- End Sub
- Private Sub sckConnect_ConnectionRequest(ByVal requestID As Long)
- ''check if connected to something else. If so, close that connection
- If sckConnect.State <> sckClosed Then sckConnect.Close
- 'accept the connection
- sckConnect.Accept requestID
- ''change circles from red to green
- shpRed.BackColor = vbDarkRed
- shpRed.BorderColor = vbDarkRed
- shpGreen.BackColor = vbGreen
- shpGreen.BorderColor = vbGreen
- txtChat.Text = txtChat.Text & "*** Connected" & vbCrLf
- End Sub
- Private Sub sckConnect_DataArrival(ByVal bytesTotal As Long)
- Dim strData As String
- 'get text to add
- Call sckConnect.GetData(strData$, vbString)
- txtChat.Text = txtChat.Text & strData$ & vbCrLf
- txtChat.SelStart = Len(txtChat.Text)
- txtChat.SelLength = 0
- End Sub
- Private Sub cmdConnect_Click()
- Dim strIP As String
- If cmdConnect.Caption = "Connect" Or cmdConnect.Caption = "Listen" Then
- txtPort.Enabled = False
- txtNick.Enabled = False
- optHostGuest(0).Enabled = False
- optHostGuest(1).Enabled = False
- cmdConnect.Caption = "Disconnect"
- Else
- txtPort.Enabled = True
- txtNick.Enabled = True
- optHostGuest(0).Enabled = True
- optHostGuest(1).Enabled = True
-
- If optHostGuest(0).Value = True Then
- cmdConnect.Caption = "Listen"
- Else
- cmdConnect.Caption = "Connect"
- End If
-
- sckConnect.Close
- shpRed.BackColor = vbRed
- shpRed.BorderColor = vbRed
- shpGreen.BackColor = vbDarkGreen
- shpGreen.BorderColor = vbDarkGreen
- txtChat.Text = txtChat.Text & "*** Disconnected" & vbCrLf
- Exit Sub
- End If
- Select Case optHostGuest(0).Value
- Case True: 'Host
- ''listen for connections
- sckConnect.LocalPort = CLng(txtPort.Text)
- sckConnect.Listen
- txtChat.Text = "*** Waiting for connection..." & vbCrLf
- Case False: 'Guest
- ''try to connect
- strIP$ = txtIP.Text
- If LCase$(strIP$) = "localhost" Then strIP$ = sckConnect.LocalIP
- sckConnect.Connect txtIP.Text, txtPort.Text
- txtChat.Text = "*** Connecting..." & vbCrLf
- End Select
-
- End Sub
- Private Sub optHostGuest_Click(Index As Integer)
- Select Case Index
- Case 0: 'Host
- txtIP.Text = sckConnect.LocalIP
- txtIP.BackColor = &H8000000F 'Grey
- txtIP.Locked = True
- cmdConnect.Caption = "Listen"
- Case 1: 'Guest
- txtIP.Text = "localhost"
- txtIP.BackColor = vbWhite
- txtIP.Locked = False
- cmdConnect.Caption = "Connect"
-
- End Select
- End Sub
- Private Sub Text1_Change()
- End Sub
- Private Sub txtText_KeyPress(KeyAscii As Integer)
- If KeyAscii = 13 Then 'If user pressed 'Enter'
- cmdSend_Click 'click 'Send' button
- KeyAscii = 0 'Make sure it doesnt write enter to txtText
- End If
- End Sub
-