home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / vb_code1 / nivb_src / mess.frm < prev    next >
Text File  |  1993-06-03  |  6KB  |  196 lines

  1. VERSION 2.00
  2. Begin Form MessForm 
  3.    Caption         =   "Message Services Test"
  4.    Height          =   2580
  5.    Left            =   1650
  6.    LinkMode        =   1  'Source
  7.    LinkTopic       =   "Form1"
  8.    ScaleHeight     =   2175
  9.    ScaleWidth      =   5760
  10.    Top             =   1230
  11.    Width           =   5880
  12.    Begin ComboBox ServerNameBox 
  13.       Height          =   300
  14.       Left            =   1200
  15.       TabIndex        =   7
  16.       Top             =   240
  17.       Width           =   2535
  18.    End
  19.    Begin TextBox MessageBox 
  20.       Height          =   375
  21.       Left            =   1200
  22.       TabIndex        =   1
  23.       Top             =   1680
  24.       Width           =   4455
  25.    End
  26.    Begin ListBox UserNameBox 
  27.       Height          =   810
  28.       Left            =   1200
  29.       Sorted          =   -1  'True
  30.       TabIndex        =   6
  31.       Top             =   720
  32.       Width           =   2535
  33.    End
  34.    Begin CommandButton CancelButton 
  35.       Caption         =   "Cancel"
  36.       Height          =   375
  37.       Left            =   4320
  38.       TabIndex        =   3
  39.       Top             =   720
  40.       Width           =   855
  41.    End
  42.    Begin CommandButton SendButton 
  43.       Caption         =   "Send"
  44.       Default         =   -1  'True
  45.       Height          =   375
  46.       Left            =   4320
  47.       TabIndex        =   2
  48.       Top             =   240
  49.       Width           =   855
  50.    End
  51.    Begin Label Label2 
  52.       Alignment       =   1  'Right Justify
  53.       Caption         =   "Message:"
  54.       Height          =   255
  55.       Left            =   240
  56.       TabIndex        =   4
  57.       Top             =   1680
  58.       Width           =   855
  59.    End
  60.    Begin Label Label3 
  61.       Alignment       =   1  'Right Justify
  62.       Caption         =   "User:"
  63.       Height          =   255
  64.       Left            =   600
  65.       TabIndex        =   5
  66.       Top             =   720
  67.       Width           =   495
  68.    End
  69.    Begin Label Label1 
  70.       Alignment       =   1  'Right Justify
  71.       Caption         =   "File Server:"
  72.       Height          =   255
  73.       Left            =   0
  74.       TabIndex        =   0
  75.       Top             =   240
  76.       Width           =   1095
  77.    End
  78. End
  79. Dim conns(MAX_CONNS) As Long
  80. Dim results As String * MAX_CONNS
  81.  
  82. Sub CancelButton_Click ()
  83.     Unload MessForm
  84. End Sub
  85.  
  86. Sub Form_Load ()
  87.     Dim fileServerName As String * 48
  88.  
  89.     For connID% = 1 To 8
  90.         If (IsConnectionIDInUse(connID%) = 1) Then
  91.             GetFileServerName connID%, fileServerName
  92.             ServerNameBox.AddItem fileServerName
  93.         End If
  94.     Next connID%
  95.  
  96.     fileServerName = GetDefaultFileServerName()
  97.     ServerNameBox.Text = fileServerName
  98.  
  99.     Call UpdateUserNameList
  100.     SetMessageBoxText
  101. End Sub
  102.  
  103. Sub Form_Unload (Cancel As Integer)
  104.     SetPreferredConnectionID (originalPrefConnID%)
  105. End Sub
  106.  
  107. Sub SendButton_Click ()
  108.     Static results(MAX_CONNS) As Integer
  109.     
  110.     ccode% = GetConnectionID(ServerNameBox.Text, connID%)
  111.     If (ccode% <> SUCCESSFUL) Then
  112.         MsgBox "Unable to get connection ID of server " + prefServer$, MB_OK, "Error"
  113.     Else
  114.         SetPreferredConnectionID (connID%)
  115.  
  116.         userName$ = UserNameBox.Text
  117.         If (Len(userName$) > 0) Then
  118.             userName$ = Left$(userName$, InStr(userName$, " ") - 1)
  119.             msgText$ = MessageBox.Text
  120.             connNum& = Val(Mid$(UserNameBox.Text, InStr(UserNameBox.Text, "[") + 1))
  121.  
  122.             ccode% = SendBroadcastMessage(msgText$, connNum&, results(0), 1)
  123.             If (ccode% <> SUCCESSFUL) Then
  124.                 MsgBox "Unable to send message to user " + userName$, MB_OK, "Error"
  125.             Else
  126.                 Select Case (results(0) And &HFF)
  127.                     Case &H0
  128.                         MsgBox "Message sent to user " + userName$, MB_OK, "Message Sent"
  129.                     Case &HFC
  130.                         MsgBox userName$ + "'s message buffer is full", MB_OK, "Warning"
  131.                     Case &HFD
  132.                         MsgBox "Invalid connection number", MB_OK, "Error"
  133.                     Case &HFF
  134.                         MsgBox "User " + userName$ + " is blocking messages", MB_OK, "Warning"
  135.                     Case Else
  136.                         MsgBox "Unknown error while sending message", MB_OK, "Error"
  137.                 End Select
  138.             End If
  139.         End If
  140.     End If
  141. End Sub
  142.  
  143. Sub ServerNameBox_Change ()
  144.     UpdateUserNameList
  145.     SetMessageBoxText
  146. End Sub
  147.  
  148. Sub ServerNameBox_Click ()
  149.     UpdateUserNameList
  150.     SetMessageBoxText
  151. End Sub
  152.  
  153. Sub SetMessageBoxText ()
  154.     Dim logTime As DATE_AND_TIME
  155.     Dim oName As String * 48
  156.     
  157.     connNum& = GetConnectionNumber()
  158.     ccode% = GetConnectionInformation(connNum&, oName, oType%, oID&, logTime)
  159.     If (ccode% <> SUCCESSFUL) Then
  160.         MsgBox "Unable to get user name for your connection", MB_OK, "Error"
  161.     Else
  162.         msgText$ = Left$(oName, InStr(oName, Chr$(0)) - 1)
  163.         msgText$ = msgText$ + " [" + Format$(connNum&) + "]" + ":"
  164.         MessageBox.Text = msgText$
  165.     End If
  166. End Sub
  167.  
  168. Sub UpdateUserNameList ()
  169.     Dim oName As String * 48
  170.     Dim serverInfo As FILE_SERV_INFO
  171.     Dim logTime As DATE_AND_TIME
  172.     
  173.     ccode% = GetConnectionID(ServerNameBox.Text, connID%)
  174.     If (ccode% <> SUCCESSFUL) Then
  175.         MsgBox "Unable to get connection ID of user " + UserNameBox.Text, MB_OK, "Error"
  176.     Else
  177.         SetPreferredConnectionID (connID%)
  178.     
  179.         UserNameBox.Clear
  180.         ccode% = GetServerInformation(54, serverInfo)
  181.         If (ccode% <> SUCCESSFUL) Then
  182.             MsgBox "Unable to get number of users supported from default file server", MB_OK, "Error"
  183.         Else
  184.             For conn& = 1 To (serverInfo.maxConnectionsSupported And 255)
  185.                 ccode% = GetConnectionInformation(conn&, oName, oType%, oID&, logTime)
  186.                 If ((ccode% = SUCCESSFUL) And (oType% = OT_USER)) Then
  187.                     temp$ = Left$(oName, (InStr(oName, Chr$(0)) - 1))
  188.                     temp$ = temp$ + " [" + Format$(conn&) + "]"
  189.                     UserNameBox.AddItem temp$
  190.                 End If
  191.             Next conn&
  192.         End If
  193.     End If
  194. End Sub
  195.  
  196.