home *** CD-ROM | disk | FTP | other *** search
/ Frostbyte's 1980s DOS Shareware Collection / floppyshareware.zip / floppyshareware / GLEN / COMDEM.ZIP / LINEDLG.TXT < prev    next >
Text File  |  1991-07-11  |  10KB  |  401 lines

  1.  
  2. Dim WorkRB As Integer
  3. Dim WorkTB As Integer
  4. Dim WorkDCB As CommStateDCB
  5. Dim WorkInterval As Integer
  6.  
  7. Dim WidthOfText As Integer
  8.  
  9.  
  10. Sub Form_Load ()
  11.  
  12.     Remove_Items_From_SysMenu LineDlg
  13.  
  14.     Initialize
  15.  
  16.     CenterDialog LineDlg
  17.  
  18. End Sub
  19.  
  20.  
  21. Sub Initialize ()
  22.     
  23.     WidthOfText = TextWidth("999991")
  24.  
  25.     SizeControls
  26.  
  27.     Comm_Receive_Scroll.value = CommRBBuffer
  28.     WorkRB = CommRBBuffer
  29.  
  30.     Comm_Transmit_Scroll.value = CommTBBuffer
  31.     WorkTB = CommTBBuffer
  32.  
  33.     If CommDeviceNum > 0 And CommHandle > -1 Then
  34.         Comm_Buffer_Size_Frame.enabled = FALSE
  35.         Comm_Buffer_Size_Label.enabled = FALSE
  36.         
  37.         Comm_Receive_Text.enabled = FALSE
  38.         Comm_Receive_Label.enabled = FALSE
  39.         
  40.         Comm_Transmit_Text.enabled = FALSE
  41.         Comm_Transmit_Label.enabled = FALSE
  42.     End If
  43.  
  44.     
  45.     Signal_Detect_CD_Scroll.value = CommState.RlsTimeOut
  46.     Signal_Detect_CS_Scroll.value = CommState.CtsTimeOut
  47.     Signal_Detect_DS_Scroll.value = CommState.DsrTimeOut
  48.     WorkDCB = CommState
  49.  
  50.     Poll_Interval_Scroll.value = CommReadInterval
  51.     WorkInterval = CommReadInterval
  52.  
  53. End Sub
  54.  
  55. Sub Reset_Command_Click ()
  56.  
  57.     Initialize
  58.  
  59. End Sub
  60.  
  61. Sub Cancel_Command_Click ()
  62.  
  63.     Unload LineDlg
  64.  
  65. End Sub
  66.  
  67. Sub OK_Command_Click ()
  68.     
  69.     If CommDeviceNum > 0 And CommHandle > -1 Then
  70.  
  71.         NoChange = TRUE
  72.  
  73.         If WorkRB <> CommRBBuffer Then NoChange = FALSE
  74.         If WorkTB <> CommTBBuffer Then NoChange = FALSE
  75.         If WorkInterval <> CommReadInterval Then NoChange = FALSE
  76.         If WorkDCB.RlsTimeOut <> CommState.RlsTimeOut Then NoChange = FALSE
  77.         If WorkDCB.CtsTimeOut <> CommState.CtsTimeOut Then NoChange = FALSE
  78.         If WorkDCB.DsrTimeOut <> CommState.DsrTimeOut Then NoChange = FALSE
  79.  
  80.         If NoChange = TRUE Then
  81.             Unload LineDlg
  82.             Exit Sub
  83.         End If
  84.         
  85.         UpdateCaption " DIALOG: Change Active Settings (Yes), Post-Pone (No), Return to Dialog (Cancel)", 0
  86.         
  87.         Result% = MsgBox("Port Already Active!" + Chr$(13) + "Activate settings Now?", 3 + 16 + 256, "Terminal Sampler II - Port Active")
  88.     
  89.         Select Case Result%
  90.             Case 6
  91.                 UpdateCaption " Changing Port Settings LIVE!", 0
  92.                 
  93.                 CommRBBuffer = WorkRB
  94.                 CommTBBuffer = WorkTB
  95.                 CommState = WorkDCB
  96.                 CommReadInterval = WorkInterval
  97.  
  98.                 PostRBBuffer = WorkRB
  99.                 PostTBBuffer = WorkTB
  100.                 PostState = WorkDCB
  101.                 PostReadInterval = WorkInterval
  102.                 
  103.                 Receive.Receive_Timer.interval = CommReadInterval
  104.  
  105.                 ApiErr% = SetCommState(WorkDCB)
  106.                 
  107.                 Unload LineDlg
  108.             Case 7
  109.                 UpdateCaption " Settings Post-Poned until next CONNECT", 0
  110.                 
  111.                 PostRBBuffer = WorkRB
  112.                 PostTBBuffer = WorkTB
  113.                 PostState = WorkDCB
  114.                 PostReadInterval = WorkInterval
  115.  
  116.                 Unload LineDlg
  117.             Case Else
  118.                 DisplayQBOpen WorkDCB, CommPortName$, WorkRB, WorkTB, WorkInterval
  119.         End Select
  120.  
  121.     Else
  122.  
  123.         CommRBBuffer = WorkRB
  124.         CommTBBuffer = WorkTB
  125.         CommState = WorkDCB
  126.         CommReadInterval = WorkInterval
  127.  
  128.         PostRBBuffer = WorkRB
  129.         PostTBBuffer = WorkTB
  130.         PostState = WorkDCB
  131.         PostReadInterval = WorkInterval
  132.  
  133.         Unload LineDlg
  134.  
  135.     End If
  136.  
  137. End Sub
  138.  
  139. Sub Signal_Detect_CD_Scroll_Change ()
  140.  
  141.     ProcessScrollChange Signal_Detect_CD_Scroll, Signal_Detect_CD_Text
  142.  
  143. End Sub
  144.  
  145. Sub Signal_Detect_CS_Scroll_Change ()
  146.  
  147.     ProcessScrollChange Signal_Detect_CS_Scroll, Signal_Detect_CS_Text
  148.  
  149. End Sub
  150.  
  151. Sub Signal_Detect_DS_Scroll_Change ()
  152.  
  153.     ProcessScrollChange Signal_Detect_DS_Scroll, Signal_Detect_DS_Text
  154.  
  155. End Sub
  156.  
  157. Sub Comm_Receive_Scroll_Change ()
  158.  
  159.     ProcessScrollChange Comm_Receive_Scroll, Comm_Receive_Text
  160.  
  161. End Sub
  162.  
  163.  
  164. Sub Comm_Transmit_Scroll_Change ()
  165.  
  166.     ProcessScrollChange Comm_Transmit_Scroll, Comm_Transmit_Text
  167.  
  168. End Sub
  169.  
  170. Sub Poll_Interval_Scroll_Change ()
  171.  
  172.     ProcessScrollChange Poll_Interval_Scroll, Poll_Interval_Text
  173.  
  174. End Sub
  175.  
  176. Sub Poll_Interval_Text_KeyPress (KeyAscii As Integer)
  177.  
  178.     ProcessTextKeyPress Poll_Interval_Scroll, Poll_Interval_Text, Comm_Receive_Text, KeyAscii
  179.  
  180. End Sub
  181.  
  182.  
  183. Sub Comm_Receive_Text_KeyPress (KeyAscii As Integer)
  184.  
  185.     ProcessTextKeyPress Comm_Receive_Scroll, Comm_Receive_Text, Comm_Transmit_Text, KeyAscii
  186.  
  187. End Sub
  188.  
  189.  
  190. Sub Comm_Receive_Text_Change ()
  191.  
  192.     ProcessTextChange Comm_Receive_Scroll, Comm_Receive_Text
  193.  
  194.     WorkRB = Comm_Receive_Scroll.value
  195.     
  196.     DisplayQBOpen WorkDCB, CommPortName$, WorkRB, WorkTB, WorkInterval
  197.  
  198. End Sub
  199.  
  200.  
  201. Sub Comm_Receive_Text_LostFocus ()
  202.  
  203.     ProcessTextLostFocus Comm_Receive_Scroll, Comm_Receive_Text
  204.  
  205. End Sub
  206.  
  207.  
  208. Sub ProcessTextChange (A_Scroll As Control, A_Text As Control)
  209.  
  210.  
  211.     WorkVal& = Val(A_Text.Text)
  212.  
  213.     If WorkVal& > A_Scroll.Max Then
  214.         A_Text.Text = LTrim$(Str$(A_Scroll.Max))
  215.         WorkVal& = A_Scroll.Max
  216.     ElseIf WorkVal& < A_Scroll.Min Then
  217.         Exit Sub
  218.     End If
  219.         
  220.     A% = Len(A_Text.Text)
  221.  
  222.     A_Scroll.value = WorkVal&
  223.  
  224.     If A% = 0 Then
  225.         A_Text.SelStart = Len(A_Text.Text)
  226.     End If
  227.  
  228. End Sub
  229.  
  230. Sub Comm_Transmit_Text_Change ()
  231.  
  232.     ProcessTextChange Comm_Transmit_Scroll, Comm_Transmit_Text
  233.  
  234.     WorkTB = Comm_Transmit_Scroll.value
  235.  
  236.     DisplayQBOpen WorkDCB, CommPortName$, WorkRB, WorkTB, WorkInterval
  237.  
  238. End Sub
  239.  
  240. Sub Poll_Interval_Text_Change ()
  241.  
  242.     ProcessTextChange Poll_Interval_Scroll, Poll_Interval_Text
  243.  
  244.     WorkInterval = Poll_Interval_Scroll.value
  245.  
  246.     DisplayQBOpen WorkDCB, CommPortName$, WorkRB, WorkTB, WorkInterval
  247.  
  248. End Sub
  249.  
  250. Sub Signal_Detect_CD_Text_Change ()
  251.  
  252.     ProcessTextChange Signal_Detect_CD_Scroll, Signal_Detect_CD_Text
  253.  
  254.     WorkDCB.RlsTimeOut = Signal_Detect_CD_Scroll.value
  255.  
  256.     DisplayQBOpen WorkDCB, CommPortName$, WorkRB, WorkTB, WorkInterval
  257.  
  258. End Sub
  259.  
  260. Sub Signal_Detect_CS_Text_Change ()
  261.  
  262.     ProcessTextChange Signal_Detect_CS_Scroll, Signal_Detect_CS_Text
  263.  
  264.     WorkDCB.CtsTimeOut = Signal_Detect_CS_Scroll.value
  265.  
  266.     DisplayQBOpen WorkDCB, CommPortName$, WorkRB, WorkTB, WorkInterval
  267.  
  268. End Sub
  269.  
  270. Sub Signal_Detect_DS_Text_Change ()
  271.  
  272.     ProcessTextChange Signal_Detect_DS_Scroll, Signal_Detect_DS_Text
  273.  
  274.     WorkDCB.DsrTimeOut = Signal_Detect_DS_Scroll.value
  275.  
  276.     DisplayQBOpen WorkDCB, CommPortName$, WorkRB, WorkTB, WorkInterval
  277.  
  278. End Sub
  279.  
  280. Sub ProcessTextKeyPress (A_Scroll As Control, A_Text As Control, Next_Text As Control, KeyAscii As Integer)
  281.  
  282.     Select Case KeyAscii
  283.         Case 8
  284.         Case 13
  285.             KeyAscii = 0
  286.             Next_Text.SetFocus
  287.         Case Asc("0") To Asc("9")
  288.             If A_Text.Sellength = 0 Then
  289.                 If KeyAscii = Asc("0") Then
  290.                     If A_Text.SelStart = 0 Then
  291.                         KeyAscii = 0
  292.                     ElseIf Val(A_Text.Text) = 0 Then
  293.                         KeyAscii = 0
  294.                     End If
  295.                 ElseIf Len(A_Text.Text) >= Len(Str$(A_Scroll.Max)) - 1 Then
  296.                     KeyAscii = 0
  297.                 End If
  298.             End If
  299.         Case Else
  300.             KeyAscii = 0
  301.     End Select
  302.  
  303. End Sub
  304.  
  305. Sub ProcessScrollChange (A_Scroll As Control, A_Text As Control)
  306.  
  307.     Work$ = LTrim$(Str$(A_Scroll.value))
  308.  
  309.     If Work$ <> LTrim$(A_Text.Text) Then
  310.         A_Text.Text = Work$
  311.     End If
  312.  
  313. End Sub
  314.  
  315. Sub Comm_Transmit_Text_KeyPress (KeyAscii As Integer)
  316.  
  317.     ProcessTextKeyPress Comm_Transmit_Scroll, Comm_Transmit_Text, Signal_Detect_CD_Text, KeyAscii
  318.  
  319. End Sub
  320.  
  321. Sub Signal_Detect_CD_Text_KeyPress (KeyAscii As Integer)
  322.  
  323.     ProcessTextKeyPress Signal_Detect_CD_Scroll, Signal_Detect_CD_Text, Signal_Detect_CS_Text, KeyAscii
  324.  
  325. End Sub
  326.  
  327. Sub Signal_Detect_CS_Text_KeyPress (KeyAscii As Integer)
  328.  
  329.     ProcessTextKeyPress Signal_Detect_CS_Scroll, Signal_Detect_CS_Text, Signal_Detect_DS_Text, KeyAscii
  330.  
  331. End Sub
  332.  
  333. Sub Signal_Detect_DS_Text_KeyPress (KeyAscii As Integer)
  334.  
  335.     ProcessTextKeyPress Signal_Detect_DS_Scroll, Signal_Detect_DS_Text, Poll_Interval_Text, KeyAscii
  336.  
  337. End Sub
  338.  
  339. Sub ProcessTextLostFocus (A_Scroll As Control, A_Text As Control)
  340.     
  341.     If Len(A_Text.Text) = 0 Then
  342.         A_Text.Text = LTrim$(Str$(A_Scroll.Min))
  343.         A_Text.SelStart = Len(A_Text.Text)
  344.     ElseIf Val(A_Text.Text) < A_Scroll.Min Then
  345.         A_Text.Text = LTrim$(Str$(A_Scroll.Min))
  346.     End If
  347.     
  348. End Sub
  349.  
  350. Sub Comm_Transmit_Text_LostFocus ()
  351.  
  352.     ProcessTextLostFocus Comm_Transmit_Scroll, Comm_Transmit_Text
  353.  
  354. End Sub
  355.  
  356. Sub Poll_Interval_Text_LostFocus ()
  357.  
  358.     ProcessTextLostFocus Poll_Interval_Scroll, Poll_Interval_Text
  359.  
  360. End Sub
  361.  
  362. Sub Signal_Detect_CD_Text_LostFocus ()
  363.  
  364.     ProcessTextLostFocus Signal_Detect_CD_Scroll, Signal_Detect_CD_Text
  365.  
  366. End Sub
  367.  
  368. Sub Signal_Detect_CS_Text_LostFocus ()
  369.  
  370.     ProcessTextLostFocus Signal_Detect_CS_Scroll, Signal_Detect_CS_Text
  371.  
  372. End Sub
  373.  
  374. Sub Signal_Detect_DS_Text_LostFocus ()
  375.  
  376.     ProcessTextLostFocus Signal_Detect_DS_Scroll, Signal_Detect_DS_Text
  377.  
  378. End Sub
  379.  
  380. Sub SizeControls ()
  381.     AdjustControl Comm_Receive_Scroll, Comm_Receive_Text, Comm_Receive_Label, Comm_Buffer_Size_Frame
  382.     AdjustControl Comm_Transmit_Scroll, Comm_Transmit_Text, Comm_Transmit_Label, Comm_Buffer_Size_Frame
  383.     AdjustControl Signal_Detect_CD_Scroll, Signal_Detect_CD_Text, Signal_Detect_CD_Label, Signal_Detect_Frame
  384.     AdjustControl Signal_Detect_CS_Scroll, Signal_Detect_CS_Text, Signal_Detect_CS_Label, Signal_Detect_Frame
  385.     AdjustControl Signal_Detect_DS_Scroll, Signal_Detect_DS_Text, Signal_Detect_DS_Label, Signal_Detect_Frame
  386.     AdjustControl Poll_Interval_Scroll, Poll_Interval_Text, Poll_Interval_Label, Poll_Buffer_Frame
  387. End Sub
  388.  
  389.  
  390. Sub AdjustControl (A_Scroll As Control, A_Text As Control, A_Label As Control, A_Frame As Control)
  391.  
  392.     A_Text.Width = WidthOfText
  393.     A_Text.Left = A_Frame.Width - (A_Label.Left + A_Text.Width)
  394.     A_Scroll.height = A_Text.height
  395.     A_Scroll.Width = A_Text.Width * 2
  396.     A_Scroll.Top = A_Text.Top
  397.     A_Scroll.Left = A_Text.Left - A_Scroll.Width - A_Text.Width \ 4
  398.  
  399. End Sub
  400.  
  401.