home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form PortDlg
- BorderStyle = 3 'Fixed Double
- Caption = "Communication Demo - Port Settings"
- ClientHeight = 3420
- ClientLeft = 1200
- ClientTop = 2580
- ClientWidth = 5460
- Height = 3825
- Icon = 0
- Left = 1140
- LinkMode = 1 'Source
- LinkTopic = "Form3"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 3420
- ScaleWidth = 5460
- Top = 2235
- Width = 5580
- Begin CommandButton Cancel_Cmmd
- Caption = "Cancel"
- Height = 375
- Left = 4230
- TabIndex = 32
- Top = 2880
- Width = 1095
- End
- Begin CommandButton Ok_Cmmd
- Caption = "OK"
- Height = 375
- Left = 2220
- TabIndex = 31
- Top = 2895
- Width = 1095
- End
- Begin CommandButton Reset_Cmmd
- Caption = "Reset"
- Height = 375
- Left = 135
- TabIndex = 30
- Top = 2895
- Width = 1095
- End
- Begin Frame Stop_Bits_Fram
- Height = 1425
- Left = 120
- TabIndex = 18
- Top = 1320
- Width = 1095
- Begin OptionButton Stop_Bits_Opt
- Caption = "2"
- Height = 255
- Index = 2
- Left = 105
- TabIndex = 22
- TabStop = 0 'False
- Top = 1035
- Width = 735
- End
- Begin OptionButton Stop_Bits_Opt
- Caption = "1.5"
- Height = 255
- Index = 1
- Left = 105
- TabIndex = 21
- TabStop = 0 'False
- Top = 735
- Width = 735
- End
- Begin OptionButton Stop_Bits_Opt
- Caption = "1"
- Height = 255
- Index = 0
- Left = 105
- TabIndex = 20
- TabStop = 0 'False
- Top = 420
- Width = 735
- End
- Begin Label Stop_Bits_Labl
- Alignment = 2 'Center
- BorderStyle = 1 'Fixed Single
- Caption = "&Stop Bits"
- Height = 255
- Left = 0
- TabIndex = 19
- Top = 90
- Width = 1095
- End
- End
- Begin Frame Data_Bits_Fram
- Height = 2625
- Left = 4080
- TabIndex = 4
- Top = 120
- Width = 1215
- Begin OptionButton Data_Bits_Opt
- Caption = "8"
- Height = 255
- Index = 4
- Left = 120
- TabIndex = 10
- TabStop = 0 'False
- Top = 2070
- Width = 975
- End
- Begin OptionButton Data_Bits_Opt
- Caption = "7"
- Height = 255
- Index = 3
- Left = 120
- TabIndex = 9
- TabStop = 0 'False
- Top = 1710
- Width = 975
- End
- Begin OptionButton Data_Bits_Opt
- Caption = "6"
- Height = 255
- Index = 2
- Left = 120
- TabIndex = 8
- TabStop = 0 'False
- Top = 1350
- Width = 975
- End
- Begin OptionButton Data_Bits_Opt
- Caption = "5"
- Height = 255
- Index = 1
- Left = 120
- TabIndex = 7
- TabStop = 0 'False
- Top = 990
- Width = 975
- End
- Begin OptionButton Data_Bits_Opt
- Caption = "4"
- Height = 255
- Index = 0
- Left = 120
- TabIndex = 6
- TabStop = 0 'False
- Top = 630
- Width = 960
- End
- Begin Label Data_Bits_Labl
- Alignment = 2 'Center
- BorderStyle = 1 'Fixed Single
- Caption = "&Data Bits"
- Height = 255
- Left = 0
- TabIndex = 5
- Top = 90
- Width = 1215
- End
- End
- Begin Frame Parity_Fram
- Height = 2625
- Left = 2760
- TabIndex = 11
- Top = 120
- Width = 1215
- Begin OptionButton Parity_Opt
- Caption = "Space"
- Height = 255
- Index = 4
- Left = 120
- TabIndex = 17
- TabStop = 0 'False
- Top = 2055
- Width = 975
- End
- Begin OptionButton Parity_Opt
- Caption = "Mark"
- Height = 255
- Index = 3
- Left = 120
- TabIndex = 16
- TabStop = 0 'False
- Top = 1695
- Width = 975
- End
- Begin OptionButton Parity_Opt
- Caption = "Even"
- Height = 255
- Index = 2
- Left = 120
- TabIndex = 15
- TabStop = 0 'False
- Top = 1335
- Width = 855
- End
- Begin OptionButton Parity_Opt
- Caption = "Odd"
- Height = 255
- Index = 1
- Left = 120
- TabIndex = 14
- TabStop = 0 'False
- Top = 975
- Width = 855
- End
- Begin OptionButton Parity_Opt
- Caption = "None"
- Height = 255
- Index = 0
- Left = 120
- TabIndex = 13
- TabStop = 0 'False
- Top = 615
- Width = 855
- End
- Begin Label Parity_Labl
- Alignment = 2 'Center
- BorderStyle = 1 'Fixed Single
- Caption = "&Parity"
- Height = 255
- Left = 0
- TabIndex = 12
- Top = 90
- Width = 1215
- End
- End
- Begin Frame Baud_Rate_Fram
- Height = 2625
- Left = 1320
- TabIndex = 23
- Top = 120
- Width = 1335
- Begin OptionButton Baud_Rate_Opt
- Caption = "19200"
- Height = 285
- Index = 5
- Left = 120
- TabIndex = 33
- TabStop = 0 'False
- Top = 2250
- Width = 1005
- End
- Begin OptionButton Baud_Rate_Opt
- Caption = "9600"
- Height = 255
- Index = 4
- Left = 120
- TabIndex = 29
- TabStop = 0 'False
- Top = 1920
- Width = 1095
- End
- Begin OptionButton Baud_Rate_Opt
- Caption = "4800"
- Height = 255
- Index = 3
- Left = 120
- TabIndex = 28
- TabStop = 0 'False
- Top = 1575
- Width = 1095
- End
- Begin OptionButton Baud_Rate_Opt
- Caption = "2400"
- Height = 255
- Index = 2
- Left = 120
- TabIndex = 27
- TabStop = 0 'False
- Top = 1215
- Width = 1095
- End
- Begin OptionButton Baud_Rate_Opt
- Caption = "1200"
- Height = 255
- Index = 1
- Left = 120
- TabIndex = 26
- TabStop = 0 'False
- Top = 870
- Width = 1095
- End
- Begin OptionButton Baud_Rate_Opt
- Caption = "300"
- Height = 255
- Index = 0
- Left = 120
- TabIndex = 25
- TabStop = 0 'False
- Top = 510
- Width = 1095
- End
- Begin Label Baud_Rate_Labl
- Alignment = 2 'Center
- BorderStyle = 1 'Fixed Single
- Caption = "&Baud Rate"
- Height = 255
- Left = 0
- TabIndex = 24
- Top = 90
- Width = 1335
- End
- End
- Begin Frame Comm_Device_Fram
- Height = 1185
- Left = 120
- TabIndex = 0
- Top = 120
- Width = 1095
- Begin OptionButton Comm_Device_Opt
- Caption = "COM2"
- Height = 255
- Index = 1
- Left = 105
- TabIndex = 3
- TabStop = 0 'False
- Top = 765
- Width = 855
- End
- Begin OptionButton Comm_Device_Opt
- Caption = "COM1"
- Height = 255
- Index = 0
- Left = 105
- TabIndex = 2
- TabStop = 0 'False
- Top = 465
- Width = 855
- End
- Begin Label Comm_Device_Labl
- Alignment = 2 'Center
- BorderStyle = 1 'Fixed Single
- Caption = "&Comm Port"
- Height = 255
- Left = 0
- TabIndex = 1
- Top = 90
- Width = 1095
- End
- End
- Dim WorkPortName As String
- Dim WorkDCB As CommStateDCB
- Sub Baud_Rate_Opt_Click (Index As Integer)
- If WorkDCB.BaudRate <> Val(Baud_Rate_Opt(Index).caption) Then
- WorkDCB.BaudRate = Val(Baud_Rate_Opt(Index).caption)
- DisplayQBOpen WorkDCB, WorkPortName, CommRBBuffer, CommTBBuffer, CommReadInterval
- End If
- End Sub
- Sub Cancel_Cmmd_Click ()
- Unload PortDlg
- End Sub
- Sub Comm_Device_Opt_Click (Index As Integer)
- WorkDCB.Id = Chr$(Index)
- WorkPortName = Comm_Device_Opt(Index).caption + ":"
- UpdateDialogSettings (Index)
- DisplayQBOpen WorkDCB, WorkPortName, CommRBBuffer, CommTBBuffer, CommReadInterval
- End Sub
- Sub Data_Bits_Opt_Click (Index As Integer)
- If WorkDCB.ByteSize <> Chr$(Index + 4) Then
- WorkDCB.ByteSize = Chr$(Index + 4)
- DisplayQBOpen WorkDCB, WorkPortName, CommRBBuffer, CommTBBuffer, CommReadInterval
- End If
- End Sub
- Sub Form_Load ()
- Remove_Items_From_SysMenu PortDlg
- WorkDCB = CommState
- WorkPortName = CommPortName
- UpdatePortDlg
- CenterDialog PortDlg
- End Sub
- Sub Ok_Cmmd_Click ()
- If CommDeviceNum > 0 And CommHandle > -1 Then
- NoChange = True
- If CommState.BaudRate <> WorkDCB.BaudRate Then NoChange = False
- If CommState.Parity <> WorkDCB.Parity Then NoChange = False
- If CommState.StopBits <> WorkDCB.StopBits Then NoChange = False
- If CommState.ByteSize <> WorkDCB.ByteSize Then NoChange = False
- If NoChange = True Then
- Unload PortDlg
- Exit Sub
- End If
- UpdateCaption " DIALOG: Change Active Settings (Yes), Post-Pone (No), Return to Dialog (Cancel)", 0
-
- Result% = MsgBox("Port Already Active!" + Chr$(13) + "Activate settings Now?", 3 + 16 + 256, "Terminal Sampler II - Port Active")
- Select Case Result%
- Case 6
- UpdateCaption " Changing Port Settings LIVE!", 0
-
- CommState = WorkDCB
- PostState = WorkDCB
- CommPortName = WorkPortName
- PostPortName = WorkPortName
- ApiErr% = SetCommState(WorkDCB)
- Unload PortDlg
- Case 7
- UpdateCaption " Settings Post-Poned until next CONNECT", 0
- PostState = WorkDCB
- PostPortName = WorkPortName
- Unload PortDlg
- Case Else
- DisplayQBOpen WorkDCB, WorkPortName, CommRBBuffer, CommTBBuffer, CommReadInterval
- End Select
- Else
- CommState = WorkDCB
- PostState = WorkDCB
- CommPortName = WorkPortName
- PostPortName = WorkPortName
- Unload PortDlg
- End If
- End Sub
- Sub Parity_Opt_Click (Index As Integer)
- If WorkDCB.Parity <> Chr$(Index) Then
-
- WorkDCB.Parity = Chr$(Index)
- DisplayQBOpen WorkDCB, WorkPortName, CommRBBuffer, CommTBBuffer, CommReadInterval
- End If
- End Sub
- Sub Reset_Cmmd_Click ()
- WorkDCB = CommState
- UpdatePortDlg
- End Sub
- Sub Stop_Bits_Opt_Click (Index As Integer)
- If WorkDCB.StopBits <> Chr$(Index) Then
-
- WorkDCB.StopBits = Chr$(Index)
- DisplayQBOpen WorkDCB, WorkPortName, CommRBBuffer, CommTBBuffer, CommReadInterval
- End If
- End Sub
- Sub UpdateDialogSettings (Index As Integer)
- For i% = 0 To 5
- If WorkDCB.BaudRate = Val(Baud_Rate_Opt(i%).caption) Then
- Baud_Rate_Opt(i%).value = True
- End If
- Next i%
- Parity_Opt(Asc(WorkDCB.Parity)).value = True
- Data_Bits_Opt(Asc(WorkDCB.ByteSize) - 4).value = True
- Stop_bits_Opt(Asc(WorkDCB.StopBits)).value = True
- End Sub
- Sub UpdatePortDlg ()
- For i% = 1 To 0 Step -1
- ApiErr% = OpenComm(Comm_Device_Opt(i%).caption + ":", 2048, 2048)
- Select Case ApiErr%
- Case IE_HARDWARE, IE_OPEN
- Comm_Device_Opt(i%).enabled = False
- Case Else
- ApiErr% = CloseComm(ApiErr%)
- Comm_Device_Opt(i%).enabled = True
- Last% = i%
- End Select
- Comm_Device_Opt(i%).value = False
- Next i%
- If CommDeviceNum > 0 And CommHandle > -1 Then
- Last% = CommDeviceNum - 1
- Comm_Device_Opt(Last%).value = True
- Else
- Comm_Device_Opt(Last%).value = True
- End If
- WorkDCB.Id = Chr$(Last%)
- WorkPortName = Comm_Device_Opt(Last%).caption + ":"
- End Sub
-