home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Unleashed / Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso / mabry / mslot12 / sample / chat.frm (.txt) next >
Encoding:
Visual Basic Form  |  1995-02-02  |  3.1 KB  |  106 lines

  1. VERSION 2.00
  2. Begin Form Chat 
  3.    Caption         =   "MSlot VBX Sample - Network Chat"
  4.    ClientHeight    =   6375
  5.    ClientLeft      =   1245
  6.    ClientTop       =   1845
  7.    ClientWidth     =   7815
  8.    Height          =   6780
  9.    Left            =   1185
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   6375
  12.    ScaleWidth      =   7815
  13.    Top             =   1500
  14.    Width           =   7935
  15.    Begin TextBox txtLocal 
  16.       Height          =   975
  17.       Left            =   120
  18.       TabIndex        =   0
  19.       Text            =   "User Types Text Here"
  20.       Top             =   5280
  21.       Width           =   7575
  22.    End
  23.    Begin TextBox txtChat 
  24.       Height          =   4575
  25.       Left            =   120
  26.       MultiLine       =   -1  'True
  27.       ScrollBars      =   2  'Vertical
  28.       TabIndex        =   1
  29.       TabStop         =   0   'False
  30.       Text            =   "Output Appears Here"
  31.       Top             =   600
  32.       Width           =   7575
  33.    End
  34.    Begin VBMailslots Mailslot1 
  35.       Height          =   420
  36.       Interval        =   250
  37.       Left            =   7320
  38.       MailslotName    =   ""
  39.       MailslotSize    =   4000
  40.       Message         =   ""
  41.       MessageSize     =   400
  42.       Priority        =   0
  43.       Timeout         =   0
  44.       Top             =   120
  45.       Width           =   420
  46.    End
  47. Option Explicit
  48. Sub Form_Load ()
  49.     ' clear edit boxes
  50.     txtLocal = ""
  51.     txtChat = ""
  52.     ' create the mailslot
  53.     Mailslot1.MailslotName = "\MAILSLOT\NetChat"
  54.     Mailslot1.Action = MSLOT_OPEN
  55.     ' tell everyone that we're here
  56.     SendMessage "Has joined the group ..."
  57. End Sub
  58. Sub Form_Resize ()
  59.     ' resize/position output edit box
  60.     txtChat.Left = 120
  61.     txtChat.Top = 120
  62.     txtChat.Height = Chat.ScaleHeight - 360 - 975
  63.     txtChat.Width = Chat.ScaleWidth - 240
  64.     ' resize/position input edit box
  65.     txtLocal.Top = Chat.ScaleHeight - 120 - 975
  66.     txtLocal.Left = 120
  67.     txtLocal.Height = 975
  68.     txtLocal.Width = Chat.ScaleWidth - 240
  69. End Sub
  70. Sub Form_Unload (Cancel As Integer)
  71.     SendMessage "Is leaving ..."
  72. End Sub
  73. Sub Mailslot1_MessageWaiting (MessageCount As Integer)
  74.     ' read twice to deal with W4Wg bug
  75.     On Error Resume Next
  76.     Mailslot1.Action = MSLOT_READ
  77.     Mailslot1.Action = MSLOT_READ
  78.     On Error GoTo 0
  79.     ' add new message to edit box
  80.     If txtChat <> "" Then
  81.         txtChat = txtChat & Chr(13) & Chr(10)
  82.     End If
  83.     txtChat = txtChat & Mailslot1.Message
  84.     txtChat.SelStart = Len(txtChat)
  85. End Sub
  86. Sub SendMessage (Text)
  87.     Dim TempMessage As String
  88.     ' send message
  89.     Mailslot1.Message = Mailslot1.UserName & " (" & Mailslot1.ComputerName & "): " & Text
  90.     Mailslot1.MailslotName = "\\*\MAILSLOT\NetChat"
  91.     Mailslot1.Action = MSLOT_WRITE
  92. End Sub
  93. Sub txtLocal_KeyPress (KeyAscii As Integer)
  94.     ' if the user pressed Enter, send result to net
  95.     If KeyAscii = 13 Then
  96.         KeyAscii = 0
  97.         SendMessage txtLocal
  98.         ' clear edit box
  99.         txtLocal = ""
  100.     End If
  101. End Sub
  102. Sub txtLocal_LostFocus ()
  103.     ' make sure focus remains here
  104.     txtLocal.SetFocus
  105. End Sub
  106.