home *** CD-ROM | disk | FTP | other *** search
/ CICA 1995 May / cica_0595_4.zip / cica_0595_4 / UTIL / WSPRTERM / WSPRTERM.FRM < prev    next >
Text File  |  1994-07-10  |  86KB  |  2,882 lines

  1. VERSION 2.00
  2. Begin Form FMain 
  3.    BackColor       =   &H8000000C&
  4.    Caption         =   "Whisper Terminal for Windows (sample)"
  5.    ClientHeight    =   4080
  6.    ClientLeft      =   1560
  7.    ClientTop       =   1680
  8.    ClientWidth     =   7230
  9.    ClipControls    =   0   'False
  10.    FontBold        =   0   'False
  11.    FontItalic      =   0   'False
  12.    FontName        =   "Terminal"
  13.    FontSize        =   9
  14.    FontStrikethru  =   0   'False
  15.    FontTransparent =   0   'False
  16.    FontUnderline   =   0   'False
  17.    Height          =   4800
  18.    Icon            =   WSPRTERM.FRX:0000
  19.    KeyPreview      =   -1  'True
  20.    Left            =   1485
  21.    LinkTopic       =   "DPTWS4W"
  22.    ScaleHeight     =   4080
  23.    ScaleWidth      =   7230
  24.    Top             =   1035
  25.    Width           =   7380
  26.    Begin Timer TPaste 
  27.       Enabled         =   0   'False
  28.       Interval        =   100
  29.       Left            =   1215
  30.       Top             =   135
  31.    End
  32.    Begin PictureBox Portal 
  33.       ClipControls    =   0   'False
  34.       FontBold        =   0   'False
  35.       FontItalic      =   0   'False
  36.       FontName        =   "Terminal"
  37.       FontSize        =   9
  38.       FontStrikethru  =   0   'False
  39.       FontTransparent =   0   'False
  40.       FontUnderline   =   0   'False
  41.       Height          =   1905
  42.       Left            =   2385
  43.       ScaleHeight     =   1875
  44.       ScaleWidth      =   1875
  45.       TabIndex        =   14
  46.       TabStop         =   0   'False
  47.       Top             =   720
  48.       Width           =   1905
  49.       Begin PictureBox Scrn 
  50.          ClipControls    =   0   'False
  51.          FontBold        =   0   'False
  52.          FontItalic      =   0   'False
  53.          FontName        =   "Terminal"
  54.          FontSize        =   9
  55.          FontStrikethru  =   0   'False
  56.          FontTransparent =   0   'False
  57.          FontUnderline   =   0   'False
  58.          Height          =   1590
  59.          Left            =   135
  60.          ScaleHeight     =   1560
  61.          ScaleWidth      =   1560
  62.          TabIndex        =   15
  63.          TabStop         =   0   'False
  64.          Top             =   135
  65.          Width           =   1590
  66.       End
  67.    End
  68.    Begin VScrollBar VScrollBar 
  69.       Height          =   2040
  70.       LargeChange     =   5
  71.       Left            =   5985
  72.       Max             =   23
  73.       TabIndex        =   10
  74.       TabStop         =   0   'False
  75.       Top             =   1125
  76.       Value           =   23
  77.       Width           =   240
  78.    End
  79.    Begin HScrollBar HScrollBar 
  80.       Height          =   240
  81.       LargeChange     =   10
  82.       Left            =   3150
  83.       Max             =   10000
  84.       SmallChange     =   100
  85.       TabIndex        =   12
  86.       TabStop         =   0   'False
  87.       Top             =   3105
  88.       Width           =   2805
  89.    End
  90.    Begin CommonDialog CMDialog1 
  91.       Left            =   135
  92.       Top             =   1215
  93.    End
  94.    Begin Timer cursorBlinkTimer 
  95.       Enabled         =   0   'False
  96.       Interval        =   300
  97.       Left            =   675
  98.       Top             =   135
  99.    End
  100.    Begin Timer CurTimeTimer 
  101.       Interval        =   1000
  102.       Left            =   135
  103.       Top             =   135
  104.    End
  105.    Begin MSComm CommPort 
  106.       CommPort        =   2
  107.       DTREnable       =   0   'False
  108.       Handshaking     =   2  'RTS
  109.       Interval        =   100
  110.       Left            =   135
  111.       RThreshold      =   1
  112.       Settings        =   "2400,e,7,2"
  113.       SThreshold      =   1
  114.       Top             =   675
  115.    End
  116.    Begin SSPanel StatusBar 
  117.       Align           =   2  'Align Bottom
  118.       BevelOuter      =   1  'Inset
  119.       BevelWidth      =   2
  120.       BorderWidth     =   0
  121.       ForeColor       =   &H00FFFF80&
  122.       Height          =   660
  123.       Left            =   0
  124.       TabIndex        =   0
  125.       Top             =   3420
  126.       Width           =   7230
  127.       Begin SSPanel ModemPanel 
  128.          BevelWidth      =   2
  129.          ForeColor       =   &H00FFFF80&
  130.          Height          =   240
  131.          Left            =   45
  132.          TabIndex        =   1
  133.          Top             =   45
  134.          Width           =   3165
  135.          Begin Label LedDSR 
  136.             AutoSize        =   -1  'True
  137.             BackStyle       =   0  'Transparent
  138.             Caption         =   "DSR"
  139.             FontBold        =   0   'False
  140.             FontItalic      =   0   'False
  141.             FontName        =   "Terminal"
  142.             FontSize        =   9
  143.             FontStrikethru  =   0   'False
  144.             FontUnderline   =   0   'False
  145.             ForeColor       =   &H00808080&
  146.             Height          =   180
  147.             Left            =   1080
  148.             TabIndex        =   2
  149.             Top             =   45
  150.             Width           =   360
  151.          End
  152.          Begin Label LedCTS 
  153.             AutoSize        =   -1  'True
  154.             BackStyle       =   0  'Transparent
  155.             Caption         =   "CTS"
  156.             FontBold        =   0   'False
  157.             FontItalic      =   0   'False
  158.             FontName        =   "Terminal"
  159.             FontSize        =   9
  160.             FontStrikethru  =   0   'False
  161.             FontUnderline   =   0   'False
  162.             ForeColor       =   &H00808080&
  163.             Height          =   180
  164.             Left            =   1980
  165.             TabIndex        =   3
  166.             Top             =   45
  167.             Width           =   360
  168.          End
  169.          Begin Label LedTX 
  170.             Alignment       =   2  'Center
  171.             AutoSize        =   -1  'True
  172.             BackStyle       =   0  'Transparent
  173.             Caption         =   "TX"
  174.             FontBold        =   0   'False
  175.             FontItalic      =   0   'False
  176.             FontName        =   "Terminal"
  177.             FontSize        =   9
  178.             FontStrikethru  =   0   'False
  179.             FontUnderline   =   0   'False
  180.             ForeColor       =   &H00808080&
  181.             Height          =   180
  182.             Left            =   2790
  183.             TabIndex        =   8
  184.             Top             =   45
  185.             Width           =   255
  186.          End
  187.          Begin Label LedRX 
  188.             Alignment       =   2  'Center
  189.             AutoSize        =   -1  'True
  190.             BackStyle       =   0  'Transparent
  191.             Caption         =   "RX"
  192.             FontBold        =   0   'False
  193.             FontItalic      =   0   'False
  194.             FontName        =   "Terminal"
  195.             FontSize        =   9
  196.             FontStrikethru  =   0   'False
  197.             FontUnderline   =   0   'False
  198.             ForeColor       =   &H00808080&
  199.             Height          =   180
  200.             Left            =   2475
  201.             TabIndex        =   7
  202.             Top             =   45
  203.             Width           =   240
  204.          End
  205.          Begin Label LedDTR 
  206.             Alignment       =   2  'Center
  207.             AutoSize        =   -1  'True
  208.             BackStyle       =   0  'Transparent
  209.             Caption         =   "DTR"
  210.             FontBold        =   0   'False
  211.             FontItalic      =   0   'False
  212.             FontName        =   "Terminal"
  213.             FontSize        =   9
  214.             FontStrikethru  =   0   'False
  215.             FontUnderline   =   0   'False
  216.             ForeColor       =   &H00808080&
  217.             Height          =   180
  218.             Left            =   135
  219.             TabIndex        =   6
  220.             Top             =   45
  221.             Width           =   360
  222.          End
  223.          Begin Label LedRTS 
  224.             Alignment       =   2  'Center
  225.             AutoSize        =   -1  'True
  226.             BackStyle       =   0  'Transparent
  227.             Caption         =   "RTS"
  228.             FontBold        =   0   'False
  229.             FontItalic      =   0   'False
  230.             FontName        =   "Terminal"
  231.             FontSize        =   9
  232.             FontStrikethru  =   0   'False
  233.             FontUnderline   =   0   'False
  234.             ForeColor       =   &H00808080&
  235.             Height          =   180
  236.             Left            =   585
  237.             TabIndex        =   5
  238.             Top             =   45
  239.             Width           =   360
  240.          End
  241.          Begin Label LedCD 
  242.             Alignment       =   2  'Center
  243.             AutoSize        =   -1  'True
  244.             BackStyle       =   0  'Transparent
  245.             Caption         =   "DCD"
  246.             FontBold        =   0   'False
  247.             FontItalic      =   0   'False
  248.             FontName        =   "Terminal"
  249.             FontSize        =   9
  250.             FontStrikethru  =   0   'False
  251.             FontUnderline   =   0   'False
  252.             ForeColor       =   &H00808080&
  253.             Height          =   180
  254.             Left            =   1530
  255.             TabIndex        =   4
  256.             Top             =   45
  257.             Width           =   360
  258.          End
  259.       End
  260.       Begin SSPanel ElapsedTime 
  261.          BackColor       =   &H00808080&
  262.          BevelOuter      =   1  'Inset
  263.          BorderWidth     =   1
  264.          Caption         =   "elapsed time"
  265.          FontBold        =   -1  'True
  266.          FontItalic      =   0   'False
  267.          FontName        =   "Times New Roman"
  268.          FontSize        =   9.75
  269.          FontStrikethru  =   0   'False
  270.          FontUnderline   =   0   'False
  271.          ForeColor       =   &H00C0C0C0&
  272.          Height          =   195
  273.          Left            =   6075
  274.          TabIndex        =   13
  275.          Top             =   45
  276.          Width           =   1095
  277.       End
  278.       Begin SSPanel CurrentTime 
  279.          BackColor       =   &H00808080&
  280.          BevelOuter      =   1  'Inset
  281.          BorderWidth     =   1
  282.          Caption         =   "current time"
  283.          FontBold        =   -1  'True
  284.          FontItalic      =   0   'False
  285.          FontName        =   "Times New Roman"
  286.          FontSize        =   9.75
  287.          FontStrikethru  =   0   'False
  288.          FontUnderline   =   0   'False
  289.          ForeColor       =   &H00C0C0C0&
  290.          Height          =   195
  291.          Left            =   4905
  292.          TabIndex        =   11
  293.          Top             =   45
  294.          Width           =   1095
  295.       End
  296.       Begin SSPanel StatusPanel 
  297.          BackColor       =   &H00000000&
  298.          BevelOuter      =   1  'Inset
  299.          BevelWidth      =   2
  300.          BorderWidth     =   2
  301.          Caption         =   "Status Info"
  302.          FontBold        =   0   'False
  303.          FontItalic      =   0   'False
  304.          FontName        =   "MS Sans Serif"
  305.          FontSize        =   8.25
  306.          FontStrikethru  =   0   'False
  307.          FontUnderline   =   0   'False
  308.          ForeColor       =   &H00FFFFFF&
  309.          Height          =   285
  310.          Left            =   45
  311.          TabIndex        =   9
  312.          Top             =   315
  313.          Width           =   7125
  314.       End
  315.    End
  316.    Begin Menu MFile 
  317.       Caption         =   "&File"
  318.       Begin Menu MFileRefresh 
  319.          Caption         =   "&Refresh Screen"
  320.          Shortcut        =   ^R
  321.       End
  322.       Begin Menu MFilePrintScreen 
  323.          Caption         =   "&Print Screen"
  324.          Shortcut        =   ^P
  325.       End
  326.       Begin Menu MFileScrCaptureBegin 
  327.          Caption         =   "Screen &Capture Begin"
  328.       End
  329.       Begin Menu MFileScrCaptureEnd 
  330.          Caption         =   "Screen &Capture End"
  331.          Enabled         =   0   'False
  332.          Visible         =   0   'False
  333.       End
  334.       Begin Menu MFileScrCaptureSetup 
  335.          Caption         =   "Screen Capture Se&tup..."
  336.          Enabled         =   0   'False
  337.          Visible         =   0   'False
  338.       End
  339.       Begin Menu MSFileSave 
  340.          Caption         =   "-"
  341.       End
  342.       Begin Menu MFileLoad 
  343.          Caption         =   "&Load Setup..."
  344.       End
  345.       Begin Menu MFileSave 
  346.          Caption         =   "&Save Setup..."
  347.       End
  348.       Begin Menu MSFileExit 
  349.          Caption         =   "-"
  350.       End
  351.       Begin Menu MFileExit 
  352.          Caption         =   "E&xit WSPRTERM"
  353.       End
  354.    End
  355.    Begin Menu MEdit 
  356.       Caption         =   "&Edit"
  357.       Begin Menu MEditUnselect 
  358.          Caption         =   "&Unselect Text"
  359.          Enabled         =   0   'False
  360.       End
  361.       Begin Menu MSEditCopy 
  362.          Caption         =   "-"
  363.       End
  364.       Begin Menu MEditCopy 
  365.          Caption         =   "&Copy New"
  366.          Enabled         =   0   'False
  367.          Shortcut        =   ^C
  368.       End
  369.       Begin Menu MEditCopyAppend 
  370.          Caption         =   "Copy &Append"
  371.          Enabled         =   0   'False
  372.          Shortcut        =   ^A
  373.       End
  374.       Begin Menu MEditPaste 
  375.          Caption         =   "&Paste"
  376.          Enabled         =   0   'False
  377.          Shortcut        =   ^V
  378.       End
  379.       Begin Menu MSEditPasteInterval 
  380.          Caption         =   "-"
  381.          Visible         =   0   'False
  382.       End
  383.       Begin Menu MEditPasteRate 
  384.          Caption         =   "Paste &Rate"
  385.          Enabled         =   0   'False
  386.          Visible         =   0   'False
  387.       End
  388.       Begin Menu MSEditShowClipboard 
  389.          Caption         =   "-"
  390.       End
  391.       Begin Menu MEditShowClipboard 
  392.          Caption         =   "&Show Clipboard"
  393.       End
  394.    End
  395.    Begin Menu MSession 
  396.       Caption         =   "&Session"
  397.       Begin Menu MSessionConnect 
  398.          Caption         =   "&Connect"
  399.          Shortcut        =   +{INSERT}
  400.       End
  401.       Begin Menu MSessionDisconnect 
  402.          Caption         =   "&Disconnect"
  403.          Shortcut        =   +{DEL}
  404.       End
  405.       Begin Menu MSSessionSetup 
  406.          Caption         =   "-"
  407.       End
  408.       Begin Menu MSessionAsync 
  409.          Caption         =   "&Async Select/Setup..."
  410.          Checked         =   -1  'True
  411.       End
  412.       Begin Menu MSSessionAutoStart 
  413.          Caption         =   "-"
  414.       End
  415.       Begin Menu MSessionAutoConnect 
  416.          Caption         =   "Auto Connect At &Startup"
  417.       End
  418.    End
  419.    Begin Menu MPref 
  420.       Caption         =   "&Preferences"
  421.       Begin Menu MPrefFont 
  422.          Caption         =   "&Font"
  423.          Begin Menu MPrefFontScreen 
  424.             Caption         =   "&Screen"
  425.          End
  426.          Begin Menu MPrefFontPrinter 
  427.             Caption         =   "&Printer"
  428.          End
  429.       End
  430.       Begin Menu MPrefColor 
  431.          Caption         =   "&Color"
  432.          Begin Menu MPrefColorFg 
  433.             Caption         =   "&Foreground (text)..."
  434.          End
  435.          Begin Menu MPrefColorBg 
  436.             Caption         =   "&Background..."
  437.          End
  438.          Begin Menu MPrefColorHi 
  439.             Caption         =   "&Highlight (bold)..."
  440.          End
  441.          Begin Menu MPrefColorCursor 
  442.             Caption         =   "&Cursor..."
  443.          End
  444.          Begin Menu MSColorSelected 
  445.             Caption         =   "-"
  446.          End
  447.          Begin Menu MColorSelectedText 
  448.             Caption         =   "&Selected Text"
  449.             Begin Menu MColorSelTextFg 
  450.                Caption         =   "&Foreground (text)..."
  451.             End
  452.             Begin Menu MColorSelTextBg 
  453.                Caption         =   "&Background..."
  454.             End
  455.          End
  456.       End
  457.       Begin Menu MSPrefLineSpacing 
  458.          Caption         =   "-"
  459.       End
  460.       Begin Menu MPrefLineSpacing 
  461.          Caption         =   "&Line Spacing..."
  462.       End
  463.       Begin Menu MPrefCursorBlink 
  464.          Caption         =   "Cursor &Blink Rate..."
  465.       End
  466.       Begin Menu MSPrefRoll 
  467.          Caption         =   "-"
  468.       End
  469.       Begin Menu MPrefRollStyle 
  470.          Caption         =   "&Roll Up/Down style"
  471.          Begin Menu MPrefRollBuffered 
  472.             Caption         =   "&Buffered"
  473.          End
  474.          Begin Menu MPrefRollImmediate 
  475.             Caption         =   "&Immediate"
  476.          End
  477.          Begin Menu MPrefRollSmart 
  478.             Caption         =   "&Smart"
  479.             Checked         =   -1  'True
  480.          End
  481.       End
  482.    End
  483.    Begin Menu MMouse 
  484.       Caption         =   "&Mouse"
  485.       Begin Menu MMouseMenu 
  486.          Caption         =   "&Menu Style"
  487.          Checked         =   -1  'True
  488.       End
  489.       Begin Menu MMouseEditor 
  490.          Caption         =   "&Editor Style"
  491.       End
  492.       Begin Menu MMouseOff 
  493.          Caption         =   "&Off"
  494.       End
  495.    End
  496.    Begin Menu MHelp 
  497.       Caption         =   "&Help"
  498.       Begin Menu MHelpAbout 
  499.          Caption         =   "&About WSPRTERM..."
  500.       End
  501.    End
  502. End
  503.  
  504. Option Explicit
  505.  
  506. Declare Function MatchCount Lib "WSPRTERM.DLL" (ByVal attrStr$, ByVal colorStr$, ByVal attr$, ByVal Color$, ByVal maxLen%) As Integer
  507.  
  508. Declare Function IsCharUpper Lib "User" (ByVal cChar As Integer) As Integer
  509.  
  510. Declare Function GetBkColor Lib "GDI" (ByVal hDC As Integer) As Long
  511. Declare Function SetBkColor Lib "GDI" (ByVal hDC As Integer, ByVal crColor As Long) As Long
  512. Declare Function GetSysColor Lib "User" (ByVal nIndex As Integer) As Long
  513.  
  514. Declare Function SetBkMode Lib "GDI" (ByVal hDC As Integer, ByVal nBkMode As Integer) As Integer
  515.  
  516. Declare Function GetTextColor Lib "GDI" (ByVal hDC As Integer) As Long
  517. Declare Function SetTextColor Lib "GDI" (ByVal hDC As Integer, ByVal crColor As Long) As Long
  518.  
  519. Declare Function GetProfileString Lib "Kernel" (ByVal lpAppName$, ByVal lpKeyName As Any, ByVal lpDefault$, ByVal lpReturnedString$, ByVal nSize%) As Integer
  520. Declare Function WriteProfileString Lib "Kernel" (ByVal lpApplicationName$, ByVal lpKeyName$, ByVal lpString$) As Integer
  521.  
  522. Declare Function SndPlaySound Lib "MMSYSTEM.DLL" (ByVal lpszSoundName As Any, ByVal wFlags%) As Integer
  523. Const SND_SYNC = &H0
  524. Const SND_ASYNC = &H1
  525. Const SND_NODEFAULT = &H2
  526. Const SND_LOOP = &H8
  527. Const SND_NOSTOP = &H10
  528.  
  529. Declare Sub ScrollWindow Lib "User" (ByVal hWnd As Integer, ByVal XAmount As Integer, ByVal YAmount As Integer, lpRect As RECT, lpClipRect As RECT)
  530. Declare Function ScrollDC Lib "User" (ByVal hDC As Integer, ByVal dx As Integer, ByVal dy As Integer, lprcScroll As RECT, lprcClip As RECT, ByVal hRgnUpdate As Integer, lprcUpdate As RECT) As Integer
  531. Dim lprcScroll As RECT
  532. Dim liveClip As RECT
  533. Dim fullClip As RECT
  534. Dim hRgnUpdate As Integer
  535. Dim lprcUpdate As RECT
  536.  
  537.  
  538. Dim rollCnt As Integer
  539. Dim scrollLR As Integer
  540. Dim windowWidth As Integer
  541. Dim lastWindowState As Integer
  542.  
  543. Dim mouseDwnX As Integer
  544. Dim mouseDwnY As Integer
  545. Dim mouseUpX As Integer
  546. Dim mouseUpY As Integer
  547.  
  548. Dim dataEnd As Integer
  549. Dim dataIndex As Integer
  550.  
  551. Static Sub BldScrn (Dta$)
  552.  
  553. ' This routine parses the incoming data stream.
  554. ' Most codes received are for a Datapoint 735x terminal type.  I have
  555. ' left most of them in to demonstrate what functions are used for the
  556. ' type of operation required.
  557.  
  558.     On Error Resume Next
  559.     Dim opChar$, opVal%, saveCursState%, dummyInt%
  560.  
  561.     rollCnt = 0
  562.     partialScrnUpdate = (rollStyle <> IMMEDIATE)
  563.     
  564.     saveCursState = textCursorOn
  565.     If textCursorOn Then
  566.     cursorBlinkTimer.Enabled = False
  567.     textCursorOn = False
  568.     SetCursorOff
  569.     End If
  570.     shortStr = ""
  571.  
  572.     If textSelected Then MEditUnselect_Click
  573.  
  574.     dataIndex = 1
  575.     dataEnd = Len(Dta$)
  576.     Do
  577.     opChar = Mid(Dta$, dataIndex, 1)
  578.     opVal = Asc(opChar)
  579.  
  580.     Select Case cmdSeq
  581.         Case EscSeq
  582.         BldScrnEsc (opVal)
  583.  
  584.         Case ExtendedSeq        ' VT100 like cmds
  585.         BldScrnExtended (opVal)
  586.  
  587.         Case Else
  588.         If opVal < &H32 Then
  589.             Scrn.Print shortStr;
  590.             shortStr = ""
  591.         End If
  592.  
  593.         Select Case opVal
  594.             Case &H3    ' RollDown
  595.             RollDown margin.top, margin.bottom
  596.             If localCapture Then FlushCapturedLine
  597.  
  598.             Case &H7    ' Bell (beep)
  599.             If beepWav = "" Then
  600.                 Beep
  601.             Else
  602.                 dummyInt = SndPlaySound(beepWav, SND_ASYNC)
  603.             End If
  604.  
  605.             Case &H8    ' Backspace
  606.             If curX > margin.left Then
  607.                 curX = curX - 1
  608.                 MoveCursor curX, curY
  609.             End If
  610.  
  611.             Case &HA    ' Linefeed
  612.             If curY < margin.bottom Then
  613.                 curY = curY + 1
  614.             Else
  615.                 RollUp margin.top, margin.bottom
  616.             End If
  617.             MoveCursor curX, curY
  618.             If localCapture Then FlushCapturedLine
  619.  
  620.             Case &HB    ' RollUp
  621.             RollUp margin.top, margin.bottom
  622.             If localCapture Then FlushCapturedLine
  623.  
  624.             Case &HD    ' Carriage Return
  625.             curX = margin.left
  626.             MoveCursor curX, curY
  627.  
  628.             Case &H15   ' HomeUp
  629.             curX = margin.left
  630.             curY = margin.top
  631.             MoveCursor curX, curY
  632.             If localCapture Then FlushCapturedLine
  633.  
  634.             Case &H16   ' EraseToEOL
  635.             EraseToEOL
  636.  
  637.             Case &H17   ' EraseToEOF
  638.             EraseToEOF
  639.  
  640.             Case &H18   ' CursorOn
  641.             saveCursState = True
  642.  
  643.             Case &H19   ' CursorOff
  644.             saveCursState = False
  645.  
  646.             Case &H1B   ' Esc sequence
  647.             cmdSeq = EscSeq
  648.             seqPhase = 0
  649.  
  650.             Case Else   ' Must be something else.
  651.             If opVal <> &H1F Then
  652.                 DisplayChar opChar
  653.             End If
  654.         End Select
  655.     End Select
  656.     dataIndex = dataIndex + 1
  657.     Loop While dataIndex <= dataEnd
  658.  
  659.     If rollCnt < 0 Then         ' Roll Down
  660.     dummyInt = ScrollDC(Scrn.hDC, 0, -(pixelHeight * rollCnt), lprcScroll, liveClip, hRgnUpdate, lprcUpdate)
  661.     rollCnt = 0
  662.     ElseIf rollCnt > 0 Then     ' Roll Up
  663.     dummyInt = ScrollDC(Scrn.hDC, 0, -(pixelHeight * rollCnt), lprcScroll, fullClip, hRgnUpdate, lprcUpdate)
  664.     rollCnt = 0
  665.     End If
  666.     If partialScrnUpdate Then
  667.     ReDisplayScreen qX1, qY1, qX2, qY2
  668.     Else
  669.     Scrn.Print shortStr;
  670.     End If
  671.  
  672.     textCursorOn = saveCursState
  673.     If textCursorOn Then
  674.     SetCursorOn
  675.     cursorBlinkTimer.Enabled = True
  676.     End If
  677.  
  678. End Sub
  679.  
  680. Sub BldScrnEsc (ByVal byte As Integer)
  681.     Dim dummyColor&, rv%
  682.  
  683.     If seqPhase = 0 Then subCmdSeq = byte
  684.  
  685.     Select Case subCmdSeq
  686.     Case &H4    ' StandardVideoMode
  687.         curAttr = curAttr And ANormal
  688.         If localCapture Then SetCapturedLineAttr
  689.         SetAttributes curAttr, curColor
  690.         cmdSeq = 0
  691.  
  692.     Case &H5    ' InverseVideoMode
  693.         curAttr = curAttr Or AInverse
  694.         SetAttributes curAttr, curColor
  695.         cmdSeq = 0
  696.  
  697.     Case &H6    ' HighIntensityVideoMode
  698.         curAttr = curAttr Or ABold
  699.         If localCapture Then SetCapturedLineAttr
  700.         SetAttributes curAttr, curColor
  701.         cmdSeq = 0
  702.  
  703.     Case &H7    ' Click
  704.         If clickWav <> "" Then
  705.         rv = SndPlaySound(clickWav, SND_ASYNC)
  706.         End If
  707.         cmdSeq = 0
  708.  
  709.     Case &H8    ' OpenLine
  710.         OpenLine
  711.  
  712.     Case &H9    ' CloseLine
  713.         CloseLine
  714.  
  715.     Case &HC    ' ResetMargins
  716.         ResetMargins
  717.         cmdSeq = 0
  718.  
  719.     Case &HE    ' SetMargins
  720.         SetMargins (byte)
  721.  
  722.     Case &HF    ' SetTopBtmMargins
  723.         SetTBMargins (byte)
  724.  
  725.     Case &H11   ' InsertChar
  726.         InsertChar (byte)
  727.  
  728.     Case &H12   ' DeleteChar
  729.         DeleteChar (byte)
  730.  
  731.     Case &H13   ' DuplicateChar
  732.         DupChar (byte)
  733.  
  734.     Case &H14   ' InsertLine
  735.         RollDown curY, margin.bottom
  736.         cmdSeq = 0
  737.  
  738.     Case &H1A   ' DeleteLine
  739.         RollUp curY, margin.bottom
  740.         cmdSeq = 0
  741.  
  742.     Case &H1B   ' ForceNextChar
  743.         If seqPhase = 0 Then
  744.         seqPhase = seqPhase + 1
  745.         Else
  746.         DisplayChar Chr$(byte)
  747.         cmdSeq = 0
  748.         End If
  749.  
  750.     Case &H5B   ' ExtendedCmdSeq
  751.         cmdSeq = ExtendedSeq
  752.         paramCnt = 0
  753.  
  754.     Case &H63   ' Reset (RIS)
  755.         ResetMargins
  756.         curX = 0
  757.         curY = 0
  758.         curAttr = ANormal
  759.         EraseToEOF
  760.         cmdSeq = 0
  761.  
  762.     Case Else   ' Illegal sequence
  763.         Beep
  764.         cmdSeq = 0
  765.  
  766.     End Select
  767.  
  768. End Sub
  769.  
  770. Sub BldScrnExtended (ByVal byte As Integer)
  771.     Dim i%
  772.  
  773.     Select Case byte
  774.     Case &H41   ' CursorUp
  775.         cmdSeq = 0
  776.         If localCapture Then FlushCapturedLine
  777.     Case &H42   ' CursorDown
  778.         cmdSeq = 0
  779.         If localCapture Then FlushCapturedLine
  780.     Case &H43   ' CursorForward
  781.         cmdSeq = 0
  782.     Case &H44   ' CursorBackward
  783.         cmdSeq = 0
  784.     Case &H48   ' CursorPos
  785.         cmdSeq = 0
  786.     Case &H66   ' HorVerPos (HVP)
  787.         cmdSeq = 0
  788.     Case &H69   ' ReadLogicalScreen
  789.         cmdSeq = 0
  790.     Case &H6D   ' SelectAttrib
  791.         For i = 1 To paramCnt
  792.         Select Case param(i)
  793.             Case &H30
  794.             curAttr = curAttr And ANormal
  795.             If localCapture Then SetCapturedLineAttr
  796.             SetAttributes curAttr, curColor
  797.             Case &H31
  798.             If (i = paramCnt) Or (param(i + 1) = &H3B) Then
  799.                 curAttr = curAttr Or ABold
  800.                 If localCapture Then SetCapturedLineAttr
  801.                 SetAttributes curAttr, curColor
  802.             Else
  803.                 i = i + 1
  804.             End If
  805.             Case &H34
  806.             curAttr = curAttr Or AUnderline
  807.             If localCapture Then SetCapturedLineAttr
  808.             SetAttributes curAttr, curColor
  809.             Case &H35
  810.             curAttr = curAttr Or ABlink
  811.             SetAttributes curAttr, curColor
  812.             Case &H37
  813.             curAttr = curAttr Or AInverse
  814.             SetAttributes curAttr, curColor
  815.            Case &H3F
  816.             curAttr = curAttr Or ABlank
  817.             SetAttributes curAttr, curColor
  818.         End Select
  819.         Next i
  820.         cmdSeq = 0
  821.  
  822.     Case Else   ' Parameter
  823.         If paramCnt < MaxParam Then
  824.         paramCnt = paramCnt + 1
  825.         param(paramCnt) = byte
  826.         End If
  827.     End Select
  828. End Sub
  829.  
  830. Sub CalculateYPosValues ()
  831.     Dim i%
  832.  
  833.     yPos(MaxRow) = Scrn.Height - Scrn.TextHeight("M")
  834.     For i = MaxRow - 1 To MinRow Step -1
  835.     yPos(i) = yPos(i + 1) - Scrn.TextHeight("M") - lineSpacingExt
  836.     Next i
  837.  
  838. End Sub
  839.  
  840. Sub CloseLine ()
  841.     Dim i%
  842.  
  843.     cmdSeq = 0
  844.     If curY < margin.bottom Then
  845.     i = sdI(curY)
  846.     Mid(scrnData(i), curX + 1, margin.right - curX + 1) = Mid(scrnData(sdI(curY + 1)), curX + 1, margin.right - curX + 1)
  847.     Mid(scrnAttr(i), curX + 1, margin.right - curX + 1) = Mid(scrnAttr(sdI(curY + 1)), curX + 1, margin.right - curX + 1)
  848.     Mid(scrnColor(i), curX + 1, margin.right - curX + 1) = Mid(scrnColor(sdI(curY + 1)), curX + 1, margin.right - curX + 1)
  849.     RollUp curY + 1, margin.bottom
  850.     QScreenUpdate curX, curY, margin.right, curY
  851.     Else
  852.     EraseToEOL
  853.     End If
  854.  
  855. End Sub
  856.  
  857. Sub CommPort_OnComm ()
  858.     Dim EVMsg$, ERMsg$
  859.     
  860.     Select Case CommPort.CommEvent
  861.  
  862.     Case MSCOMM_EV_RECEIVE
  863.         LedRX.ForeColor = LedOnColor
  864.         BldScrn (CommPort.Input)
  865.         If CommPort.InBufferCount = 0 Then
  866.         LedRX.ForeColor = LedOffColor
  867.         End If
  868.  
  869.     Case MSCOMM_EV_SEND
  870.         LedTX.ForeColor = LedOffColor
  871.         If Len(queueTxData) > 0 Then
  872.         SendString ""
  873.         End If
  874.         
  875.     Case MSCOMM_EV_CTS
  876.         If CommPort.CTSHolding Then
  877.         LedCTS.ForeColor = LedOnColor
  878.         Else
  879.         LedCTS.ForeColor = LedOffColor
  880.         End If
  881.  
  882.     Case MSCOMM_EV_DSR
  883.         If CommPort.DSRHolding Then
  884.         LedDSR.ForeColor = LedOnColor
  885.         Else
  886.         LedDSR.ForeColor = LedOffColor
  887.         End If
  888.  
  889.     Case MSCOMM_EV_CD
  890.         If CommPort.CDHolding Then
  891.         LedCD.ForeColor = LedOnColor
  892.         If connecting Then
  893.             ShowStatus "OnLine - COM" & CommPort.CommPort & ":" & CommPort.Settings, False
  894.             connecting = False
  895.         End If
  896.         Else
  897.         LedCD.ForeColor = LedOffColor
  898.         If disconnecting Then
  899.             ShowStatus "Disconnected", False
  900.             disconnecting = False
  901.         End If
  902.         End If
  903.  
  904.     Case MSCOMM_EV_RING
  905.     Case MSCOMM_EV_EOF
  906.  
  907.     '--- Error messages
  908.     Case MSCOMM_ER_BREAK
  909.     Case MSCOMM_ER_CTSTO
  910.     Case MSCOMM_ER_DSRTO
  911.     Case MSCOMM_ER_FRAME
  912.         ERMsg$ = "Framing Error"
  913.     Case MSCOMM_ER_OVERRUN
  914.         ERMsg$ = "Overrun Error"
  915.     Case MSCOMM_ER_CDTO
  916.     Case MSCOMM_ER_RXOVER
  917.         ERMsg$ = "Receive Buffer Overflow"
  918.     Case MSCOMM_ER_RXPARITY
  919.         ERMsg$ = "Parity Error"
  920.     Case MSCOMM_ER_TXFULL
  921.         ERMsg$ = "Transmit Buffer Full"
  922.     Case Else
  923.         ERMsg$ = "Unknown error/event: " & CommPort.CommEvent
  924.     End Select
  925.     
  926.     If Len(EVMsg$) Then
  927.     ShowStatus EVMsg$, False
  928.     EVMsg$ = ""
  929.     ElseIf Len(ERMsg$) Then
  930.     Beep
  931.     ShowStatus ERMsg$, True
  932.     ERMsg$ = ""
  933.     End If
  934.  
  935. End Sub
  936.  
  937. Sub cursorBlinkTimer_Timer ()
  938.     Static blinkOn As Integer
  939.  
  940.     If blinkOn Then SetCursorOff Else SetCursorOn
  941.     blinkOn = Not blinkOn
  942.  
  943. End Sub
  944.  
  945. Sub CurTimeTimer_Timer ()
  946.  
  947.     CurrentTime.Caption = Format(Now, "h:mm AM/PM")
  948.     ElapsedTime.Caption = Format(startTime - TimeValue(Now), "hh:mm:ss")
  949.     
  950. End Sub
  951.  
  952. Sub DeleteChar (ByVal byte As Integer)
  953.     Static fieldH%, fieldV%
  954.     Dim i%, j%, wrapChar$, wrapAttr$, wrapColor$
  955.  
  956.     Select Case seqPhase
  957.     Case 1
  958.         fieldH = byte + margin.left
  959.     Case 2
  960.         cmdSeq = 0
  961.         fieldV = byte + margin.top
  962.         If (fieldH <= margin.right) And (fieldV <= margin.bottom) Then
  963.         i = sdI(curY)
  964.         If curY = fieldV Then
  965.             Mid(scrnData(i), curX + 1, fieldH - curX + 1) = Mid(scrnData(i), curX + 2, fieldH - curX) & " "
  966.             Mid(scrnAttr(i), curX + 1, fieldH - curX + 1) = Mid(scrnAttr(i), curX + 2, fieldH - curX) & Chr$(curAttr)
  967.             Mid(scrnColor(i), curX + 1, fieldH - curX + 1) = Mid(scrnColor(i), curX + 2, fieldH - curX) & Chr$(curColor)
  968.             QScreenUpdate curX, curY, fieldH, curY
  969.         Else
  970.             wrapChar = Mid(scrnData(sdI(i + 1)), margin.left + 1, 1)
  971.             wrapAttr = Mid(scrnAttr(sdI(i + 1)), margin.left + 1, 1)
  972.             wrapColor = Mid(scrnColor(sdI(i + 1)), margin.left + 1, 1)
  973.             Mid(scrnData(i), curX + 1, margin.right - curX + 1) = Mid(scrnData(i), curX + 2, margin.right - curX) & wrapChar
  974.             Mid(scrnAttr(i), curX + 1, margin.right - curX + 1) = Mid(scrnAttr(i), curX + 2, margin.right - curX) & wrapAttr
  975.             Mid(scrnColor(i), curX + 1, margin.right - curX + 1) = Mid(scrnColor(i), curX + 2, margin.right - curX) & wrapColor
  976.             For j = curY + 1 To fieldV
  977.             i = sdI(j)
  978.             If j = fieldV Then
  979.                 Mid(scrnData(i), margin.left + 1, fieldH - margin.left + 1) = Mid(scrnData(i), margin.left + 2, fieldH - margin.left) & " "
  980.                 Mid(scrnAttr(i), margin.left + 1, fieldH - margin.left + 1) = Mid(scrnAttr(i), margin.left + 2, fieldH - margin.left) & Chr$(curAttr)
  981.                 Mid(scrnColor(i), margin.left + 1, fieldH - margin.left + 1) = Mid(scrnColor(i), margin.left + 2, fieldH - margin.left) & Chr$(curColor)
  982.             Else
  983.                 wrapChar = Mid(scrnData(sdI(j + 1)), margin.left + 1, 1)
  984.                 wrapAttr = Mid(scrnAttr(sdI(j + 1)), margin.left + 1, 1)
  985.                 wrapColor = Mid(scrnColor(sdI(j + 1)), margin.left + 1, 1)
  986.                 Mid(scrnData(i), margin.left + 1, windowWidth) = Mid(scrnData(i), margin.left + 2, margin.right - margin.left) & wrapChar
  987.                 Mid(scrnAttr(i), margin.left + 1, windowWidth) = Mid(scrnAttr(i), margin.left + 2, margin.right - margin.left) & wrapAttr
  988.                 Mid(scrnColor(i), margin.left + 1, windowWidth) = Mid(scrnColor(i), margin.left + 2, margin.right - margin.left) & wrapColor
  989.             End If
  990.             Next j
  991.             QScreenUpdate margin.left, curY, margin.right, fieldV
  992.         End If
  993.         End If
  994.     End Select
  995.  
  996.     seqPhase = seqPhase + 1
  997.  
  998. End Sub
  999.  
  1000. Sub DisplayChar (ByVal char As String)
  1001.     Dim i%
  1002.  
  1003.     i = sdI(curY)
  1004.  
  1005.     Mid(scrnData(i), curX + 1, 1) = char
  1006.     Mid(scrnAttr(i), curX + 1, 1) = Chr$(curAttr)
  1007.     Mid(scrnColor(i), curX + 1, 1) = Chr$(curColor)
  1008.     If localCapture Then
  1009.     localCaptureLine = localCaptureLine & char
  1010.     End If
  1011.  
  1012.     If partialScrnUpdate Then
  1013.     QScreenUpdate curX, curY, curX, curY
  1014.     ElseIf curX < margin.right Then
  1015.     shortStr = shortStr & char
  1016.     Else
  1017.     Scrn.Print shortStr & char;
  1018.     shortStr = ""
  1019.     MoveCursor curX, curY
  1020.     End If
  1021.     If curX < margin.right Then
  1022.     curX = curX + 1
  1023.     End If
  1024.  
  1025. End Sub
  1026.  
  1027. Sub DupChar (ByVal byte As Integer)
  1028.     Static char%, i%
  1029.  
  1030.     Select Case seqPhase
  1031.     Case 1
  1032.         char = byte
  1033.     Case 2
  1034.         cmdSeq = 0
  1035.         If (char <= &HFE) And (byte <= &HFE) Then
  1036.         For i = 1 To byte
  1037.             DisplayChar Chr$(char)
  1038.         Next i
  1039.         End If
  1040.     End Select
  1041.  
  1042.     seqPhase = seqPhase + 1
  1043.  
  1044. End Sub
  1045.  
  1046. Sub ElapsedTime_Click ()
  1047.  
  1048.     startTime = TimeValue(Now)
  1049.     ElapsedTime.Caption = Format(startTime - TimeValue(Now), "hh:mm:ss")
  1050.  
  1051. End Sub
  1052.  
  1053. Sub EraseToEOF ()
  1054.     Dim i%
  1055.  
  1056.     EraseToEOL
  1057.     If (margin.left = 0) And (margin.right = MaxColumn) Then
  1058.     For i = curY + 1 To margin.bottom
  1059.         scrnData(sdI(i)) = blankLine
  1060.         scrnAttr(sdI(i)) = String(CharsPerRow, curAttr)
  1061.         scrnColor(sdI(i)) = String(CharsPerRow, curColor)
  1062.     Next i
  1063.     Else
  1064.     For i = curY + 1 To margin.bottom
  1065.         Mid(scrnData(sdI(i)), margin.left + 1, windowWidth) = String(windowWidth, " ")
  1066.         Mid(scrnAttr(sdI(i)), margin.left + 1, windowWidth) = String(windowWidth, curAttr)
  1067.         Mid(scrnColor(sdI(i)), margin.left + 1, windowWidth) = String(windowWidth, curColor)
  1068.     Next i
  1069.     End If
  1070.     QScreenUpdate margin.left, curY, margin.right, margin.bottom
  1071.  
  1072. End Sub
  1073.  
  1074. Sub EraseToEOL ()
  1075.  
  1076.     Mid(scrnData(sdI(curY)), curX + 1, margin.right - curX + 1) = String(margin.right - curX + 1, " ")
  1077.     Mid(scrnAttr(sdI(curY)), curX + 1, margin.right - curX + 1) = String(margin.right - curX + 1, curAttr)
  1078.     Mid(scrnColor(sdI(curY)), curX + 1, margin.right - curX + 1) = String(margin.right - curX + 1, curColor)
  1079.     QScreenUpdate curX, curY, margin.right, curY
  1080.  
  1081. End Sub
  1082.  
  1083. Function FindUpperCaseChar () As Integer
  1084.     Dim row%, col%, i%, chCode%
  1085.  
  1086.     row = mouseUpY \ (Scrn.TextHeight("M") + lineSpacingExt) + MinRow
  1087.     If row > MaxRow Then row = MaxRow
  1088.     col = mouseUpX \ Scrn.TextWidth("M")
  1089.     If col > MaxColumn Then col = MaxColumn
  1090.     ' Look left
  1091.     For i = col To MinColumn Step -1
  1092.     chCode = Asc(Mid(scrnData(sdI(row)), i + 1, 1))
  1093.     If chCode = &H20 Then Exit For
  1094.     If IsCharUpper(chCode) <> 0 Then
  1095.         FindUpperCaseChar = chCode
  1096.         Exit Function
  1097.     End If
  1098.     Next i
  1099.     ' Not found left, so look right
  1100.     For i = col To MaxColumn
  1101.     chCode = Asc(Mid(scrnData(sdI(row)), i + 1, 1))
  1102.     If chCode = &H20 Then Exit For
  1103.     If IsCharUpper(chCode) <> 0 Then
  1104.         FindUpperCaseChar = chCode
  1105.         Exit Function
  1106.     End If
  1107.     Next i
  1108.     FindUpperCaseChar = 0
  1109.  
  1110. End Function
  1111.  
  1112. Sub FlushCapturedLine ()
  1113.  
  1114.     On Error GoTo prtFlushError
  1115.     Printer.Print localCaptureLine
  1116.     localCaptureLine = ""
  1117.     Exit Sub
  1118.  
  1119. prtFlushError:
  1120.     localCapture = False
  1121.     MFileScrCaptureBegin.Enabled = True
  1122.     MFileScrCaptureBegin.Visible = True
  1123.     MFileScrCaptureEnd.Enabled = False
  1124.     MFileScrCaptureEnd.Visible = False
  1125.     MFilePrintScreen.Enabled = True
  1126.     ShowStatus "Printer Error", True
  1127.     Resume Next
  1128.  
  1129. End Sub
  1130.  
  1131. Sub Form_Activate ()
  1132.  
  1133.     Select Case curConnectType
  1134.     Case CT_Async
  1135.         If CommPort.PortOpen = False Then
  1136.         CommPort.Settings = curBaudRate & "," & curParity & "," & curDataBits & "," & curStopBits
  1137.         CommPort.CommPort = curCommPort
  1138.         CommPort.Handshaking = curHandShake
  1139.         If CommPort.DTREnable Then LedDTR.ForeColor = LedOnColor
  1140.         If CommPort.RTSEnable Then LedRTS.ForeColor = LedOnColor
  1141.         If CommPort.CDHolding Then LedCD.ForeColor = LedOnColor
  1142.         If CommPort.DSRHolding Then LedDSR.ForeColor = LedOnColor
  1143.         If CommPort.CTSHolding Then LedCTS.ForeColor = LedOnColor
  1144.         End If
  1145.         ShowStatus "COM" & CommPort.CommPort & ":" & CommPort.Settings, False
  1146.     End Select
  1147.  
  1148. End Sub
  1149.  
  1150. Sub Form_GotFocus ()
  1151.  
  1152.     Scrn.SetFocus
  1153.  
  1154. End Sub
  1155.  
  1156. Sub Form_KeyPress (KeyAscii As Integer)
  1157.  
  1158.     SendString Chr$(KeyAscii)
  1159.     KeyAscii = 0
  1160.  
  1161. End Sub
  1162.  
  1163. Sub Form_Load ()
  1164.     Dim rv%
  1165.  
  1166.     InitVars
  1167.     
  1168.     localCapture = False
  1169.     textSelected = False
  1170.     pasteInterval = TPaste.Interval
  1171.     pasteBurst = 5
  1172.     lastWindowState = FMain.WindowState
  1173.  
  1174.     normalBgColor = GetSysColor(COLOR_WINDOW)
  1175.     normalFgColor = GetSysColor(COLOR_WINDOWTEXT)
  1176.     normalHiColor = normalFgColor
  1177.     cursorColor = normalFgColor
  1178.     selTextFgColor = normalBgColor
  1179.     selTextBgColor = normalFgColor
  1180.  
  1181.     Portal.BorderStyle = 0
  1182.     Scrn.BorderStyle = 0
  1183.  
  1184.     LoadFromFile DefaultINI
  1185.  
  1186.     ' Get the following from the WIN.INI [sounds] section
  1187.     clickWav = GetOrSetWav(Appl_ClickWav, defaultClickWav)
  1188.     beepWav = GetOrSetWav(Appl_BeepWav, defaultBeepWav)
  1189.  
  1190.  
  1191.     ' If no default INI file has been created, then create one
  1192.     If curIniFilename = "" Then
  1193.     curIniFilename = "*.wtw"
  1194.     SaveToFile DefaultINI
  1195.     rv = WritePrivateProfileString(Key_Notes, Appl_CurrentIni, curIniFilename, DefaultINI)
  1196.     End If
  1197.  
  1198.     MoveCursor curX, curY
  1199.     SetCursorOff
  1200.     textCursorOn = False
  1201.  
  1202.     cmdSeq = 0
  1203.  
  1204.     startTime = TimeValue(Now)
  1205.  
  1206.     LedOnColor = QBColor(OnColor)
  1207.     LedOffColor = QBColor(OffColor)
  1208.     LedRX.ForeColor = LedOffColor
  1209.     LedTX.ForeColor = LedOffColor
  1210.     LedDTR.ForeColor = LedOffColor
  1211.     LedRTS.ForeColor = LedOffColor
  1212.     LedCD.ForeColor = LedOffColor
  1213.     LedDSR.ForeColor = LedOffColor
  1214.     LedCTS.ForeColor = LedOffColor
  1215.  
  1216.     MSessionDisconnect.Enabled = False
  1217.  
  1218. End Sub
  1219.  
  1220. Sub Form_Resize ()
  1221.     Dim tempSize%, minWidth%, maxWidth%, rv%
  1222.  
  1223.     If FMain.WindowState <> MINIMIZED Then
  1224.  
  1225.     ' Only allow full line heights
  1226.     If FMain.WindowState <> MAXIMIZED Then
  1227.         tempSize = FMain.Height - StatusBar.Height - sidesTB - HScrollBar.Height
  1228.         tempSize = tempSize \ (Scrn.TextHeight("M") + lineSpacingExt)
  1229.         FMain.Height = (tempSize * (Scrn.TextHeight("M") + lineSpacingExt)) + StatusBar.Height + sidesTB + HScrollBar.Height
  1230.     End If
  1231.  
  1232.     HScrollBar.SmallChange = Scrn.TextWidth("M")
  1233.     HScrollBar.LargeChange = HScrollBar.SmallChange * 10
  1234.     VScrollBar.SmallChange = Scrn.TextHeight("M") + lineSpacingExt
  1235.     VScrollBar.LargeChange = VScrollBar.SmallChange * 5
  1236.  
  1237.     minWidth = ModemPanel.Width + CurrentTime.Width + ElapsedTime.Width + 500
  1238.     maxWidth = CharsPerRow * Scrn.TextWidth("M") + sidesLR + VScrollBar.Width
  1239.     If minWidth > maxWidth Then maxWidth = minWidth
  1240.     If FMain.Width < minWidth Then
  1241.         FMain.Width = minWidth
  1242.     ElseIf (FMain.Width > maxWidth) And (FMain.WindowState <> MAXIMIZED) Then
  1243.         FMain.Width = maxWidth
  1244.     End If
  1245.  
  1246.     tempSize = FMain.Width - sidesLR - VScrollBar.Width
  1247.     HScrollBar.Max = (CharsPerRow * Scrn.TextWidth("M")) - tempSize
  1248.     HScrollBar.Enabled = (HScrollBar.Max > HScrollBar.Min)
  1249.     tempSize = (FMain.Height - StatusBar.Height - sidesTB - HScrollBar.Height)' - 30)
  1250.     VScrollBar.Max = ((MaxRow - MinRow + 1) * (Scrn.TextHeight("M") + lineSpacingExt)) - tempSize
  1251.     VScrollBar.Enabled = (VScrollBar.Max > VScrollBar.Min)
  1252.  
  1253.  
  1254.     StatusPanel.Width = FMain.ScaleWidth - StatusPanel.left - 30
  1255.     ElapsedTime.left = StatusPanel.Width - ElapsedTime.Width
  1256.     CurrentTime.left = ElapsedTime.left - CurrentTime.Width - 50
  1257.  
  1258.     HScrollBar.Width = FMain.Width - sidesLR - VScrollBar.Width
  1259.     HScrollBar.left = 0
  1260.     HScrollBar.top = FMain.Height - sidesTB - StatusBar.Height - HScrollBar.Height
  1261.  
  1262.     VScrollBar.top = 0
  1263.     VScrollBar.left = FMain.Width - sidesLR - VScrollBar.Width
  1264.     VScrollBar.Height = Abs(HScrollBar.top)
  1265.  
  1266.     Portal.top = FMain.ScaleTop
  1267.     Portal.left = FMain.ScaleLeft
  1268.     Portal.Width = VScrollBar.left
  1269.     Portal.Height = VScrollBar.Height
  1270.     Portal.BackColor = normalBgColor
  1271.  
  1272.     If (lastWindowState = MAXIMIZED) And (FMain.WindowState <> MAXIMIZED) Then
  1273.         VScrollBar.Value = VScrollBar.Max
  1274.     End If
  1275.  
  1276.     Scrn.top = -VScrollBar.Value
  1277.     Scrn.left = -HScrollBar.Value
  1278.     Scrn.Width = CharsPerRow * Scrn.TextWidth("M")
  1279.     Scrn.Height = (MaxRow - MinRow + 1) * (Scrn.TextHeight("M") + lineSpacingExt)
  1280.     CalculateYPosValues
  1281.  
  1282.     visibleArea.bottom = MaxRow - (VScrollBar.Max - VScrollBar.Value) \ (Scrn.TextHeight("M") + lineSpacingExt)
  1283.     visibleArea.top = (visibleArea.bottom - (VScrollBar.Height \ (Scrn.TextHeight("M") + lineSpacingExt))) + 1
  1284.     visibleLines = visibleArea.bottom - visibleArea.top + 1
  1285.     ShowStatus visibleLines & " lines from " & Str$(visibleArea.top) & " through " & Trim$(Str$(visibleArea.bottom)) & " are visible", False
  1286.  
  1287.     SetClipRegion
  1288.  
  1289.     End If
  1290.  
  1291.     lastWindowState = FMain.WindowState
  1292.     If FMain.WindowState = NORMAL Then
  1293.     initLeft = FMain.left
  1294.     initTop = FMain.top
  1295.     initWidth = FMain.Width
  1296.     initHeight = FMain.Height
  1297.     rv = WritePrivateProfileString(Key_Notes, Appl_Width, Str$(initWidth), DefaultINI)
  1298.     rv = WritePrivateProfileString(Key_Notes, Appl_Height, Str$(initHeight), DefaultINI)
  1299.     End If
  1300.     
  1301. End Sub
  1302.  
  1303. Sub Form_Unload (Cancel As Integer)
  1304.     Dim rv%
  1305.  
  1306.     MFileScrCaptureEnd_Click
  1307.  
  1308.     If MSessionDisconnect.Enabled Then
  1309.     MSessionDisconnect_Click
  1310.     End If
  1311.  
  1312.     rv = WritePrivateProfileString(Key_Pref, Appl_MouseStyle, Str$(mouseStyle), DefaultINI)
  1313.     If FMain.WindowState = NORMAL Then
  1314.     rv = WritePrivateProfileString(Key_Notes, Appl_Top, Str$(FMain.top), DefaultINI)
  1315.     rv = WritePrivateProfileString(Key_Notes, Appl_Left, Str$(FMain.left), DefaultINI)
  1316.     End If
  1317.     
  1318.     End
  1319.  
  1320. End Sub
  1321.  
  1322. Function GetOrSetWav (keyWav$, dfltWav$) As String
  1323.     Dim rv%, pLen%, pStr As String * 256, wavName$
  1324.  
  1325.     pLen = GetProfileString("Sounds", keyWav, "", pStr, 255)
  1326.     wavName = Trim$(Left$(pStr, pLen))
  1327.     pLen = InStr(wavName, ",")
  1328.     If pLen > 0 Then
  1329.     wavName = Trim$(Left$(wavName, pLen - 1))
  1330.     End If
  1331.     If wavName = "" Then     'not installed yet or incorrect format, so let's install it
  1332.     rv = WriteProfileString("Sounds", keyWav, dfltWav & "," & keyWav)
  1333.     wavName = dfltWav
  1334.     End If
  1335.  
  1336.     GetOrSetWav = wavName
  1337.  
  1338. End Function
  1339.  
  1340. Sub HScrollBar_Change ()
  1341.     
  1342.     Scrn.left = -HScrollBar.Value
  1343.  
  1344. End Sub
  1345.  
  1346. Sub HScrollBar_GotFocus ()
  1347.  
  1348.     Scrn.SetFocus
  1349.  
  1350. End Sub
  1351.  
  1352. Sub InitVars ()
  1353.     Dim i%
  1354.  
  1355.     blankLine = String(CharsPerRow, " ")
  1356.     curAttrFullLine = String(CharsPerRow, ANormal)
  1357.     curAttr = ANormal
  1358.     curColor = CNormal
  1359.     For i = MinRow To MaxRow
  1360.     scrnData(i) = blankLine
  1361.     scrnAttr(i) = curAttrFullLine
  1362.     scrnColor(i) = String(CharsPerRow, CNormal)
  1363.     sdI(i) = i
  1364.     Next i
  1365.  
  1366.     sidesLR = FMain.Width - FMain.ScaleWidth
  1367.     sidesTB = FMain.Height - FMain.ScaleHeight
  1368.  
  1369.     curX = 0
  1370.     curY = 0
  1371.     ResetMargins
  1372.  
  1373.     qX1 = MaxColumn
  1374.     qY1 = MaxRow
  1375.     qX2 = 0
  1376.     qY2 = 0
  1377.     partialScrnUpdate = False
  1378.  
  1379.     queueTxData = ""
  1380.  
  1381.     lastMouseButton = 0
  1382.     mouseState = 0
  1383.  
  1384.     connecting = False
  1385.     disconnecting = False
  1386.  
  1387.     defaultClickWav = ""
  1388.     defaultBeepWav = ""
  1389.  
  1390. End Sub
  1391.  
  1392. Sub InsertChar (ByVal byte As Integer)
  1393.     Static fieldH%, fieldV%
  1394.     Dim headChar$, tailChar$, headAttr$, tailAttr$, headColor$, tailColor$, i%, j%
  1395.  
  1396.     Select Case seqPhase
  1397.     Case 1
  1398.         fieldH = byte + margin.left
  1399.     Case 2
  1400.         cmdSeq = 0
  1401.         fieldV = byte + margin.top
  1402.         If (fieldH <= margin.right) And (fieldV <= margin.bottom) Then
  1403.         i = sdI(curY)
  1404.         If curY = fieldV Then
  1405.             Mid(scrnData(i), curX + 1, fieldH - curX + 1) = " " & Mid(scrnData(i), curX + 1, fieldH - curX)
  1406.             Mid(scrnAttr(i), curX + 1, fieldH - curX + 1) = Chr$(curAttr) & Mid(scrnAttr(i), curX + 1, fieldH - curX)
  1407.             Mid(scrnColor(i), curX + 1, fieldH - curX + 1) = Chr$(curColor) & Mid(scrnColor(i), curX + 1, fieldH - curX)
  1408.             QScreenUpdate curX, curY, fieldH, curY
  1409.         Else
  1410.             headChar = Mid(scrnData(i), margin.right + 1, 1)
  1411.             headAttr = Mid(scrnAttr(i), margin.right + 1, 1)
  1412.             headColor = Mid(scrnColor(i), margin.right + 1, 1)
  1413.             Mid(scrnData(i), curX + 1, margin.right - curX + 1) = " " & Mid(scrnData(i), curX + 1, margin.right - curX)
  1414.             Mid(scrnAttr(i), curX + 1, margin.right - curX + 1) = Chr$(curAttr) & Mid(scrnAttr(i), curX + 1, margin.right - curX)
  1415.             Mid(scrnColor(i), curX + 1, margin.right - curX + 1) = Chr$(curColor) & Mid(scrnColor(i), curX + 1, margin.right - curX)
  1416.             For j = curY + 1 To fieldV
  1417.             i = sdI(j)
  1418.             If i = fieldV Then
  1419.                 Mid(scrnData(i), margin.left + 1, fieldH - margin.left + 1) = headChar & Mid(scrnData(i), margin.left + 1, fieldH - margin.left)
  1420.                 Mid(scrnAttr(i), margin.left + 1, fieldH - margin.left + 1) = headAttr & Mid(scrnAttr(i), margin.left + 1, fieldH - margin.left)
  1421.                 Mid(scrnColor(i), margin.left + 1, fieldH - margin.left + 1) = headColor & Mid(scrnColor(i), margin.left + 1, fieldH - margin.left)
  1422.             Else
  1423.                 tailChar = Mid(scrnData(i), margin.right + 1, 1)
  1424.                 tailAttr = Mid(scrnAttr(i), margin.right + 1, 1)
  1425.                 tailColor = Mid(scrnColor(i), margin.right + 1, 1)
  1426.                 Mid(scrnData(i), margin.left + 1, windowWidth) = headChar & Mid(scrnData(i), margin.left + 1, margin.right - margin.left)
  1427.                 Mid(scrnAttr(i), margin.left + 1, windowWidth) = headAttr & Mid(scrnAttr(i), margin.left + 1, margin.right - margin.left)
  1428.                 Mid(scrnColor(i), margin.left + 1, windowWidth) = headColor & Mid(scrnColor(i), margin.left + 1, margin.right - margin.left)
  1429.                 headChar = tailChar
  1430.                 headAttr = tailAttr
  1431.                 headColor = tailColor
  1432.             End If
  1433.             Next j
  1434.             QScreenUpdate margin.left, curY, margin.right, fieldV
  1435.         End If
  1436.         End If
  1437.     End Select
  1438.  
  1439.     seqPhase = seqPhase + 1
  1440.  
  1441. End Sub
  1442.  
  1443. Sub LoadFromFile (iniFile$)
  1444.     Dim pLen%, pStr As String * 256
  1445.  
  1446.     curCommPort = GetPrivateProfileInt(Key_Async, Appl_CommPort, 2, iniFile)
  1447.  
  1448.     curHandShake = GetPrivateProfileInt(Key_Async, Appl_HandShake, 2, iniFile)
  1449.     If (curHandShake > 2) Or (curHandShake < 0) Then
  1450.     curHandShake = 0
  1451.     End If
  1452.  
  1453.     pLen = GetPrivateProfileString(Key_Async, Appl_BaudRate, "9600", pStr, 6, iniFile)
  1454.     curBaudRate = Left(pStr, pLen)
  1455.  
  1456.     pLen = GetPrivateProfileString(Key_Async, Appl_Parity, "N", pStr, 2, iniFile)
  1457.     curParity = Left(pStr, pLen)
  1458.  
  1459.     pLen = GetPrivateProfileString(Key_Async, Appl_Databits, "8", pStr, 2, iniFile)
  1460.     curDataBits = Left(pStr, pLen)
  1461.  
  1462.     pLen = GetPrivateProfileString(Key_Async, Appl_Stopbits, "1", pStr, 2, iniFile)
  1463.     curStopBits = Left(pStr, pLen)
  1464.  
  1465.     asyncOutBufSize = GetPrivateProfileInt(Key_Async, Appl_OutBufSize, 512, iniFile)
  1466.     asyncInBufSize = GetPrivateProfileInt(Key_Async, Appl_InBufSize, 1024, iniFile)
  1467.     asyncPollInterval = GetPrivateProfileInt(Key_Async, Appl_Interval, 100, iniFile)
  1468.  
  1469.  
  1470.     pLen = GetPrivateProfileString(Key_Pref, Appl_ForeColor, Str$(normalFgColor), pStr, 11, iniFile)
  1471.     normalFgColor = CLng(Left(pStr, pLen))
  1472.  
  1473.     pLen = GetPrivateProfileString(Key_Pref, Appl_BackColor, Str$(normalBgColor), pStr, 11, iniFile)
  1474.     normalBgColor = CLng(Left(pStr, pLen))
  1475.     
  1476.     pLen = GetPrivateProfileString(Key_Pref, Appl_HiColor, Str$(normalHiColor), pStr, 11, iniFile)
  1477.     normalHiColor = CLng(Left(pStr, pLen))
  1478.     
  1479.     pLen = GetPrivateProfileString(Key_Pref, Appl_CursorColor, Str$(cursorColor), pStr, 11, iniFile)
  1480.     cursorColor = CLng(Left(pStr, pLen))
  1481.  
  1482.     pLen = GetPrivateProfileString(Key_Pref, Appl_SelTxtFgColor, Str$(selTextFgColor), pStr, 11, iniFile)
  1483.     selTextFgColor = CLng(Left(pStr, pLen))
  1484.                            
  1485.     pLen = GetPrivateProfileString(Key_Pref, Appl_SelTxtBgColor, Str$(selTextBgColor), pStr, 11, iniFile)
  1486.     selTextBgColor = CLng(Left(pStr, pLen))
  1487.                            
  1488.                            
  1489.     pLen = GetPrivateProfileString(Key_Pref, Appl_Font, "Terminal", pStr, 30, iniFile)
  1490.     Scrn.FontName = Left(pStr, pLen)
  1491.  
  1492.     Scrn.FontSize = GetPrivateProfileInt(Key_Pref, Appl_FontSize, 9, iniFile)
  1493.  
  1494.     lineSpacing = GetPrivateProfileInt(Key_Pref, Appl_LineSpacing, 0, iniFile)
  1495.     If lineSpacing > 10 Then lineSpacing = 10
  1496.     If lineSpacing < 0 Then lineSpacing = 0
  1497.     lineSpacingExt = lineSpacing * Screen.TwipsPerPixelY
  1498.  
  1499.     cursorBlinkTimer.Interval = GetPrivateProfileInt(Key_Pref, Appl_CursorBlink, 3, iniFile) * 100
  1500.     If cursorBlinkTimer.Interval > 1000 Then cursorBlinkTimer.Interval = 1000
  1501.  
  1502.     rollStyle = GetPrivateProfileInt(Key_Pref, Appl_RollStyle, BUFFERED, iniFile)
  1503.     MPrefRollBuffered.Checked = False
  1504.     MPrefRollImmediate.Checked = False
  1505.     MPrefRollSmart.Checked = False
  1506.     Select Case rollStyle
  1507.     Case IMMEDIATE
  1508.         MPrefRollImmediate.Checked = True
  1509.     Case BUFFERED
  1510.         MPrefRollBuffered.Checked = True
  1511.     Case Else
  1512.         rollStyle = SMART
  1513.         MPrefRollSmart.Checked = True
  1514.     End Select
  1515.  
  1516.  
  1517.     mouseStyle = GetPrivateProfileInt(Key_Pref, Appl_MouseStyle, MouseMenu, iniFile)
  1518.     
  1519.     
  1520.     ' The following commented code causes a General Protection Fault in GDI
  1521.     dPrtFontName = "Courier"
  1522.     pLen = GetPrivateProfileString(Key_Pref, Appl_PrtFontName, dPrtFontName, pStr, 30, iniFile)
  1523.     prtFontName = Left(pStr, pLen)
  1524.     'Printer.FontName = Left(pStr, pLen)
  1525.     dPrtFontSize = 12
  1526.     'Printer.FontSize = GetPrivateProfileInt(Key_Pref, Appl_PrtFontSize, dPrtFontSize, iniFile)
  1527.     prtFontSize = GetPrivateProfileInt(Key_Pref, Appl_PrtFontSize, dPrtFontSize, iniFile)
  1528.  
  1529.  
  1530.     pLen = GetPrivateProfileString(Key_Notes, Appl_CurrentIni, "", pStr, 255, iniFile)
  1531.     curIniFilename = Left(pStr, pLen)
  1532.  
  1533.     curConnectType = GetPrivateProfileInt(Key_Notes, Appl_ConnectType, CT_Async, iniFile)
  1534.     connectAtStartup = GetPrivateProfileInt(Key_Notes, Appl_AutoConnect, False, iniFile)
  1535.  
  1536.     initTop = GetPrivateProfileInt(Key_Notes, Appl_Top, 0, iniFile)
  1537.     initLeft = GetPrivateProfileInt(Key_Notes, Appl_Left, 0, iniFile)
  1538.     initWidth = GetPrivateProfileInt(Key_Notes, Appl_Width, 0, iniFile)
  1539.     initHeight = GetPrivateProfileInt(Key_Notes, Appl_Height, 0, iniFile)
  1540.  
  1541.     
  1542.     Scrn.BackColor = normalBgColor
  1543.     Scrn.ForeColor = normalFgColor
  1544.     ' Specifying COLOR_SCROLLBAR caused "invalid property" on Compaq's
  1545.     If GetSysColor(COLOR_SCROLLBAR) > &HFFFFFF Then
  1546.     FMain.BackColor = QBColor(G_LIGHT_GRAY)
  1547.     Else
  1548.     FMain.BackColor = GetSysColor(COLOR_SCROLLBAR)
  1549.     End If
  1550.  
  1551.  
  1552.     pixelHeight = (Scrn.TextHeight("M") / Screen.TwipsPerPixelY) + lineSpacing
  1553.     pixelWidth = Scrn.TextWidth("M") / Screen.TwipsPerPixelX
  1554.     
  1555.     If initHeight = 0 Then
  1556.     initHeight = (MaxRow + 1) * Scrn.TextHeight("M") + lineSpacingExt + StatusBar.Height + sidesTB + HScrollBar.Height '+ 30'25
  1557.     End If
  1558.     If initWidth = 0 Then
  1559.     initWidth = CharsPerRow * Scrn.TextWidth("M") + sidesLR + VScrollBar.Width '+ 30'25
  1560.     End If
  1561.     FMain.Move initLeft, initTop, initWidth, initHeight
  1562.     VScrollBar.Value = VScrollBar.Max
  1563.  
  1564. End Sub
  1565.  
  1566. Sub MColorSelTextBg_Click ()
  1567.     Dim rv%
  1568.  
  1569.     FMain.CMDialog1.DialogTitle = "Selected Text Background Color"
  1570.     FMain.CMDialog1.Color = selTextBgColor
  1571.     FMain.CMDialog1.Flags = CC_RGBINIT
  1572.     CMDialog1.CancelError = False
  1573.     FMain.CMDialog1.Action = 3
  1574.  
  1575.     selTextBgColor = FMain.CMDialog1.Color
  1576.     rv = WritePrivateProfileString(Key_Pref, Appl_SelTxtBgColor, Str$(selTextBgColor), DefaultINI)
  1577.  
  1578. End Sub
  1579.  
  1580. Sub MColorSelTextFg_Click ()
  1581.     Dim rv%
  1582.  
  1583.     FMain.CMDialog1.DialogTitle = "Selected Text Foreground Color"
  1584.     FMain.CMDialog1.Color = selTextFgColor
  1585.     FMain.CMDialog1.Flags = CC_RGBINIT
  1586.     CMDialog1.CancelError = False
  1587.     FMain.CMDialog1.Action = 3
  1588.  
  1589.     selTextFgColor = FMain.CMDialog1.Color
  1590.     rv = WritePrivateProfileString(Key_Pref, Appl_SelTxtFgColor, Str$(selTextFgColor), DefaultINI)
  1591.  
  1592. End Sub
  1593.  
  1594. Sub MEdit_Click ()
  1595.  
  1596.     MEditPaste.Enabled = Clipboard.GetFormat(CF_TEXT)
  1597.     MEditCopyAppend.Enabled = MEditPaste.Enabled And MEditCopy.Enabled
  1598.     MEditUnselect.Enabled = MEditCopy.Enabled
  1599.  
  1600. End Sub
  1601.  
  1602. Sub MEditCopy_Click ()
  1603.     Dim rowIndex%, lineLen%, s$
  1604.  
  1605.     lineLen = selTextLastCol - selTextCol1 + 1
  1606.     s = Mid(scrnData(sdI(selTextRow1)), selTextCol1 + 1, lineLen) & Chr$(13) & Chr$(10)
  1607.     For rowIndex = selTextRow1 + 1 To selTextLastRow
  1608.     s = s & Mid(scrnData(sdI(rowIndex)), selTextCol1 + 1, lineLen) & Chr$(13) & Chr$(10)
  1609.     Next rowIndex
  1610.     Clipboard.SetText s
  1611.  
  1612.     ReDisplayScreen selTextCol1, selTextRow1, selTextLastCol, selTextLastRow
  1613.     MEditCopy.Enabled = False
  1614.     textSelected = False
  1615.  
  1616. End Sub
  1617.  
  1618. Sub MEditCopyAppend_Click ()
  1619.     Dim rowIndex%, lineLen%, s$
  1620.  
  1621.     s = Clipboard.GetText(CF_TEXT)   ' Get current Clipboard text
  1622.  
  1623.     lineLen = selTextLastCol - selTextCol1 + 1
  1624.     s = s & Mid(scrnData(sdI(selTextRow1)), selTextCol1 + 1, lineLen) & Chr$(13) & Chr$(10)
  1625.     For rowIndex = selTextRow1 + 1 To selTextLastRow
  1626.     s = s & Mid(scrnData(sdI(rowIndex)), selTextCol1 + 1, lineLen) & Chr$(13) & Chr$(10)
  1627.     Next rowIndex
  1628.     Clipboard.SetText s
  1629.  
  1630.     ReDisplayScreen selTextCol1, selTextRow1, selTextLastCol, selTextLastRow
  1631.     MEditCopy.Enabled = False
  1632.     textSelected = False
  1633.  
  1634. End Sub
  1635.  
  1636. Sub MEditPaste_Click ()
  1637.  
  1638.     If TPaste.Enabled Then
  1639.     TPaste.Enabled = False
  1640.     Else
  1641.     pasteStr = Clipboard.GetText(CF_TEXT)   ' Get Clipboard text
  1642.     pasteLen = Len(pasteStr)
  1643.     If pasteLen > 0 Then
  1644.         pasteIndex = 1
  1645.         TPaste.Interval = pasteInterval
  1646.         TPaste.Enabled = True
  1647.     End If
  1648.     End If
  1649.  
  1650. End Sub
  1651.  
  1652. Sub MEditShowClipboard_Click ()
  1653.     Dim cbStr$
  1654.  
  1655.     cbStr = Clipboard.GetText(CF_TEXT) ' Get Clipboard text
  1656.     MsgBox cbStr, MB_OK, "Current Clipboard Data"
  1657.  
  1658. End Sub
  1659.  
  1660. Sub MEditUnselect_Click ()
  1661.  
  1662.     ReDisplayScreen selTextCol1, selTextRow1, selTextLastCol, selTextLastRow
  1663.     MEditCopy.Enabled = False
  1664.     MEditUnselect.Enabled = False
  1665.     textSelected = False
  1666.  
  1667. End Sub
  1668.  
  1669. Sub MFile_Click ()
  1670.  
  1671.     MFileLoad.Enabled = MSessionConnect.Enabled
  1672.  
  1673. End Sub
  1674.  
  1675. Sub MFileExit_Click ()
  1676.  
  1677.     Unload FMain
  1678.  
  1679. End Sub
  1680.  
  1681. Sub MFileLoad_Click ()
  1682.     Dim rv%, fileToLoad$
  1683.  
  1684.     CMDialog1.Filename = curIniFilename
  1685.     CMDialog1.Filter = "WSPRTERM files (*.wtw) | *.wtw | All files (*.*) | *.*"
  1686.     CMDialog1.FilterIndex = 1
  1687.     CMDialog1.DefaultExt = "wtw"
  1688.     CMDialog1.Flags = OFN_HIDEREADONLY
  1689.     CMDialog1.CancelError = True
  1690.  
  1691.     On Error GoTo LoadCancelled
  1692.     CMDialog1.Action = 1            ' Open...
  1693.  
  1694.     If CMDialog1.Filename <> "" Then
  1695.     fileToLoad = CMDialog1.Filename
  1696.     FMain.Hide
  1697.     LoadFromFile fileToLoad
  1698.     curIniFilename = fileToLoad
  1699.     SaveToFile DefaultINI
  1700.     rv = WritePrivateProfileString(Key_Notes, Appl_CurrentIni, curIniFilename, DefaultINI)
  1701.     FMain.Show
  1702.     FMain.Refresh
  1703.     Form_Activate
  1704.     End If
  1705.  
  1706.     Exit Sub
  1707.  
  1708. LoadCancelled:
  1709.     Exit Sub
  1710.  
  1711. End Sub
  1712.  
  1713. Sub MFilePrintScreen_Click ()
  1714.     Dim row%, rowIndex%, col%, attr%, start%, count%
  1715.  
  1716.     On Error GoTo prtScrError
  1717.  
  1718.     ShowStatus "Printing screen...", False
  1719.     attr = ANormal
  1720.     Printer.FontBold = False
  1721.     Printer.FontUnderline = False
  1722.     Printer.FontName = prtFontName
  1723.     Printer.FontSize = prtFontSize
  1724.  
  1725.     For rowIndex = visibleArea.top To visibleArea.bottom
  1726.     row = sdI(rowIndex)
  1727.     start = 1
  1728.  
  1729.     count = 0
  1730.     For col = 1 To CharsPerRow
  1731.         If attr = Asc(Mid(scrnAttr(row), col, 1)) Then
  1732.         count = count + 1
  1733.         Else
  1734.         attr = Asc(Mid(scrnAttr(row), col, 1))
  1735.         Printer.Print Mid(scrnData(row), start, count);
  1736.         count = 1
  1737.         start = col
  1738.         Printer.FontBold = ((attr And ABold) <> 0)
  1739.         Printer.FontUnderline = ((attr And AUnderline) <> 0)
  1740.         End If
  1741.     Next col
  1742.     Printer.Print Mid(scrnData(row), start, count)
  1743.     Next rowIndex
  1744.  
  1745.     Printer.FontBold = False
  1746.     Printer.FontUnderline = False
  1747.     Printer.EndDoc
  1748.     ShowStatus "Print screen completed.", False
  1749.     Exit Sub
  1750.  
  1751.  
  1752. prtScrError:
  1753.     ShowStatus "Printer Error", True
  1754.     Exit Sub
  1755.  
  1756. End Sub
  1757.  
  1758. Sub MFileRefresh_Click ()
  1759.  
  1760.     If (curAttr And ASysColors) = 0 Then
  1761.     Scrn.BackColor = QBColor((curColor And CBgColorMask) \ Shift4)
  1762.     End If
  1763.     ReDisplayScreen 0, MinRow, MaxColumn, MaxRow
  1764.  
  1765. End Sub
  1766.  
  1767. Sub MFileSave_Click ()
  1768.     Dim rv%
  1769.  
  1770.     CMDialog1.Filename = curIniFilename
  1771.     CMDialog1.Filter = "WSPRTERM files (*.wtw) | *.wtw | All files (*.*) | *.*"
  1772.     CMDialog1.FilterIndex = 1
  1773.     CMDialog1.DefaultExt = "wtw"
  1774.     CMDialog1.Flags = OFN_HIDEREADONLY Or OFN_OVERWRITEPROMPT Or OFN_PATHMUSTEXIST
  1775.     CMDialog1.CancelError = True
  1776.  
  1777.     On Error GoTo SaveCancelled
  1778.     CMDialog1.Action = 2            ' SaveAs...
  1779.  
  1780.     If CMDialog1.Filename <> "" Then
  1781.     curIniFilename = CMDialog1.Filename
  1782.     If FMain.WindowState = NORMAL Then
  1783.         initLeft = FMain.left
  1784.         initTop = FMain.top
  1785.         initWidth = FMain.Width
  1786.         initHeight = FMain.Height
  1787.     End If
  1788.     SaveToFile curIniFilename
  1789.     rv = WritePrivateProfileString(Key_Notes, Appl_CurrentIni, curIniFilename, DefaultINI)
  1790.     End If
  1791.  
  1792.     Exit Sub
  1793.  
  1794. SaveCancelled:
  1795.     Exit Sub
  1796.  
  1797. End Sub
  1798.  
  1799. Sub MFileScrCaptureBegin_Click ()
  1800.  
  1801.     If MFileScrCaptureBegin.Enabled Then
  1802.     localCaptureLine = ""
  1803.     localCapture = True
  1804.     Printer.FontBold = ((curAttr And ABold) <> 0)
  1805.     Printer.FontUnderline = ((curAttr And AUnderline) <> 0)
  1806.     Printer.FontName = prtFontName
  1807.     Printer.FontSize = prtFontSize
  1808.     MFileScrCaptureBegin.Enabled = False
  1809.     MFileScrCaptureBegin.Visible = False
  1810.     MFileScrCaptureEnd.Enabled = True
  1811.     MFileScrCaptureEnd.Visible = True
  1812.     MFilePrintScreen.Enabled = False
  1813.     ShowStatus "Screen Capture On", False
  1814.     End If
  1815.  
  1816. End Sub
  1817.  
  1818. Sub MFileScrCaptureEnd_Click ()
  1819.  
  1820.     If MFileScrCaptureEnd.Enabled Then
  1821.     FlushCapturedLine
  1822.     localCapture = False
  1823.     MFileScrCaptureBegin.Enabled = True
  1824.     MFileScrCaptureBegin.Visible = True
  1825.     MFileScrCaptureEnd.Enabled = False
  1826.     MFileScrCaptureEnd.Visible = False
  1827.     MFilePrintScreen.Enabled = True
  1828.     Printer.EndDoc
  1829.     ShowStatus "Screen Capture Off", False
  1830.     End If
  1831.  
  1832. End Sub
  1833.  
  1834. Sub MHelpAbout_Click ()
  1835.  
  1836.     FAbout.Show 1
  1837.  
  1838. End Sub
  1839.  
  1840. Sub MMouse_Click ()
  1841.     
  1842.     MMouseMenu.Checked = False
  1843.     MMouseEditor.Checked = False
  1844.     MMouseOff.Checked = False
  1845.     Select Case mouseStyle
  1846.     Case MouseMenu
  1847.         MMouseMenu.Checked = True
  1848.     Case MouseEditor
  1849.         MMouseEditor.Checked = True
  1850.     Case MouseOff
  1851.         MMouseOff.Checked = True
  1852.     End Select
  1853.     
  1854. End Sub
  1855.  
  1856. Sub MMouseEditor_Click ()
  1857.  
  1858.     mouseStyle = MouseEditor
  1859.     Scrn.MousePointer = IBEAM
  1860.  
  1861. End Sub
  1862.  
  1863. Sub MMouseMenu_Click ()
  1864.  
  1865.     mouseStyle = MouseMenu
  1866.     Scrn.MousePointer = DEFAULT
  1867.  
  1868. End Sub
  1869.  
  1870. Sub MMouseOff_Click ()
  1871.  
  1872.     mouseStyle = MouseOff
  1873.     Scrn.MousePointer = NO_DROP
  1874.  
  1875.     If textSelected Then MEditUnselect_Click
  1876.  
  1877. End Sub
  1878.  
  1879. Sub MoveCursor (ByVal xVal%, ByVal yVal%)
  1880.  
  1881.     If Not partialScrnUpdate Then
  1882.     Scrn.CurrentX = Scrn.TextWidth(Left(scrnData(sdI(yVal)), xVal))
  1883.     Scrn.CurrentY = yPos(yVal)
  1884.     End If
  1885.  
  1886. End Sub
  1887.  
  1888. Sub MPrefColorBg_Click ()
  1889.     Dim rv%
  1890.  
  1891.     FMain.CMDialog1.DialogTitle = "Background Color"
  1892.     FMain.CMDialog1.Color = normalBgColor
  1893.     FMain.CMDialog1.Flags = CC_RGBINIT
  1894.     CMDialog1.CancelError = False
  1895.     FMain.CMDialog1.Action = 3
  1896.  
  1897.     normalBgColor = FMain.CMDialog1.Color
  1898.     rv = WritePrivateProfileString(Key_Pref, Appl_BackColor, Str$(normalBgColor), DefaultINI)
  1899.     
  1900.     Scrn.BackColor = normalBgColor
  1901.     curAttr = curAttr Or ASysColors
  1902.     ReDisplayScreen 0, MinRow, MaxColumn, MaxRow
  1903.  
  1904. End Sub
  1905.  
  1906. Sub MPrefColorCursor_Click ()
  1907.     Dim rv%
  1908.  
  1909.     FMain.CMDialog1.DialogTitle = "Cursor Color"
  1910.     FMain.CMDialog1.Color = cursorColor
  1911.     FMain.CMDialog1.Flags = CC_RGBINIT
  1912.     CMDialog1.CancelError = False
  1913.     FMain.CMDialog1.Action = 3
  1914.  
  1915.     cursorColor = FMain.CMDialog1.Color
  1916.     rv = WritePrivateProfileString(Key_Pref, Appl_CursorColor, Str$(cursorColor), DefaultINI)
  1917.     
  1918.     If textCursorOn Then SetCursorOn
  1919.  
  1920. End Sub
  1921.  
  1922. Sub MPrefColorFg_Click ()
  1923.     Dim rv%
  1924.  
  1925.     FMain.CMDialog1.DialogTitle = "Foreground (text) Color"
  1926.     FMain.CMDialog1.Color = normalFgColor
  1927.     FMain.CMDialog1.Flags = CC_RGBINIT
  1928.     CMDialog1.CancelError = False
  1929.     FMain.CMDialog1.Action = 3
  1930.  
  1931.     normalFgColor = FMain.CMDialog1.Color
  1932.     rv = WritePrivateProfileString(Key_Pref, Appl_ForeColor, Str$(normalFgColor), DefaultINI)
  1933.     
  1934.     Scrn.ForeColor = normalFgColor
  1935.     curAttr = curAttr Or ASysColors
  1936.     ReDisplayScreen 0, MinRow, MaxColumn, MaxRow
  1937.  
  1938. End Sub
  1939.  
  1940. Sub MPrefColorHi_Click ()
  1941.     Dim rv%
  1942.  
  1943.     FMain.CMDialog1.DialogTitle = "Highlight Color"
  1944.     FMain.CMDialog1.Color = normalHiColor
  1945.     FMain.CMDialog1.Flags = CC_RGBINIT
  1946.     CMDialog1.CancelError = False
  1947.     FMain.CMDialog1.Action = 3
  1948.  
  1949.     normalHiColor = FMain.CMDialog1.Color
  1950.     rv = WritePrivateProfileString(Key_Pref, Appl_HiColor, Str$(normalHiColor), DefaultINI)
  1951.     
  1952.     ReDisplayScreen 0, MinRow, MaxColumn, MaxRow
  1953.  
  1954. End Sub
  1955.  
  1956. Sub MPrefCursorBlink_Click ()
  1957.  
  1958.     FCursorBlink.Show 1
  1959.     If textCursorOn Then SetCursorOn
  1960.  
  1961. End Sub
  1962.  
  1963. Sub MPrefFontPrinter_Click ()
  1964.     Dim rv%
  1965.  
  1966.     Printer.FontName = prtFontName
  1967.     Printer.FontSize = prtFontSize
  1968.  
  1969.     FMain.CMDialog1.FontName = Printer.FontName
  1970.     FMain.CMDialog1.FontSize = Printer.FontSize
  1971.     FMain.CMDialog1.Flags = CF_PRINTERFONTS Or CF_FIXEDPITCHONLY Or CF_NOSTYLESEL
  1972.     CMDialog1.CancelError = False
  1973.     FMain.CMDialog1.Action = 4
  1974.  
  1975.     Printer.FontName = FMain.CMDialog1.FontName
  1976.     Printer.FontSize = FMain.CMDialog1.FontSize
  1977.  
  1978.     prtFontName = Printer.FontName
  1979.     prtFontSize = Printer.FontSize
  1980.     
  1981.     rv = WritePrivateProfileString(Key_Pref, Appl_PrtFontName, prtFontName, DefaultINI)
  1982.     rv = WritePrivateProfileString(Key_Pref, Appl_PrtFontSize, Str$(prtFontSize), DefaultINI)
  1983.  
  1984. End Sub
  1985.  
  1986. Sub MPrefFontScreen_Click ()
  1987.     Dim newHeight%, newWidth%, rv%
  1988.  
  1989.     Scrn.Cls
  1990.  
  1991.     FMain.CMDialog1.FontName = Scrn.FontName
  1992.     FMain.CMDialog1.FontSize = Scrn.FontSize
  1993.     FMain.CMDialog1.Flags = CF_SCREENFONTS Or CF_FIXEDPITCHONLY
  1994.     CMDialog1.CancelError = False
  1995.     FMain.CMDialog1.Action = 4
  1996.  
  1997.     Scrn.FontName = FMain.CMDialog1.FontName
  1998.     Scrn.FontSize = FMain.CMDialog1.FontSize
  1999.     Scrn.FontBold = FMain.CMDialog1.FontBold
  2000.     Scrn.FontItalic = FMain.CMDialog1.FontItalic
  2001.     rv = WritePrivateProfileString(Key_Pref, Appl_Font, Scrn.FontName, DefaultINI)
  2002.     rv = WritePrivateProfileString(Key_Pref, Appl_FontSize, Str$(Scrn.FontSize), DefaultINI)
  2003.  
  2004.     pixelHeight = (Scrn.TextHeight("M") / Screen.TwipsPerPixelY) + lineSpacing
  2005.     pixelWidth = Scrn.TextWidth("M") / Screen.TwipsPerPixelX
  2006.  
  2007.     newHeight = (MaxRow + 1) * (Scrn.TextHeight("M") + lineSpacingExt) + StatusBar.Height + sidesTB + HScrollBar.Height
  2008.     newWidth = CharsPerRow * Scrn.TextWidth("M") + sidesLR + VScrollBar.Width
  2009.     If (FMain.WindowState = NORMAL) And ((newWidth <> FMain.Width) Or (newHeight <> FMain.Height)) Then
  2010.     FMain.Move FMain.left, FMain.top, newWidth, newHeight
  2011.     End If
  2012.     VScrollBar.Value = VScrollBar.Max
  2013.  
  2014.     ReDisplayScreen 0, MinRow, MaxColumn, MaxRow
  2015.  
  2016. End Sub
  2017.  
  2018. Sub MPrefLineSpacing_Click ()
  2019.  
  2020.     FLineSpacing.Show 1
  2021.  
  2022. End Sub
  2023.  
  2024. Sub MPrefRollBuffered_Click ()
  2025.     Dim rv%
  2026.  
  2027.     rollStyle = BUFFERED
  2028.     rv = WritePrivateProfileString(Key_Pref, Appl_RollStyle, Str$(rollStyle), DefaultINI)
  2029.  
  2030. End Sub
  2031.  
  2032. Sub MPrefRollImmediate_Click ()
  2033.     Dim rv%
  2034.  
  2035.     rollStyle = IMMEDIATE
  2036.     rv = WritePrivateProfileString(Key_Pref, Appl_RollStyle, Str$(rollStyle), DefaultINI)
  2037.  
  2038. End Sub
  2039.  
  2040. Sub MPrefRollSmart_Click ()
  2041.     Dim rv%
  2042.  
  2043.     rollStyle = SMART
  2044.     rv = WritePrivateProfileString(Key_Pref, Appl_RollStyle, Str$(rollStyle), DefaultINI)
  2045.  
  2046. End Sub
  2047.  
  2048. Sub MPrefRollStyle_Click ()
  2049.  
  2050.     MPrefRollBuffered.Checked = False
  2051.     MPrefRollImmediate.Checked = False
  2052.     MPrefRollSmart.Checked = False
  2053.     Select Case rollStyle
  2054.     Case BUFFERED
  2055.         MPrefRollBuffered.Checked = True
  2056.     Case IMMEDIATE
  2057.         MPrefRollImmediate.Checked = True
  2058.     Case SMART
  2059.         MPrefRollSmart.Checked = True
  2060.     End Select
  2061.  
  2062. End Sub
  2063.  
  2064. Sub MSession_Click ()
  2065.  
  2066.     MSessionAutoConnect.Checked = connectAtStartup
  2067.  
  2068. End Sub
  2069.  
  2070. Sub MSessionAsync_Click ()
  2071.  
  2072.     CommSettings.Show 1
  2073.  
  2074. End Sub
  2075.  
  2076. Sub MSessionAutoConnect_Click ()
  2077.     Dim rv%
  2078.  
  2079.     connectAtStartup = Not connectAtStartup
  2080.     rv = WritePrivateProfileString(Key_Notes, Appl_AutoConnect, Str$(connectAtStartup), DefaultINI)
  2081.  
  2082. End Sub
  2083.  
  2084. Sub MSessionConnect_Click ()
  2085.  
  2086.     InitVars
  2087.     ReDisplayScreen 0, MinRow, MaxColumn, MaxRow
  2088.  
  2089.     Select Case curConnectType
  2090.  
  2091.     Case CT_Async
  2092.         CommPort.OutBufferSize = asyncOutBufSize
  2093.         CommPort.InBufferSize = asyncInBufSize
  2094.         CommPort.Interval = asyncPollInterval
  2095.         CommPort.DTREnable = True
  2096.         LedDTR.ForeColor = LedOnColor
  2097.         CommPort.PortOpen = True
  2098.         If CommPort.PortOpen Then
  2099.         MSessionConnect.Enabled = False
  2100.         MSessionDisconnect.Enabled = True
  2101.         CommPort.RTSEnable = True
  2102.         LedRTS.ForeColor = LedOnColor
  2103.         If CommPort.CDHolding Then
  2104.             ShowStatus "OnLine - COM" & CommPort.CommPort & ":" & CommPort.Settings, False
  2105.             LedCD.ForeColor = LedOnColor
  2106.             If CommPort.CTSHolding Then
  2107.             LedCTS.ForeColor = LedOnColor
  2108.             End If
  2109.             If CommPort.DSRHolding Then
  2110.             LedDSR.ForeColor = LedOnColor
  2111.             End If
  2112.         Else
  2113.             connecting = True
  2114.             ShowStatus "Connecting... using Async (COM" & CommPort.CommPort & ")", False
  2115.         End If
  2116.         SetCursorOn
  2117.         textCursorOn = True
  2118.         cursorBlinkTimer.Enabled = True
  2119.         End If
  2120.     
  2121.     End Select
  2122.     
  2123. End Sub
  2124.  
  2125. Sub MSessionDisconnect_Click ()
  2126.  
  2127.     Select Case curConnectType
  2128.  
  2129.     Case CT_Async
  2130.         ShowStatus "Disconnecting...", False
  2131.         CommPort.RTSEnable = False
  2132.         LedRTS.ForeColor = LedOffColor
  2133.         CommPort.DTREnable = False
  2134.         LedDTR.ForeColor = LedOffColor
  2135.         CommPort.PortOpen = False
  2136.  
  2137.         LedCTS.ForeColor = LedOffColor
  2138.         LedDSR.ForeColor = LedOffColor
  2139.         If CommPort.CDHolding Then
  2140.         disconnecting = True
  2141.         Else
  2142.         ShowStatus "Disconnected", False
  2143.         LedCD.ForeColor = LedOffColor
  2144.         End If
  2145.  
  2146.     End Select
  2147.  
  2148.     MSessionDisconnect.Enabled = False
  2149.     MSessionConnect.Enabled = True
  2150.  
  2151.     cursorBlinkTimer.Enabled = False
  2152.     SetCursorOff
  2153.     textCursorOn = False
  2154.  
  2155. End Sub
  2156.  
  2157. Sub OpenLine ()
  2158.     Dim i%
  2159.  
  2160.     cmdSeq = 0
  2161.     If curY < margin.bottom Then
  2162.     RollDown curY + 1, margin.bottom
  2163.     i = sdI(curY + 1)
  2164.     Mid(scrnData(i), curX + 1, margin.right - curX + 1) = Mid(scrnData(sdI(curY)), curX + 1, margin.right - curX + 1)
  2165.     Mid(scrnAttr(i), curX + 1, margin.right - curX + 1) = Mid(scrnAttr(sdI(curY)), curX + 1, margin.right - curX + 1)
  2166.     Mid(scrnColor(i), curX + 1, margin.right - curX + 1) = Mid(scrnColor(sdI(curY)), curX + 1, margin.right - curX + 1)
  2167.     QScreenUpdate curX, curY, margin.right, curY + 1
  2168.     End If
  2169.     EraseToEOL
  2170.  
  2171. End Sub
  2172.  
  2173. Sub Paste (s As String)
  2174.  
  2175.     pasteStr = s
  2176.     pasteLen = Len(pasteStr)
  2177.     If pasteLen > 0 Then
  2178.     pasteIndex = 1
  2179.     TPaste.Interval = pasteInterval
  2180.     TPaste.Enabled = True
  2181.     End If
  2182.  
  2183. End Sub
  2184.  
  2185. Sub QScreenUpdate (ByVal x1%, ByVal y1%, ByVal x2%, ByVal y2%)
  2186.  
  2187.     partialScrnUpdate = True
  2188.     If x1 < qX1 Then qX1 = x1
  2189.     If y1 < qY1 Then qY1 = y1
  2190.     If x2 > qX2 Then qX2 = x2
  2191.     If y2 > qY2 Then qY2 = y2
  2192.  
  2193. End Sub
  2194.  
  2195. Sub ReDisplayScreen (ByVal x1%, ByVal y1%, ByVal x2%, ByVal y2%)
  2196.     Dim i%, j%, Y%, attr%, Color%, start%, count%, lineLen%, matches%, remain%
  2197.  
  2198.     If y1 < visibleArea.top Then y1 = visibleArea.top
  2199.     If y2 > visibleArea.bottom Then y2 = visibleArea.bottom
  2200.  
  2201.     partialScrnUpdate = False
  2202.     attr = curAttr
  2203.     Color = curColor
  2204.  
  2205.     lineLen = x2 - x1 + 1
  2206.     
  2207.     For i = y2 To y1 Step -1
  2208.     MoveCursor x1, i
  2209.     Y = sdI(i)
  2210.     start = x1 + 1
  2211.     remain = lineLen
  2212.     Do While (remain > 0)
  2213.         matches = MatchCount(Mid(scrnAttr(Y), start, remain), Mid(scrnColor(Y), start, remain), Chr$(attr), Chr$(Color), remain)
  2214.         Scrn.Print Mid(scrnData(Y), start, matches);
  2215.         
  2216.         remain = remain - matches
  2217.         If remain > 0 Then
  2218.         start = start + matches
  2219.         attr = Asc(Mid(scrnAttr(Y), start, 1))
  2220.         Color = Asc(Mid(scrnColor(Y), start, 1))
  2221.         SetAttributes attr, Color
  2222.         End If
  2223.     Loop
  2224.     Next i
  2225.  
  2226.     If visibleArea.bottom < margin.bottom Then
  2227.     qY1 = visibleArea.bottom
  2228.     Else
  2229.     qY1 = margin.bottom
  2230.     End If
  2231.  
  2232.     qX2 = 0
  2233.     If visibleArea.top > margin.top Then
  2234.     qY2 = visibleArea.top
  2235.     Else
  2236.     qY2 = 0
  2237.     End If
  2238.  
  2239.     SetAttributes curAttr, curColor
  2240.     MoveCursor curX, curY
  2241.     If textCursorOn Then SetCursorOn
  2242.  
  2243. End Sub
  2244.  
  2245. Sub ResetMargins ()
  2246.     Dim dummyInt%
  2247.  
  2248.     If rollCnt <> 0 Then
  2249.     rollCnt = 0
  2250.     QScreenUpdate margin.left, margin.top, margin.right, margin.bottom
  2251.     End If
  2252.  
  2253.     margin.top = LiveMinRow
  2254.     margin.bottom = LiveMaxRow
  2255.     margin.left = LiveMinCol
  2256.     margin.right = LiveMaxCol
  2257.  
  2258.     windowWidth = CharsPerRow
  2259.  
  2260.     SetClipRegion
  2261.  
  2262. End Sub
  2263.  
  2264. Sub RollDown (ByVal topLine As Integer, ByVal bottomLine As Integer)
  2265.     Dim i%, j%, temp%, dummyInt%
  2266.  
  2267.     If (margin.left = 0) And (margin.right = MaxColumn) Then
  2268.     temp = sdI(bottomLine)
  2269.     For i = bottomLine To topLine + 1 Step -1
  2270.         sdI(i) = sdI(i - 1)
  2271.     Next i
  2272.     sdI(topLine) = temp
  2273.     scrnData(temp) = blankLine
  2274.     scrnAttr(temp) = String(CharsPerRow, curAttr)
  2275.     scrnColor(temp) = String(CharsPerRow, curColor)
  2276.     Else
  2277.     For j = bottomLine To topLine + 1 Step -1
  2278.         i = sdI(j)
  2279.         Mid(scrnData(i), margin.left + 1, windowWidth) = Mid(scrnData(sdI(j - 1)), margin.left + 1, windowWidth)
  2280.         Mid(scrnAttr(i), margin.left + 1, windowWidth) = Mid(scrnAttr(sdI(j - 1)), margin.left + 1, windowWidth)
  2281.         Mid(scrnColor(i), margin.left + 1, windowWidth) = Mid(scrnColor(sdI(j - 1)), margin.left + 1, windowWidth)
  2282.     Next j
  2283.     Mid(scrnData(sdI(topLine)), margin.left + 1, windowWidth) = Left(blankLine, windowWidth)
  2284.     Mid(scrnAttr(sdI(topLine)), margin.left + 1, windowWidth) = String(windowWidth, curAttr)
  2285.     Mid(scrnColor(sdI(topLine)), margin.left + 1, windowWidth) = String(windowWidth, curColor)
  2286.     End If
  2287.  
  2288.     Select Case rollStyle
  2289.     Case BUFFERED
  2290.         QScreenUpdate margin.left, topLine, margin.right, bottomLine
  2291.     Case IMMEDIATE
  2292.         If topLine = margin.top Then
  2293.         dummyInt = ScrollDC(Scrn.hDC, 0, pixelHeight, lprcScroll, liveClip, hRgnUpdate, lprcUpdate)
  2294.         QScreenUpdate margin.left, topLine, margin.right, qY2 + 1
  2295.         Else
  2296.         QScreenUpdate margin.left, topLine, margin.right, bottomLine
  2297.         End If
  2298.     Case SMART
  2299.         If topLine = margin.top Then
  2300.         If rollCnt <= 0 Then
  2301.             QScreenUpdate margin.left, topLine, margin.right, qY2 + 1
  2302.         End If
  2303.         rollCnt = rollCnt - 1
  2304.         Else
  2305.         If rollCnt = 0 Then
  2306.             QScreenUpdate margin.left, topLine, margin.right, bottomLine
  2307.         Else
  2308.             rollCnt = 0
  2309.             QScreenUpdate margin.left, margin.top, margin.right, margin.bottom
  2310.         End If
  2311.         End If
  2312.     End Select
  2313.  
  2314. End Sub
  2315.  
  2316. Sub RollUp (ByVal topLine As Integer, ByVal bottomLine As Integer)
  2317.     Dim i%, j%, temp%, dummyInt%
  2318.  
  2319.     If (margin.left = 0) And (margin.right = MaxColumn) Then
  2320.     If topLine = 0 Then topLine = MinRow
  2321.     temp = sdI(topLine)
  2322.     For i = topLine + 1 To bottomLine
  2323.         sdI(i - 1) = sdI(i)
  2324.     Next i
  2325.     sdI(bottomLine) = temp
  2326.     scrnData(temp) = blankLine
  2327.     scrnAttr(temp) = String(CharsPerRow, curAttr)
  2328.     scrnColor(temp) = String(CharsPerRow, curColor)
  2329.     Else
  2330.     For j = topLine + 1 To bottomLine
  2331.         i = sdI(j - 1)
  2332.         Mid(scrnData(i), margin.left + 1, windowWidth) = Mid(scrnData(sdI(j)), margin.left + 1, windowWidth)
  2333.         Mid(scrnAttr(i), margin.left + 1, windowWidth) = Mid(scrnAttr(sdI(j)), margin.left + 1, windowWidth)
  2334.         Mid(scrnColor(i), margin.left + 1, windowWidth) = Mid(scrnColor(sdI(j)), margin.left + 1, windowWidth)
  2335.     Next j
  2336.     Mid(scrnData(sdI(bottomLine)), margin.left + 1, windowWidth) = Left(blankLine, windowWidth)
  2337.     Mid(scrnAttr(sdI(bottomLine)), margin.left + 1, windowWidth) = String(windowWidth, curAttr)
  2338.     Mid(scrnColor(sdI(bottomLine)), margin.left + 1, windowWidth) = String(windowWidth, curColor)
  2339.     End If
  2340.  
  2341.     Select Case rollStyle
  2342.     Case BUFFERED
  2343.         QScreenUpdate margin.left, topLine, margin.right, bottomLine
  2344.     Case IMMEDIATE
  2345.         If (topLine = MinRow) Or (topLine = margin.top) Then
  2346.         dummyInt = ScrollDC(Scrn.hDC, 0, -pixelHeight, lprcScroll, fullClip, hRgnUpdate, lprcUpdate)
  2347.         QScreenUpdate margin.left, qY1 - 1, margin.right, bottomLine
  2348.         Else
  2349.         QScreenUpdate margin.left, topLine, margin.right, bottomLine
  2350.         End If
  2351.     Case SMART
  2352.         If (topLine = MinRow) Or (topLine = margin.top) Then
  2353.         If rollCnt >= 0 Then
  2354.             QScreenUpdate margin.left, qY1 - 1, margin.right, bottomLine
  2355.         End If
  2356.         rollCnt = rollCnt + 1
  2357.         Else
  2358.         If rollCnt = 0 Then
  2359.             QScreenUpdate margin.left, topLine, margin.right, bottomLine
  2360.         Else
  2361.             rollCnt = 0
  2362.             QScreenUpdate margin.left, margin.top, margin.right, margin.bottom
  2363.         End If
  2364.         End If
  2365.     End Select
  2366.  
  2367. End Sub
  2368.  
  2369. Sub SaveToFile (iniFile$)
  2370.     Dim rv%
  2371.  
  2372.     rv = WritePrivateProfileString(Key_Async, Appl_CommPort, Str$(curCommPort), iniFile)
  2373.     rv = WritePrivateProfileString(Key_Async, Appl_HandShake, Str$(curHandShake), iniFile)
  2374.     rv = WritePrivateProfileString(Key_Async, Appl_BaudRate, curBaudRate, iniFile)
  2375.     rv = WritePrivateProfileString(Key_Async, Appl_Parity, curParity, iniFile)
  2376.     rv = WritePrivateProfileString(Key_Async, Appl_Databits, curDataBits, iniFile)
  2377.     rv = WritePrivateProfileString(Key_Async, Appl_Stopbits, curStopBits, iniFile)
  2378.     rv = WritePrivateProfileString(Key_Async, Appl_OutBufSize, Str$(asyncOutBufSize), iniFile)
  2379.     rv = WritePrivateProfileString(Key_Async, Appl_InBufSize, Str$(asyncInBufSize), iniFile)
  2380.     rv = WritePrivateProfileString(Key_Async, Appl_Interval, Str$(asyncPollInterval), iniFile)
  2381.  
  2382.     rv = WritePrivateProfileString(Key_Pref, Appl_ForeColor, Str$(normalFgColor), iniFile)
  2383.     rv = WritePrivateProfileString(Key_Pref, Appl_BackColor, Str$(normalBgColor), iniFile)
  2384.     rv = WritePrivateProfileString(Key_Pref, Appl_HiColor, Str$(normalHiColor), iniFile)
  2385.     rv = WritePrivateProfileString(Key_Pref, Appl_CursorColor, Str$(cursorColor), iniFile)
  2386.     rv = WritePrivateProfileString(Key_Pref, Appl_SelTxtFgColor, Str$(selTextFgColor), iniFile)
  2387.     rv = WritePrivateProfileString(Key_Pref, Appl_SelTxtBgColor, Str$(selTextBgColor), iniFile)
  2388.  
  2389.     rv = WritePrivateProfileString(Key_Pref, Appl_Font, Scrn.FontName, iniFile)
  2390.     rv = WritePrivateProfileString(Key_Pref, Appl_FontSize, Str$(Scrn.FontSize), iniFile)
  2391.     rv = WritePrivateProfileString(Key_Pref, Appl_LineSpacing, Str$(lineSpacing), iniFile)
  2392.     rv = WritePrivateProfileString(Key_Pref, Appl_CursorBlink, Str$(cursorBlinkTimer.Interval \ 100), iniFile)
  2393.     rv = WritePrivateProfileString(Key_Pref, Appl_RollStyle, Str$(rollStyle), iniFile)
  2394.     rv = WritePrivateProfileString(Key_Pref, Appl_MouseStyle, Str$(mouseStyle), iniFile)
  2395.     rv = WritePrivateProfileString(Key_Pref, Appl_PrtFontName, prtFontName, iniFile)
  2396.     rv = WritePrivateProfileString(Key_Pref, Appl_PrtFontSize, Str$(prtFontSize), iniFile)
  2397.  
  2398.     rv = WritePrivateProfileString(Key_Notes, Appl_ConnectType, Str$(curConnectType), iniFile)
  2399.     rv = WritePrivateProfileString(Key_Notes, Appl_AutoConnect, Str$(connectAtStartup), iniFile)
  2400.     rv = WritePrivateProfileString(Key_Notes, Appl_Top, Str$(initTop), iniFile)
  2401.     rv = WritePrivateProfileString(Key_Notes, Appl_Left, Str$(initLeft), iniFile)
  2402.     rv = WritePrivateProfileString(Key_Notes, Appl_Width, Str$(initWidth), iniFile)
  2403.     rv = WritePrivateProfileString(Key_Notes, Appl_Height, Str$(initHeight), iniFile)
  2404.  
  2405. End Sub
  2406.  
  2407. Sub Scrn_Click ()
  2408.     Dim row%, col%, i%, chCode%, xDir%, yDir%, keys$, rowCnt%, colCnt%
  2409.  
  2410.     If lastMouseButton = LEFT_BUTTON Then
  2411.  
  2412.     row = mouseUpY \ (Scrn.TextHeight("M") + lineSpacingExt) + MinRow
  2413.     If row < 0 Then
  2414.         row = 0
  2415.     ElseIf row > MaxRow Then
  2416.         row = MaxRow
  2417.     End If
  2418.     rowCnt = Abs(curY - row)
  2419.     col = mouseUpX \ Scrn.TextWidth("M")
  2420.     If col > MaxColumn Then col = MaxColumn
  2421.     colCnt = Abs(curX - col)
  2422.     
  2423.     If (row = selTextRow1) And (col = selTextCol1) Then
  2424.     
  2425.         Select Case mouseStyle
  2426.     
  2427.         Case MouseMenu
  2428.             chCode = FindUpperCaseChar()
  2429.             If chCode <> 0 Then
  2430.             SendString Chr$(chCode)
  2431.             End If
  2432.     
  2433.         Case MouseEditor
  2434.             If row > curY Then yDir = KEY_DOWN Else yDir = KEY_UP
  2435.             If col > curX Then xDir = KEY_RIGHT Else xDir = KEY_LEFT
  2436.             keys = String(rowCnt, Chr$(yDir))
  2437.             keys = keys & String(colCnt, Chr$(xDir))
  2438.             SendString keys
  2439.     
  2440.         End Select
  2441.     
  2442.     End If
  2443.  
  2444.     End If
  2445.  
  2446. End Sub
  2447.  
  2448. Sub Scrn_DblClick ()
  2449.  
  2450.     If lastMouseButton = LEFT_BUTTON Then
  2451.     Select Case mouseStyle
  2452.         Case MouseMenu
  2453.         SendString Chr$(KEY_RETURN)
  2454.         Case MouseEditor
  2455.     End Select
  2456.     End If
  2457.  
  2458. End Sub
  2459.  
  2460. Sub Scrn_GotFocus ()
  2461.  
  2462.     If connectAtStartup And MSessionConnect.Enabled Then
  2463.     MSessionConnect_Click
  2464.     End If
  2465.  
  2466.     Do
  2467.     DoEvents
  2468.     If LedRX.ForeColor = LedOnColor Then
  2469.         LedRX.ForeColor = LedOffColor
  2470.     End If
  2471.     Loop
  2472.  
  2473. End Sub
  2474.  
  2475. Sub Scrn_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  2476.     
  2477.     mouseState = mouseState Or Button
  2478.     If mouseState = (LEFT_BUTTON Or RIGHT_BUTTON) Then
  2479.     Button = MIDDLE_BUTTON
  2480.     End If
  2481.     lastMouseButton = Button
  2482.  
  2483.     If mouseStyle <> MouseOff Then
  2484.  
  2485.     If X < 0 Then mouseDwnX = 0 Else mouseDwnX = X
  2486.     If Y < 0 Then mouseDwnY = 0 Else mouseDwnY = Y
  2487.  
  2488.     If Button = LEFT_BUTTON Then
  2489.  
  2490.         If MEditCopy.Enabled Then MEditUnselect_Click
  2491.         selTextRow1 = mouseDwnY \ (Scrn.TextHeight("M") + lineSpacingExt) + MinRow
  2492.         If selTextRow1 < MinRow Then
  2493.         selTextRow1 = MinRow
  2494.         ElseIf selTextRow1 > MaxRow Then
  2495.         selTextRow1 = MaxRow
  2496.         End If
  2497.         selTextLastRow = selTextRow1
  2498.  
  2499.         selTextCol1 = mouseDwnX \ Scrn.TextWidth("M")
  2500.         If selTextCol1 > MaxColumn Then selTextCol1 = MaxColumn
  2501.         selTextLastCol = selTextCol1
  2502.  
  2503.     End If
  2504.  
  2505.     End If
  2506.  
  2507. End Sub
  2508.  
  2509. Sub Scrn_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
  2510.     Dim row2%, col2%, deltaX%, deltaY%, rowIndex%
  2511.     Dim savedBgColor&, savedFgColor&, dummyColor&
  2512.  
  2513.     If (mouseStyle <> MouseOff) And (Button = LEFT_BUTTON) Then
  2514.     row2 = Y \ (Scrn.TextHeight("M") + lineSpacingExt) + MinRow
  2515.     If row2 < MinRow Then
  2516.         row2 = MinRow
  2517.     ElseIf row2 > MaxRow Then
  2518.         row2 = MaxRow
  2519.     End If
  2520.     If row2 < selTextRow1 Then selTextRow1 = row2
  2521.  
  2522.     col2 = X \ Scrn.TextWidth("M")
  2523.     If col2 < 0 Then
  2524.         col2 = 0
  2525.     ElseIf col2 > MaxColumn Then
  2526.         col2 = MaxColumn
  2527.     End If
  2528.     If col2 < selTextCol1 Then selTextCol1 = col2
  2529.  
  2530.     If (row2 <> selTextLastRow) Or (col2 <> selTextLastCol) Then
  2531.         MEditCopy.Enabled = True
  2532.         textSelected = True
  2533.         savedBgColor = SetBkColor(Scrn.hDC, selTextBgColor)
  2534.         savedFgColor = SetTextColor(Scrn.hDC, selTextFgColor)
  2535.         If col2 > selTextLastCol Then
  2536.         deltaX = col2 - selTextLastCol + 1
  2537.         For rowIndex = selTextRow1 To row2
  2538.             MoveCursor selTextLastCol, rowIndex
  2539.             Scrn.Print Mid(scrnData(sdI(rowIndex)), selTextLastCol + 1, deltaX);
  2540.         Next rowIndex
  2541.         selTextLastCol = col2
  2542.         ElseIf col2 < selTextLastCol Then
  2543.         dummyColor = SetBkColor(Scrn.hDC, savedBgColor)
  2544.         dummyColor = SetTextColor(Scrn.hDC, savedFgColor)
  2545.         ReDisplayScreen col2 + 1, selTextRow1, selTextLastCol, selTextLastRow
  2546.         dummyColor = SetBkColor(Scrn.hDC, selTextBgColor)
  2547.         dummyColor = SetTextColor(Scrn.hDC, selTextFgColor)
  2548.         selTextLastCol = col2
  2549.         End If
  2550.         If row2 > selTextLastRow Then
  2551.         deltaX = Abs(col2 - selTextCol1) + 1
  2552.         For rowIndex = selTextLastRow To row2
  2553.             MoveCursor selTextCol1, rowIndex
  2554.             Scrn.Print Mid(scrnData(sdI(rowIndex)), selTextCol1 + 1, deltaX);
  2555.         Next rowIndex
  2556.         selTextLastRow = row2
  2557.         ElseIf row2 < selTextLastRow Then
  2558.         dummyColor = SetBkColor(Scrn.hDC, savedBgColor)
  2559.         dummyColor = SetTextColor(Scrn.hDC, savedFgColor)
  2560.         ReDisplayScreen selTextCol1, row2 + 1, selTextLastCol, selTextLastRow
  2561.         dummyColor = SetBkColor(Scrn.hDC, selTextBgColor)
  2562.         dummyColor = SetTextColor(Scrn.hDC, selTextFgColor)
  2563.         selTextLastRow = row2
  2564.         End If
  2565.         dummyColor = SetBkColor(Scrn.hDC, savedBgColor)
  2566.         dummyColor = SetTextColor(Scrn.hDC, savedFgColor)
  2567.         MoveCursor curX, curY
  2568.     End If
  2569.     End If
  2570.  
  2571. End Sub
  2572.  
  2573. Sub Scrn_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  2574.  
  2575.     If (mouseState And Button) <> 0 Then
  2576.     mouseState = mouseState Xor Button
  2577.     End If
  2578.     If lastMouseButton = MIDDLE_BUTTON Then
  2579.     If mouseState = 0 Then
  2580.         lastMouseButton = 0
  2581.         Button = MIDDLE_BUTTON
  2582.     Else
  2583.         Button = 0
  2584.     End If
  2585.     End If
  2586.  
  2587.     If mouseStyle <> MouseOff Then
  2588.  
  2589.     If X < 0 Then mouseUpX = 0 Else mouseUpX = X
  2590.     If Y < 0 Then mouseUpY = 0 Else mouseUpY = Y
  2591.  
  2592.     Select Case Button
  2593.  
  2594.         Case MIDDLE_BUTTON
  2595.  
  2596.         Case RIGHT_BUTTON
  2597.         Select Case mouseStyle
  2598.             Case MouseMenu
  2599.             mouseStyle = MouseEditor
  2600.             Scrn.MousePointer = IBEAM
  2601.             Case MouseEditor
  2602.             mouseStyle = MouseMenu
  2603.             Scrn.MousePointer = DEFAULT
  2604.             Case Else
  2605.             mouseStyle = MouseOff
  2606.             Scrn.MousePointer = NO_DROP
  2607.         End Select
  2608.  
  2609.     End Select
  2610.  
  2611.     End If
  2612.  
  2613. End Sub
  2614.  
  2615. Sub Scrn_Paint ()
  2616.  
  2617.     ReDisplayScreen MinColumn, MinRow, MaxColumn, MaxRow
  2618.  
  2619. End Sub
  2620.  
  2621. Sub SendString (s As String)
  2622.  
  2623.     Select Case curConnectType
  2624.  
  2625.     Case CT_Async
  2626.         If CommPort.PortOpen Then
  2627.         If CommPort.OutBufferCount > 0 Then
  2628.             queueTxData = queueTxData & s
  2629.         Else
  2630.             LedTX.ForeColor = LedOnColor
  2631.             CommPort.Output = queueTxData & s
  2632.             queueTxData = ""
  2633.             If CommPort.OutBufferCount <= 1 Then
  2634.             LedTX.ForeColor = LedOffColor
  2635.             End If
  2636.         End If
  2637.         End If
  2638.  
  2639.     End Select
  2640.  
  2641. End Sub
  2642.  
  2643. Sub SetAttributes (ByVal attr%, ByVal Color%)
  2644.     Dim dummyColor&, fgColor&, newFgColor&, newBgColor&, newHiColor&
  2645.  
  2646.     If attr And ASysColors Then
  2647.     newFgColor = normalFgColor
  2648.     newBgColor = normalBgColor
  2649.     newHiColor = normalHiColor
  2650.     Else
  2651.     newFgColor = QBColor(Color And &H7)
  2652.     newBgColor = QBColor((Color / Shift4) And &H7)
  2653.     newHiColor = QBColor((Color And &H7) Or &H8)
  2654.     End If
  2655.  
  2656.     If attr And ABold Then
  2657.     fgColor = newHiColor
  2658.     Else
  2659.     fgColor = newFgColor
  2660.     End If
  2661.     If attr And AInverse Then
  2662.     dummyColor = SetTextColor(Scrn.hDC, newBgColor)
  2663.     dummyColor = SetBkColor(Scrn.hDC, fgColor)
  2664.     Else
  2665.     dummyColor = SetTextColor(Scrn.hDC, fgColor)
  2666.     dummyColor = SetBkColor(Scrn.hDC, newBgColor)
  2667.     End If
  2668.     If attr And AUnderline Then
  2669.     Scrn.FontUnderline = True
  2670.     Else
  2671.     Scrn.FontUnderline = False
  2672.     End If
  2673.     If attr And ABlink Then
  2674.     End If
  2675.  
  2676. End Sub
  2677.  
  2678. Sub SetCapturedLineAttr ()
  2679.  
  2680.     Printer.Print localCaptureLine;
  2681.     localCaptureLine = ""
  2682.     Printer.FontBold = ((curAttr And ABold) <> 0)
  2683.     Printer.FontUnderline = ((curAttr And AUnderline) <> 0)
  2684.  
  2685. End Sub
  2686.  
  2687. Sub SetClipRegion ()
  2688.     Dim limitTop%
  2689.  
  2690.     lprcScroll.top = 0
  2691.     lprcScroll.left = 0
  2692.     lprcScroll.bottom = Rows * pixelHeight
  2693.     lprcScroll.right = CharsPerRow * pixelWidth
  2694.  
  2695.     ' Calculate "live area" clip region (for roll down and scrolls)
  2696.     liveClip.top = (margin.top - MinRow) * pixelHeight
  2697.     liveClip.bottom = (margin.bottom - MinRow + 1) * pixelHeight
  2698.     liveClip.left = margin.left * pixelWidth
  2699.     liveClip.right = (margin.right + 1) * pixelWidth
  2700.  
  2701.     ' Calculate "full (live + visible) area" clip region (for roll up)
  2702.     If (margin.top = LiveMinRow) And (visibleArea.top < LiveMinRow) Then
  2703.         limitTop = visibleArea.top
  2704.     Else
  2705.         limitTop = margin.top
  2706.     End If
  2707.     fullClip.top = (limitTop - MinRow) * pixelHeight
  2708.     fullClip.bottom = (margin.bottom - MinRow + 1) * pixelHeight
  2709.     fullClip.left = margin.left * pixelWidth
  2710.     fullClip.right = (margin.right + 1) * pixelWidth
  2711.  
  2712. End Sub
  2713.  
  2714. Sub SetCursorOff ()
  2715.     Dim saveX%
  2716.  
  2717.     saveX = Scrn.CurrentX
  2718.     SetAttributes Asc(Mid(scrnAttr(sdI(curY)), curX + 1, 1)), Asc(Mid(scrnColor(sdI(curY)), curX + 1, 1))
  2719.     Scrn.Print Mid(scrnData(sdI(curY)), curX + 1, 1);
  2720.     SetAttributes curAttr, curColor
  2721.     Scrn.CurrentX = saveX
  2722.  
  2723. End Sub
  2724.  
  2725. Sub SetCursorOn ()
  2726.     Dim saveX%, savedBgColor&, savedFgColor&, dummyColor&
  2727.  
  2728.     saveX = Scrn.CurrentX
  2729.     savedBgColor = SetBkColor(Scrn.hDC, cursorColor)
  2730.     savedFgColor = SetTextColor(Scrn.hDC, normalBgColor)
  2731.     Scrn.Print Mid(scrnData(sdI(curY)), curX + 1, 1);
  2732.     dummyColor = SetBkColor(Scrn.hDC, savedBgColor)
  2733.     dummyColor = SetTextColor(Scrn.hDC, savedFgColor)
  2734.     Scrn.CurrentX = saveX
  2735.  
  2736. End Sub
  2737.  
  2738. Sub SetLRMargins (ByVal byte As Integer)
  2739.     Dim dummyInt%
  2740.  
  2741.     Select Case seqPhase
  2742.     Case 1
  2743.         If rollCnt <> 0 Then
  2744.         rollCnt = 0
  2745.         QScreenUpdate margin.left, margin.top, margin.right, margin.bottom
  2746.         End If
  2747.         margin.left = byte
  2748.     Case 2
  2749.         cmdSeq = 0
  2750.         margin.right = byte
  2751.         If (margin.right > LiveMaxCol) Or (margin.left > margin.right) Then
  2752.         margin.left = 0
  2753.         margin.right = MaxColumn
  2754.         End If
  2755.         windowWidth = margin.right - margin.left + 1
  2756.  
  2757.         SetClipRegion
  2758.  
  2759.     End Select
  2760.  
  2761.     seqPhase = seqPhase + 1
  2762.  
  2763. End Sub
  2764.  
  2765. Sub SetMargins (ByVal byte As Integer)
  2766.     Dim dummyInt%
  2767.  
  2768.     Select Case seqPhase
  2769.     Case 1
  2770.         If rollCnt <> 0 Then
  2771.         rollCnt = 0
  2772.         QScreenUpdate margin.left, margin.top, margin.right, margin.bottom
  2773.         End If
  2774.         margin.top = byte
  2775.     Case 2
  2776.         margin.bottom = byte
  2777.     Case 3
  2778.         margin.left = byte
  2779.     Case 4
  2780.         margin.right = byte
  2781.         cmdSeq = 0
  2782.     End Select
  2783.  
  2784.     If cmdSeq <> 0 Then
  2785.     seqPhase = seqPhase + 1
  2786.     Else
  2787.     If (margin.bottom > MaxRow) Or (margin.top > margin.bottom) Then
  2788.         margin.top = 0
  2789.         margin.bottom = MaxRow
  2790.     End If
  2791.     If (margin.right > LiveMaxCol) Or (margin.left > margin.right) Then
  2792.         margin.left = 0
  2793.         margin.right = MaxColumn
  2794.     End If
  2795.     windowWidth = margin.right - margin.left + 1
  2796.  
  2797.     SetClipRegion
  2798.  
  2799.     End If
  2800.  
  2801. End Sub
  2802.  
  2803. Sub SetTBMargins (ByVal byte As Integer)
  2804.     Dim dummyInt%
  2805.  
  2806.     Select Case seqPhase
  2807.     Case 1
  2808.         If rollCnt <> 0 Then
  2809.         rollCnt = 0
  2810.         QScreenUpdate margin.left, margin.top, margin.right, margin.bottom
  2811.         End If
  2812.         margin.top = byte
  2813.  
  2814.     Case 2
  2815.         cmdSeq = 0
  2816.         margin.bottom = byte
  2817.         If (margin.bottom > MaxRow) Or (margin.top > margin.bottom) Then
  2818.         margin.top = 0
  2819.         margin.bottom = MaxRow
  2820.         End If
  2821.  
  2822.         SetClipRegion
  2823.  
  2824.     End Select
  2825.  
  2826.     seqPhase = seqPhase + 1
  2827.  
  2828. End Sub
  2829.  
  2830. Sub ShowStatus (s As String, isError As Integer)
  2831.  
  2832.     If isError Then
  2833.     StatusPanel.BackColor = QBColor(G_Red)
  2834.     Else
  2835.     StatusPanel.BackColor = QBColor(G_BLACK)
  2836.     End If
  2837.     StatusPanel.Caption = s
  2838.  
  2839. End Sub
  2840.  
  2841. Sub StatusPanel_Click ()
  2842.  
  2843.     ShowStatus "", False
  2844.  
  2845. End Sub
  2846.  
  2847. Sub TPaste_Timer ()
  2848.     Dim c$, burst%
  2849.     
  2850.     For burst = 1 To pasteBurst
  2851.     c = Mid(pasteStr, pasteIndex, 1)
  2852.     SendString c
  2853.     If pasteIndex >= pasteLen Then
  2854.         TPaste.Enabled = False
  2855.         Exit For
  2856.     Else
  2857.         pasteIndex = pasteIndex + 1
  2858.     End If
  2859.     Next burst
  2860.  
  2861. End Sub
  2862.  
  2863. Sub VScrollBar_Change ()
  2864.     
  2865.     Scrn.top = -VScrollBar.Value
  2866.  
  2867.     visibleArea.bottom = MaxRow - (VScrollBar.Max - VScrollBar.Value) \ (Scrn.TextHeight("M") + lineSpacingExt)
  2868.     visibleArea.top = (visibleArea.bottom - (VScrollBar.Height \ (Scrn.TextHeight("M") + lineSpacingExt))) + 1
  2869.     visibleLines = visibleArea.bottom - visibleArea.top + 1
  2870.     ShowStatus visibleLines & " lines from " & Str$(visibleArea.top) & " through " & Trim$(Str$(visibleArea.bottom)) & " are visible", False
  2871.     
  2872.     SetClipRegion
  2873.  
  2874. End Sub
  2875.  
  2876. Sub VScrollBar_GotFocus ()
  2877.  
  2878.     Scrn.SetFocus
  2879.  
  2880. End Sub
  2881.  
  2882.