home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / comdem / linedlg.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-08  |  18.0 KB  |  495 lines

  1. VERSION 2.00
  2. Begin Form LineDlg 
  3.    BorderStyle     =   3  'Fixed Double
  4.    Caption         =   "Communication Demo - Line Settings"
  5.    ClientHeight    =   5160
  6.    ClientLeft      =   1200
  7.    ClientTop       =   2040
  8.    ClientWidth     =   4875
  9.    Height          =   5565
  10.    Icon            =   0
  11.    Left            =   1140
  12.    LinkMode        =   1  'Source
  13.    LinkTopic       =   "Form4"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   5160
  17.    ScaleWidth      =   4875
  18.    Top             =   1695
  19.    Width           =   4995
  20.    Begin CommandButton Cancel_Command 
  21.       Caption         =   "Cancel"
  22.       Height          =   345
  23.       Left            =   3390
  24.       TabIndex        =   26
  25.       Top             =   4680
  26.       Width           =   1335
  27.    End
  28.    Begin CommandButton OK_Command 
  29.       Caption         =   "OK"
  30.       Height          =   345
  31.       Left            =   1755
  32.       TabIndex        =   25
  33.       Top             =   4680
  34.       Width           =   1335
  35.    End
  36.    Begin CommandButton Reset_Command 
  37.       Caption         =   "Reset"
  38.       Height          =   345
  39.       Left            =   135
  40.       TabIndex        =   24
  41.       Top             =   4680
  42.       Width           =   1335
  43.    End
  44.    Begin Frame Poll_Buffer_Frame 
  45.       Height          =   975
  46.       Left            =   120
  47.       TabIndex        =   19
  48.       Top             =   3480
  49.       Width           =   4605
  50.       Begin TextBox Poll_Interval_Text 
  51.          Height          =   285
  52.          Left            =   3600
  53.          TabIndex        =   23
  54.          Text            =   "Text6"
  55.          Top             =   555
  56.          Width           =   855
  57.       End
  58.       Begin HScrollBar Poll_Interval_Scroll 
  59.          Height          =   285
  60.          LargeChange     =   50
  61.          Left            =   2610
  62.          Min             =   1
  63.          TabIndex        =   22
  64.          Top             =   555
  65.          Value           =   51
  66.          Width           =   900
  67.       End
  68.       Begin Label Poll_Interval_Label 
  69.          Caption         =   "Poll Interval"
  70.          Height          =   285
  71.          Left            =   120
  72.          TabIndex        =   21
  73.          Top             =   555
  74.          Width           =   1335
  75.       End
  76.       Begin Label Poll_Buffer_Label 
  77.          Alignment       =   2  'Center
  78.          BorderStyle     =   1  'Fixed Single
  79.          Caption         =   "Poll/Read Receive Buffer"
  80.          Height          =   285
  81.          Left            =   0
  82.          TabIndex        =   20
  83.          Top             =   90
  84.          Width           =   4605
  85.       End
  86.    End
  87.    Begin Frame Signal_Detect_Frame 
  88.       Height          =   1815
  89.       Left            =   120
  90.       TabIndex        =   8
  91.       Top             =   1575
  92.       Width           =   4605
  93.       Begin TextBox Signal_Detect_DS_Text 
  94.          Height          =   285
  95.          Left            =   3600
  96.          TabIndex        =   18
  97.          Text            =   "Text5"
  98.          Top             =   1440
  99.          Width           =   855
  100.       End
  101.       Begin HScrollBar Signal_Detect_DS_Scroll 
  102.          Height          =   285
  103.          LargeChange     =   512
  104.          Left            =   2625
  105.          TabIndex        =   17
  106.          Top             =   1440
  107.          Value           =   1
  108.          Width           =   870
  109.       End
  110.       Begin TextBox Signal_Detect_CS_Text 
  111.          Height          =   285
  112.          Left            =   3600
  113.          TabIndex        =   15
  114.          Text            =   "Text4"
  115.          Top             =   960
  116.          Width           =   855
  117.       End
  118.       Begin HScrollBar Signal_Detect_CS_Scroll 
  119.          Height          =   285
  120.          LargeChange     =   512
  121.          Left            =   2640
  122.          TabIndex        =   14
  123.          Top             =   960
  124.          Value           =   1
  125.          Width           =   855
  126.       End
  127.       Begin TextBox Signal_Detect_CD_Text 
  128.          Height          =   285
  129.          Left            =   3600
  130.          TabIndex        =   12
  131.          Text            =   "Text3"
  132.          Top             =   495
  133.          Width           =   855
  134.       End
  135.       Begin HScrollBar Signal_Detect_CD_Scroll 
  136.          Height          =   285
  137.          LargeChange     =   512
  138.          Left            =   2655
  139.          TabIndex        =   11
  140.          Top             =   480
  141.          Value           =   1
  142.          Width           =   825
  143.       End
  144.       Begin Label Signal_Detect_DS_Label 
  145.          Caption         =   "Data Set Ready"
  146.          Height          =   285
  147.          Left            =   120
  148.          TabIndex        =   16
  149.          Top             =   1440
  150.          Width           =   1455
  151.       End
  152.       Begin Label Signal_Detect_CS_Label 
  153.          Caption         =   "Clear to Send"
  154.          Height          =   285
  155.          Left            =   120
  156.          TabIndex        =   13
  157.          Top             =   960
  158.          Width           =   1455
  159.       End
  160.       Begin Label Signal_Detect_CD_Label 
  161.          Caption         =   "Carrier Detect"
  162.          Height          =   285
  163.          Left            =   120
  164.          TabIndex        =   10
  165.          Top             =   480
  166.          Width           =   1335
  167.       End
  168.       Begin Label Signal_Detect_Label 
  169.          Alignment       =   2  'Center
  170.          BorderStyle     =   1  'Fixed Single
  171.          Caption         =   "Signal Detection Time"
  172.          Height          =   285
  173.          Left            =   0
  174.          TabIndex        =   9
  175.          Top             =   90
  176.          Width           =   4605
  177.       End
  178.    End
  179.    Begin Frame Comm_Buffer_Size_Frame 
  180.       ForeColor       =   &H00000000&
  181.       Height          =   1335
  182.       Left            =   120
  183.       TabIndex        =   0
  184.       Top             =   135
  185.       Width           =   4605
  186.       Begin TextBox Comm_Transmit_Text 
  187.          Height          =   285
  188.          Left            =   3600
  189.          TabIndex        =   7
  190.          Text            =   "Text2"
  191.          Top             =   960
  192.          Width           =   855
  193.       End
  194.       Begin HScrollBar Comm_Transmit_Scroll 
  195.          Height          =   285
  196.          LargeChange     =   512
  197.          Left            =   2685
  198.          TabIndex        =   6
  199.          Top             =   960
  200.          Value           =   1
  201.          Width           =   795
  202.       End
  203.       Begin TextBox Comm_Receive_Text 
  204.          Height          =   285
  205.          Left            =   3600
  206.          TabIndex        =   4
  207.          Text            =   "Text1"
  208.          Top             =   465
  209.          Width           =   855
  210.       End
  211.       Begin HScrollBar Comm_Receive_Scroll 
  212.          Height          =   285
  213.          LargeChange     =   512
  214.          Left            =   2715
  215.          TabIndex        =   3
  216.          Top             =   480
  217.          Value           =   1
  218.          Width           =   780
  219.       End
  220.       Begin Label Comm_Transmit_Label 
  221.          Caption         =   "Transmit"
  222.          Height          =   285
  223.          Left            =   120
  224.          TabIndex        =   5
  225.          Top             =   975
  226.          Width           =   975
  227.       End
  228.       Begin Label Comm_Receive_Label 
  229.          Caption         =   "Receive"
  230.          Height          =   285
  231.          Left            =   120
  232.          TabIndex        =   2
  233.          Top             =   480
  234.          Width           =   975
  235.       End
  236.       Begin Label Comm_Buffer_Size_Label 
  237.          Alignment       =   2  'Center
  238.          BorderStyle     =   1  'Fixed Single
  239.          Caption         =   "Communication Buffer Size"
  240.          Height          =   285
  241.          Left            =   0
  242.          TabIndex        =   1
  243.          Top             =   90
  244.          Width           =   4605
  245.       End
  246.    End
  247. Dim WorkRB As Integer
  248. Dim WorkTB As Integer
  249. Dim WorkDCB As CommStateDCB
  250. Dim WorkInterval As Integer
  251. Dim WidthOfText As Integer
  252. Sub AdjustControl (A_Scroll As Control, A_Text As Control, A_Label As Control, A_Frame As Control)
  253.     A_Text.Width = WidthOfText
  254.     A_Text.Left = A_Frame.Width - (A_Label.Left + A_Text.Width)
  255.     A_Scroll.height = A_Text.height
  256.     A_Scroll.Width = A_Text.Width * 2
  257.     A_Scroll.Top = A_Text.Top
  258.     A_Scroll.Left = A_Text.Left - A_Scroll.Width - A_Text.Width \ 4
  259. End Sub
  260. Sub Cancel_Command_Click ()
  261.     Unload LineDlg
  262. End Sub
  263. Sub Comm_Receive_Scroll_Change ()
  264.     ProcessScrollChange Comm_Receive_Scroll, Comm_Receive_Text
  265. End Sub
  266. Sub Comm_Receive_Text_Change ()
  267.     ProcessTextChange Comm_Receive_Scroll, Comm_Receive_Text
  268.     WorkRB = Comm_Receive_Scroll.value
  269.     DisplayQBOpen WorkDCB, CommPortName$, WorkRB, WorkTB, WorkInterval
  270. End Sub
  271. Sub Comm_Receive_Text_KeyPress (KeyAscii As Integer)
  272.     ProcessTextKeyPress Comm_Receive_Scroll, Comm_Receive_Text, Comm_Transmit_Text, KeyAscii
  273. End Sub
  274. Sub Comm_Receive_Text_LostFocus ()
  275.     ProcessTextLostFocus Comm_Receive_Scroll, Comm_Receive_Text
  276. End Sub
  277. Sub Comm_Transmit_Scroll_Change ()
  278.     ProcessScrollChange Comm_Transmit_Scroll, Comm_Transmit_Text
  279. End Sub
  280. Sub Comm_Transmit_Text_Change ()
  281.     ProcessTextChange Comm_Transmit_Scroll, Comm_Transmit_Text
  282.     WorkTB = Comm_Transmit_Scroll.value
  283.     DisplayQBOpen WorkDCB, CommPortName$, WorkRB, WorkTB, WorkInterval
  284. End Sub
  285. Sub Comm_Transmit_Text_KeyPress (KeyAscii As Integer)
  286.     ProcessTextKeyPress Comm_Transmit_Scroll, Comm_Transmit_Text, Signal_Detect_CD_Text, KeyAscii
  287. End Sub
  288. Sub Comm_Transmit_Text_LostFocus ()
  289.     ProcessTextLostFocus Comm_Transmit_Scroll, Comm_Transmit_Text
  290. End Sub
  291. Sub Form_Load ()
  292.     Remove_Items_From_SysMenu LineDlg
  293.     Initialize
  294.     CenterDialog LineDlg
  295. End Sub
  296. Sub Initialize ()
  297.     WidthOfText = TextWidth("999991")
  298.     SizeControls
  299.     Comm_Receive_Scroll.value = CommRBBuffer
  300.     WorkRB = CommRBBuffer
  301.     Comm_Transmit_Scroll.value = CommTBBuffer
  302.     WorkTB = CommTBBuffer
  303.     If CommDeviceNum > 0 And CommHandle > -1 Then
  304.         Comm_Buffer_Size_Frame.enabled = False
  305.         Comm_Buffer_Size_Label.enabled = False
  306.         
  307.         Comm_Receive_Text.enabled = False
  308.         Comm_Receive_Label.enabled = False
  309.         
  310.         Comm_Transmit_Text.enabled = False
  311.         Comm_Transmit_Label.enabled = False
  312.     End If
  313.     Signal_Detect_CD_Scroll.value = CommState.RlsTimeOut
  314.     Signal_Detect_CS_Scroll.value = CommState.CtsTimeOut
  315.     Signal_Detect_DS_Scroll.value = CommState.DsrTimeOut
  316.     WorkDCB = CommState
  317.     Poll_Interval_Scroll.value = CommReadInterval
  318.     WorkInterval = CommReadInterval
  319. End Sub
  320. Sub OK_Command_Click ()
  321.     If CommDeviceNum > 0 And CommHandle > -1 Then
  322.         NoChange = True
  323.         If WorkRB <> CommRBBuffer Then NoChange = False
  324.         If WorkTB <> CommTBBuffer Then NoChange = False
  325.         If WorkInterval <> CommReadInterval Then NoChange = False
  326.         If WorkDCB.RlsTimeOut <> CommState.RlsTimeOut Then NoChange = False
  327.         If WorkDCB.CtsTimeOut <> CommState.CtsTimeOut Then NoChange = False
  328.         If WorkDCB.DsrTimeOut <> CommState.DsrTimeOut Then NoChange = False
  329.         If NoChange = True Then
  330.             Unload LineDlg
  331.             Exit Sub
  332.         End If
  333.         
  334.         UpdateCaption " DIALOG: Change Active Settings (Yes), Post-Pone (No), Return to Dialog (Cancel)", 0
  335.         
  336.         Result% = MsgBox("Port Already Active!" + Chr$(13) + "Activate settings Now?", 3 + 16 + 256, "Terminal Sampler II - Port Active")
  337.         Select Case Result%
  338.             Case 6
  339.                 UpdateCaption " Changing Port Settings LIVE!", 0
  340.                 
  341.                 CommRBBuffer = WorkRB
  342.                 CommTBBuffer = WorkTB
  343.                 CommState = WorkDCB
  344.                 CommReadInterval = WorkInterval
  345.                 PostRBBuffer = WorkRB
  346.                 PostTBBuffer = WorkTB
  347.                 PostState = WorkDCB
  348.                 PostReadInterval = WorkInterval
  349.                 
  350.                 Receive.Receive_Timer.interval = CommReadInterval
  351.                 ApiErr% = SetCommState(WorkDCB)
  352.                 
  353.                 Unload LineDlg
  354.             Case 7
  355.                 UpdateCaption " Settings Post-Poned until next CONNECT", 0
  356.                 
  357.                 PostRBBuffer = WorkRB
  358.                 PostTBBuffer = WorkTB
  359.                 PostState = WorkDCB
  360.                 PostReadInterval = WorkInterval
  361.                 Unload LineDlg
  362.             Case Else
  363.                 DisplayQBOpen WorkDCB, CommPortName$, WorkRB, WorkTB, WorkInterval
  364.         End Select
  365.     Else
  366.         CommRBBuffer = WorkRB
  367.         CommTBBuffer = WorkTB
  368.         CommState = WorkDCB
  369.         CommReadInterval = WorkInterval
  370.         PostRBBuffer = WorkRB
  371.         PostTBBuffer = WorkTB
  372.         PostState = WorkDCB
  373.         PostReadInterval = WorkInterval
  374.         Unload LineDlg
  375.     End If
  376. End Sub
  377. Sub Poll_Interval_Scroll_Change ()
  378.     ProcessScrollChange Poll_Interval_Scroll, Poll_Interval_Text
  379. End Sub
  380. Sub Poll_Interval_Text_Change ()
  381.     ProcessTextChange Poll_Interval_Scroll, Poll_Interval_Text
  382.     WorkInterval = Poll_Interval_Scroll.value
  383.     DisplayQBOpen WorkDCB, CommPortName$, WorkRB, WorkTB, WorkInterval
  384. End Sub
  385. Sub Poll_Interval_Text_KeyPress (KeyAscii As Integer)
  386.     ProcessTextKeyPress Poll_Interval_Scroll, Poll_Interval_Text, Comm_Receive_Text, KeyAscii
  387. End Sub
  388. Sub Poll_Interval_Text_LostFocus ()
  389.     ProcessTextLostFocus Poll_Interval_Scroll, Poll_Interval_Text
  390. End Sub
  391. Sub ProcessScrollChange (A_Scroll As Control, A_Text As Control)
  392.     Work$ = LTrim$(Str$(A_Scroll.value))
  393.     If Work$ <> LTrim$(A_Text.Text) Then
  394.         A_Text.Text = Work$
  395.     End If
  396. End Sub
  397. Sub ProcessTextChange (A_Scroll As Control, A_Text As Control)
  398.     WorkVal& = Val(A_Text.Text)
  399.     If WorkVal& > A_Scroll.Max Then
  400.         A_Text.Text = LTrim$(Str$(A_Scroll.Max))
  401.         WorkVal& = A_Scroll.Max
  402.     ElseIf WorkVal& < A_Scroll.Min Then
  403.         Exit Sub
  404.     End If
  405.         
  406.     A% = Len(A_Text.Text)
  407.     A_Scroll.value = WorkVal&
  408.     If A% = 0 Then
  409.         A_Text.SelStart = Len(A_Text.Text)
  410.     End If
  411. End Sub
  412. Sub ProcessTextKeyPress (A_Scroll As Control, A_Text As Control, Next_Text As Control, KeyAscii As Integer)
  413.     Select Case KeyAscii
  414.         Case 8
  415.         Case 13
  416.             KeyAscii = 0
  417.             Next_Text.SetFocus
  418.         Case Asc("0") To Asc("9")
  419.             If A_Text.Sellength = 0 Then
  420.                 If KeyAscii = Asc("0") Then
  421.                     If A_Text.SelStart = 0 Then
  422.                         KeyAscii = 0
  423.                     ElseIf Val(A_Text.Text) = 0 Then
  424.                         KeyAscii = 0
  425.                     End If
  426.                 ElseIf Len(A_Text.Text) >= Len(Str$(A_Scroll.Max)) - 1 Then
  427.                     KeyAscii = 0
  428.                 End If
  429.             End If
  430.         Case Else
  431.             KeyAscii = 0
  432.     End Select
  433. End Sub
  434. Sub ProcessTextLostFocus (A_Scroll As Control, A_Text As Control)
  435.     If Len(A_Text.Text) = 0 Then
  436.         A_Text.Text = LTrim$(Str$(A_Scroll.Min))
  437.         A_Text.SelStart = Len(A_Text.Text)
  438.     ElseIf Val(A_Text.Text) < A_Scroll.Min Then
  439.         A_Text.Text = LTrim$(Str$(A_Scroll.Min))
  440.     End If
  441. End Sub
  442. Sub Reset_Command_Click ()
  443.     Initialize
  444. End Sub
  445. Sub Signal_Detect_CD_Scroll_Change ()
  446.     ProcessScrollChange Signal_Detect_CD_Scroll, Signal_Detect_CD_Text
  447. End Sub
  448. Sub Signal_Detect_CD_Text_Change ()
  449.     ProcessTextChange Signal_Detect_CD_Scroll, Signal_Detect_CD_Text
  450.     WorkDCB.RlsTimeOut = Signal_Detect_CD_Scroll.value
  451.     DisplayQBOpen WorkDCB, CommPortName$, WorkRB, WorkTB, WorkInterval
  452. End Sub
  453. Sub Signal_Detect_CD_Text_KeyPress (KeyAscii As Integer)
  454.     ProcessTextKeyPress Signal_Detect_CD_Scroll, Signal_Detect_CD_Text, Signal_Detect_CS_Text, KeyAscii
  455. End Sub
  456. Sub Signal_Detect_CD_Text_LostFocus ()
  457.     ProcessTextLostFocus Signal_Detect_CD_Scroll, Signal_Detect_CD_Text
  458. End Sub
  459. Sub Signal_Detect_CS_Scroll_Change ()
  460.     ProcessScrollChange Signal_Detect_CS_Scroll, Signal_Detect_CS_Text
  461. End Sub
  462. Sub Signal_Detect_CS_Text_Change ()
  463.     ProcessTextChange Signal_Detect_CS_Scroll, Signal_Detect_CS_Text
  464.     WorkDCB.CtsTimeOut = Signal_Detect_CS_Scroll.value
  465.     DisplayQBOpen WorkDCB, CommPortName$, WorkRB, WorkTB, WorkInterval
  466. End Sub
  467. Sub Signal_Detect_CS_Text_KeyPress (KeyAscii As Integer)
  468.     ProcessTextKeyPress Signal_Detect_CS_Scroll, Signal_Detect_CS_Text, Signal_Detect_DS_Text, KeyAscii
  469. End Sub
  470. Sub Signal_Detect_CS_Text_LostFocus ()
  471.     ProcessTextLostFocus Signal_Detect_CS_Scroll, Signal_Detect_CS_Text
  472. End Sub
  473. Sub Signal_Detect_DS_Scroll_Change ()
  474.     ProcessScrollChange Signal_Detect_DS_Scroll, Signal_Detect_DS_Text
  475. End Sub
  476. Sub Signal_Detect_DS_Text_Change ()
  477.     ProcessTextChange Signal_Detect_DS_Scroll, Signal_Detect_DS_Text
  478.     WorkDCB.DsrTimeOut = Signal_Detect_DS_Scroll.value
  479.     DisplayQBOpen WorkDCB, CommPortName$, WorkRB, WorkTB, WorkInterval
  480. End Sub
  481. Sub Signal_Detect_DS_Text_KeyPress (KeyAscii As Integer)
  482.     ProcessTextKeyPress Signal_Detect_DS_Scroll, Signal_Detect_DS_Text, Poll_Interval_Text, KeyAscii
  483. End Sub
  484. Sub Signal_Detect_DS_Text_LostFocus ()
  485.     ProcessTextLostFocus Signal_Detect_DS_Scroll, Signal_Detect_DS_Text
  486. End Sub
  487. Sub SizeControls ()
  488.     AdjustControl Comm_Receive_Scroll, Comm_Receive_Text, Comm_Receive_Label, Comm_Buffer_Size_Frame
  489.     AdjustControl Comm_Transmit_Scroll, Comm_Transmit_Text, Comm_Transmit_Label, Comm_Buffer_Size_Frame
  490.     AdjustControl Signal_Detect_CD_Scroll, Signal_Detect_CD_Text, Signal_Detect_CD_Label, Signal_Detect_Frame
  491.     AdjustControl Signal_Detect_CS_Scroll, Signal_Detect_CS_Text, Signal_Detect_CS_Label, Signal_Detect_Frame
  492.     AdjustControl Signal_Detect_DS_Scroll, Signal_Detect_DS_Text, Signal_Detect_DS_Label, Signal_Detect_Frame
  493.     AdjustControl Poll_Interval_Scroll, Poll_Interval_Text, Poll_Interval_Label, Poll_Buffer_Frame
  494. End Sub
  495.