home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / virtltxt / virtual.frm (.txt) < prev   
Encoding:
Visual Basic Form  |  1994-01-22  |  53.5 KB  |  1,703 lines

  1. VERSION 2.00
  2. Begin Form VirtualText 
  3.    Caption         =   "Virtual Text - (Untitled)"
  4.    ClientHeight    =   5280
  5.    ClientLeft      =   960
  6.    ClientTop       =   1650
  7.    ClientWidth     =   8370
  8.    FontBold        =   0   'False
  9.    FontItalic      =   0   'False
  10.    FontName        =   "Fixedsys"
  11.    FontSize        =   9
  12.    FontStrikethru  =   0   'False
  13.    FontUnderline   =   0   'False
  14.    Height          =   5940
  15.    Left            =   915
  16.    LinkMode        =   1  'Source
  17.    LinkTopic       =   "Form1"
  18.    ScaleHeight     =   36
  19.    ScaleMode       =   3  'Pixel
  20.    ScaleWidth      =   36
  21.    Top             =   1035
  22.    Width           =   8460
  23.    Begin HScrollBar HScroll1 
  24.       Height          =   240
  25.       LargeChange     =   5
  26.       Left            =   0
  27.       Max             =   255
  28.       Min             =   1
  29.       TabIndex        =   3
  30.       TabStop         =   0   'False
  31.       Top             =   6060
  32.       Value           =   1
  33.       Width           =   9600
  34.    End
  35.    Begin Timer Timer1 
  36.       Interval        =   100
  37.       Left            =   8895
  38.       Top             =   540
  39.    End
  40.    Begin SSPanel Panel3D1 
  41.       Align           =   2  'Align Bottom
  42.       BorderWidth     =   1
  43.       FloodColor      =   &H00C0C0C0&
  44.       FloodShowPct    =   0   'False
  45.       Height          =   345
  46.       Left            =   0
  47.       Outline         =   -1  'True
  48.       TabIndex        =   5
  49.       Top             =   4935
  50.       Width           =   8370
  51.       Begin SSPanel pnlMessages2 
  52.          Alignment       =   2  'Left Justify - BOTTOM
  53.          BevelOuter      =   1  'Inset
  54.          BorderWidth     =   1
  55.          Height          =   225
  56.          Left            =   7600
  57.          RoundedCorners  =   0   'False
  58.          TabIndex        =   12
  59.          Top             =   60
  60.          Width           =   735
  61.       End
  62.       Begin SSPanel pnlPageValue 
  63.          Alignment       =   2  'Left Justify - BOTTOM
  64.          BevelOuter      =   1  'Inset
  65.          BorderWidth     =   1
  66.          Height          =   225
  67.          Left            =   3750
  68.          RoundedCorners  =   0   'False
  69.          TabIndex        =   11
  70.          Top             =   60
  71.          Width           =   1275
  72.       End
  73.       Begin SSPanel pnlPageText 
  74.          Alignment       =   2  'Left Justify - BOTTOM
  75.          BevelOuter      =   0  'None
  76.          BorderWidth     =   1
  77.          Caption         =   "Page"
  78.          Height          =   225
  79.          Left            =   3270
  80.          RoundedCorners  =   0   'False
  81.          TabIndex        =   10
  82.          Top             =   45
  83.          Width           =   450
  84.       End
  85.       Begin SSPanel pnlRowValue 
  86.          Alignment       =   2  'Left Justify - BOTTOM
  87.          BevelOuter      =   1  'Inset
  88.          BorderWidth     =   1
  89.          Height          =   225
  90.          Left            =   1635
  91.          RoundedCorners  =   0   'False
  92.          TabIndex        =   9
  93.          Top             =   60
  94.          Width           =   1590
  95.       End
  96.       Begin SSPanel pnlRowText 
  97.          Alignment       =   2  'Left Justify - BOTTOM
  98.          BevelOuter      =   0  'None
  99.          BorderWidth     =   1
  100.          Caption         =   "Row"
  101.          Height          =   225
  102.          Left            =   1215
  103.          RoundedCorners  =   0   'False
  104.          TabIndex        =   8
  105.          Top             =   45
  106.          Width           =   390
  107.       End
  108.       Begin SSPanel pnlColValue 
  109.          Alignment       =   2  'Left Justify - BOTTOM
  110.          BevelOuter      =   1  'Inset
  111.          BorderWidth     =   1
  112.          Height          =   225
  113.          Left            =   450
  114.          RoundedCorners  =   0   'False
  115.          TabIndex        =   7
  116.          Top             =   60
  117.          Width           =   585
  118.       End
  119.       Begin SSPanel pnlColText 
  120.          Alignment       =   2  'Left Justify - BOTTOM
  121.          BevelOuter      =   0  'None
  122.          BorderWidth     =   1
  123.          Caption         =   "Col"
  124.          Height          =   225
  125.          Left            =   135
  126.          RoundedCorners  =   0   'False
  127.          TabIndex        =   6
  128.          Top             =   45
  129.          Width           =   285
  130.       End
  131.       Begin SSPanel pnlMessages 
  132.          Alignment       =   2  'Left Justify - BOTTOM
  133.          BevelOuter      =   1  'Inset
  134.          BorderWidth     =   1
  135.          Height          =   225
  136.          Left            =   5145
  137.          RoundedCorners  =   0   'False
  138.          TabIndex        =   4
  139.          Top             =   60
  140.          Width           =   2350
  141.       End
  142.    End
  143.    Begin CommonDialog CMDialog1 
  144.       Left            =   8880
  145.       Top             =   30
  146.    End
  147.    Begin PictureBox Picture1 
  148.       BackColor       =   &H00808080&
  149.       BorderStyle     =   0  'None
  150.       ClipControls    =   0   'False
  151.       FontBold        =   0   'False
  152.       FontItalic      =   0   'False
  153.       FontName        =   "MS Sans Serif"
  154.       FontSize        =   8.25
  155.       FontStrikethru  =   0   'False
  156.       FontUnderline   =   0   'False
  157.       Height          =   270
  158.       Left            =   9075
  159.       ScaleHeight     =   270
  160.       ScaleWidth      =   330
  161.       TabIndex        =   2
  162.       TabStop         =   0   'False
  163.       Top             =   5430
  164.       Width           =   330
  165.    End
  166.    Begin VScrollBar VScroll1 
  167.       Height          =   5370
  168.       Left            =   9375
  169.       Min             =   1
  170.       TabIndex        =   1
  171.       TabStop         =   0   'False
  172.       Top             =   0
  173.       Value           =   1
  174.       Width           =   270
  175.    End
  176.    Begin TextBox TextArray 
  177.       BackColor       =   &H00C0C0C0&
  178.       BorderStyle     =   0  'None
  179.       FontBold        =   0   'False
  180.       FontItalic      =   0   'False
  181.       FontName        =   "Fixedsys"
  182.       FontSize        =   9
  183.       FontStrikethru  =   0   'False
  184.       FontUnderline   =   0   'False
  185.       Height          =   6030
  186.       Index           =   1
  187.       Left            =   0
  188.       MultiLine       =   -1  'True
  189.       ScrollBars      =   1  'Horizontal
  190.       TabIndex        =   0
  191.       TabStop         =   0   'False
  192.       Top             =   0
  193.       Width           =   30000
  194.    End
  195.    Begin Menu mnuFileTop 
  196.       Caption         =   "&File"
  197.       Begin Menu mnuOpenFile 
  198.          Caption         =   "&Open ..."
  199.          Shortcut        =   ^O
  200.       End
  201.       Begin Menu mnuCloseFile 
  202.          Caption         =   "&Close"
  203.       End
  204.       Begin Menu mnuPrintFile 
  205.          Caption         =   "&Print"
  206.          Shortcut        =   ^P
  207.       End
  208.       Begin Menu mnuPrinterSetup 
  209.          Caption         =   "Printer &Setup..."
  210.       End
  211.       Begin Menu zBar11 
  212.          Caption         =   "-"
  213.       End
  214.       Begin Menu mnuShowInformation 
  215.          Caption         =   "Show &Information"
  216.       End
  217.       Begin Menu zBar10 
  218.          Caption         =   "-"
  219.       End
  220.       Begin Menu mnuExitEditBox 
  221.          Caption         =   "E&xit"
  222.       End
  223.       Begin Menu zBar1 
  224.          Caption         =   "-"
  225.          Visible         =   0   'False
  226.       End
  227.       Begin Menu mnuFileList 
  228.          Caption         =   "&1"
  229.          Index           =   1
  230.          Visible         =   0   'False
  231.       End
  232.       Begin Menu mnuFileList 
  233.          Caption         =   "&2"
  234.          Index           =   2
  235.          Visible         =   0   'False
  236.       End
  237.       Begin Menu mnuFileList 
  238.          Caption         =   "&3"
  239.          Index           =   3
  240.          Visible         =   0   'False
  241.       End
  242.       Begin Menu mnuFileList 
  243.          Caption         =   "&4"
  244.          Index           =   4
  245.          Visible         =   0   'False
  246.       End
  247.       Begin Menu mnuFileList 
  248.          Caption         =   "&5"
  249.          Index           =   5
  250.          Visible         =   0   'False
  251.       End
  252.    End
  253.    Begin Menu mnuEditTop 
  254.       Caption         =   "&Edit"
  255.       Begin Menu mnuCopy 
  256.          Caption         =   "&Copy"
  257.          Shortcut        =   ^C
  258.       End
  259.       Begin Menu zBar12 
  260.          Caption         =   "-"
  261.       End
  262.       Begin Menu mnuSelectAll 
  263.          Caption         =   "Select &All"
  264.       End
  265.    End
  266.    Begin Menu mnuView 
  267.       Caption         =   "&View"
  268.       Begin Menu mnuTextMode 
  269.          Caption         =   "&Text Mode"
  270.          Checked         =   -1  'True
  271.          Shortcut        =   ^T
  272.       End
  273.       Begin Menu mnuHexMode 
  274.          Caption         =   "&Hex Mode"
  275.          Shortcut        =   ^H
  276.       End
  277.    End
  278.    Begin Menu mnuSearchTop 
  279.       Caption         =   "&Search"
  280.       Begin Menu mnuFindText 
  281.          Caption         =   "&Find ..."
  282.          Shortcut        =   ^F
  283.       End
  284.       Begin Menu mnuFindNext 
  285.          Caption         =   "Find &Next"
  286.          Shortcut        =   {F3}
  287.       End
  288.       Begin Menu mnuFindPrevious 
  289.          Caption         =   "Find &Previous"
  290.          Shortcut        =   +{F3}
  291.       End
  292.       Begin Menu zBar6 
  293.          Caption         =   "-"
  294.       End
  295.       Begin Menu mnuGotoLine 
  296.          Caption         =   "&Go to Line..."
  297.          Shortcut        =   ^G
  298.       End
  299.    End
  300.    Begin Menu mnuOptions 
  301.       Caption         =   "&Options"
  302.       Begin Menu mnuShowVerticalScroll 
  303.          Caption         =   "Show &Vertical Scroll"
  304.          Checked         =   -1  'True
  305.       End
  306.       Begin Menu mnuShowHorizontalScroll 
  307.          Caption         =   "Show &Horizontal Scroll"
  308.          Checked         =   -1  'True
  309.       End
  310.       Begin Menu mnuShowStatusBar 
  311.          Caption         =   "Show Status &Bar"
  312.          Checked         =   -1  'True
  313.       End
  314.       Begin Menu zBar7 
  315.          Caption         =   "-"
  316.       End
  317.       Begin Menu mnuExpandTabs 
  318.          Caption         =   "Expand &Tabs"
  319.       End
  320.       Begin Menu mnuVerticalDrag 
  321.          Caption         =   "Vertical &Drag"
  322.       End
  323.       Begin Menu zBar4 
  324.          Caption         =   "-"
  325.       End
  326.       Begin Menu mnuSetFont 
  327.          Caption         =   "Set &Font"
  328.          Begin Menu mnuSetFontScreen 
  329.             Caption         =   "&Screen..."
  330.          End
  331.          Begin Menu mnuSetFontPrinter 
  332.             Caption         =   "&Printer..."
  333.          End
  334.       End
  335.       Begin Menu mnuSetColors 
  336.          Caption         =   "Set &Colors"
  337.          Begin Menu mnuSetBackground 
  338.             Caption         =   "Bac&kground..."
  339.          End
  340.          Begin Menu mnuSetForeground 
  341.             Caption         =   "F&oreground..."
  342.          End
  343.       End
  344.       Begin Menu zBar9 
  345.          Caption         =   "-"
  346.       End
  347.       Begin Menu mnuSaveWindowPosition 
  348.          Caption         =   "Save Window &Position"
  349.       End
  350.       Begin Menu zBar20 
  351.          Caption         =   "-"
  352.       End
  353.       Begin Menu mnuSaveOptions 
  354.          Caption         =   "&Save Options"
  355.       End
  356.    End
  357.    Begin Menu mnuHelpTop 
  358.       Caption         =   "&Help"
  359.       Begin Menu mnuAboutEditBox 
  360.          Caption         =   "&About Virtual Text..."
  361.       End
  362.    End
  363. 'VIRTUAL.FRM: VBC Version
  364. DefInt A-Z
  365. Sub CloseCurrent ()
  366. DisableMenuItems
  367. ' Unload all but first array
  368. If NumArrays > 1 Then
  369.     For X = 2 To NumArrays Step 1
  370.     Unload TextArray(X)
  371.     Next
  372. End If
  373. TextArray(1).Enabled = True
  374. ' Put array 1 back to proper position, may be horizontally scrolled
  375. Dim Posn As RECT
  376. rtn& = SendMessageAsAny(TextArray(1).hWnd, EM_GETRECT, 0, Posn)
  377. Posn.Left = 0
  378. rtn& = SendMessageAsAny(TextArray(1).hWnd, EM_SETRECT, 0, Posn)
  379. TextArray(1).Text = " "
  380. TextArray(1).Enabled = False
  381. Me.Caption = "Virtual Text - (Untitled)"
  382. InitializeVariables
  383. UpdateStatusBar
  384. End Sub
  385. Sub DisableMenuItems ()
  386. ' Disable if no open document
  387. mnuFindText.Enabled = False
  388. mnuFindNext.Enabled = False
  389. mnuFindPrevious.Enabled = False
  390. mnuGoToLine.Enabled = False
  391. mnuCloseFile.Enabled = False
  392. mnuShowInformation.Enabled = False
  393. mnuPrintFile.Enabled = False
  394. mnuCopy.Enabled = False
  395. mnuSelectAll.Enabled = False
  396. End Sub
  397. Sub DragandDrop ()
  398. Totfiles = 0
  399. PM_NOREMOVE = 0
  400. PM_NOYIELD = 2
  401. wRemoveMsg = PM_NOREMOVE Or PM_NOYIELD   'parameters for PeekMessage call
  402. Me.Show
  403. Handle = Me.hWnd
  404. Filenum = -1
  405. DragAcceptFiles Handle, True    'identify form as able to accept d/d messages
  406. 'Do While DoEvents()
  407. Gotone% = False
  408. Do While Gotone% = False And Me.WindowState = 1
  409.     DoEvents
  410.     X = PeekMessage(NewMessage, Handle, 563, 563, wRemoveMsg) 'determine if a d/d message is waiting
  411.     If X <> 0 Then  'if a dd message is waiting
  412.     'calling DragQueryFile with a -1 value for FileNum returns # of files dropped
  413.     NameOfFile = Space$(129)
  414.     X = DragQueryFile(NewMessage.wparam, Filenum, NameOfFile, 128)
  415.     For Counter = 0 To 0 '  X - 1   ' for each file dropped
  416.         'calling with a value greater than -1 returns name of corresponding file
  417.     Y = DragQueryFile(NewMessage.wparam, Counter, NameOfFile, 128)
  418.         'add NameOfFile to List
  419.     Next Counter    'get next file
  420.     Totfiles = Totfiles + X
  421.     Gotone% = True
  422.     'always call dragfinish to release d/d memory buffer
  423.     DragFinish NewMessage.wparam
  424.     End If
  425. If Gotone% = True Then
  426.     MenuSelect = True
  427.     Me.WindowState = 0  'Normal
  428.     Z = InStr(Trim$(NameOfFile), Chr$(0))  'Strip trailing junk
  429.     If Z > 0 Then
  430.     FullFilePath = Mid$(NameOfFile, 1, Z - 1)
  431.     Else
  432.     FullFilePath = LCase$(NameOfFile)
  433.     End If
  434.     OpenFile
  435. End If
  436. End Sub
  437. Sub EnableMenuItems ()
  438. mnuFindText.Enabled = True
  439. mnuFindNext.Enabled = True
  440. mnuFindPrevious.Enabled = True
  441. mnuGoToLine.Enabled = True
  442. mnuCloseFile.Enabled = True
  443. mnuShowInformation.Enabled = True
  444. mnuPrintFile.Enabled = True
  445. ' No copy allowed for now!
  446. 'Copy.Enabled = True
  447. 'SelectAll.Enabled = True
  448. End Sub
  449. Function Exists% (f$)
  450. ' A simplistic file existence check
  451. On Error Resume Next
  452. X& = FileLen(f$)
  453. If X& Then Exists% = True
  454. End Function
  455. Sub ExpandTabs ()
  456. ' Setting TABS about every 4 characters
  457. ReDim tabvals%(7)
  458. tabvals%(0) = 16
  459. tabvals%(1) = 32
  460. tabvals%(2) = 48
  461. tabvals%(3) = 64
  462. tabvals%(4) = 80
  463. tabvals%(5) = 96
  464. tabvals%(6) = 112
  465. tabvals%(7) = 128
  466. For X = 1 To NumArrays
  467.     TextArray(X).Enabled = True
  468.     TextArray(X).SetFocus
  469.     Success& = SendMessageAsAny(TextArray(X).hWnd, EM_SETTABSTOPS, 8, tabvals%(0))
  470.     TextArray(X).Enabled = False
  471.     TextArray(X).Refresh
  472. End Sub
  473. Sub FindLongestLine ()
  474. ' Not used for Hex - that line is always a fixed length.
  475. ' This routine really slows up the load of the document - but to get
  476. ' an accurate Horizontal scroll bar it is needed.
  477. ' Assumes only one byte for a TAB
  478. ' Look for line feed
  479. LF$ = Chr$(10)
  480. Dim X!
  481. Dim Y!
  482. Dim Z!
  483. Z = 1
  484. For X = 1 To MaxBytestoRead
  485.     Y = InStr(X, FL(1).FixedLengthTemp, LF$)
  486.     If Y = 0 Then Exit For  'outta here
  487.     If Y - Z > LongestLine Then
  488.     LongestLine = Y - Z
  489.     End If
  490.     Z = Y
  491.     X = Y + 2  'Start after the carriage return - line feed
  492. End Sub
  493. Sub FindTextString ()
  494. If FindStr = "" Then Exit Sub
  495. If FromTopFlag = True Then
  496.     FromTopFlag = False
  497.     StartArray = 1
  498.     StartLine = 1
  499.     ' Where is the search starting?
  500.     StartArray = Active        ' Array were starting in
  501.     If StartArray = 1 Then
  502.     StartLine = VScroll1.Value + 1
  503.     Else
  504.     StartLine = VScroll1.Value - FixedLines(StartArray - 1) + 1
  505.     End If
  506. End If
  507. SearchLine% = VScroll1.Value
  508. Dim linetoshow%, linelength%
  509. Dim linebuf$
  510. Dim lc%
  511. Dim linechar%
  512. pnlMessages.Caption = "Searching line number"
  513. For X = StartArray To NumArrays
  514.     TextArray(X).Enabled = True
  515.     If X > StartArray Then StartLine = 1      ' When we go to new array start at 1
  516.     BoxLines% = SendMessage(TextArray(X).hWnd, EM_GETLINECOUNT, 0, 0)
  517.     For Y = StartLine To BoxLines% 'Lines in array
  518.     SearchLine% = SearchLine% + 1
  519.     If Right$(Str$(SearchLine%), 1) = "0" Then
  520.     pnlMessages2.Caption = Str$(SearchLine%)
  521.     End If
  522.     linetoshow% = Y
  523.     ' Find out the character offset to the first character
  524.     ' in the specified line
  525.     lchar& = SendMessageBynum(TextArray(X).hWnd, EM_LINEINDEX, linetoshow%, 0&)
  526.     ' Convert from long integer to usage VB integer (signed)
  527.     If lchar& > 32767 Then
  528.     SignedEquivalent% = CInt(lchar& - &H10000)
  529.     Else
  530.     SignedEquivalent% = lchar&
  531.     End If
  532.     ' The character offset is used to determine the length of the line
  533.     ' containing that character.
  534.     lc% = SendMessageBynum(TextArray(X).hWnd, EM_LINELENGTH, SignedEquivalent%, 0&) + 1
  535.     ' Now allocate a string long enough to hold the result
  536.     linebuf$ = String$(lc% + 2, 0)
  537.     Mid$(linebuf$, 1, 1) = Chr$(lc% And &HFF)
  538.     Mid$(linebuf$, 2, 1) = Chr$(lc% / &H100)
  539.     ' Now get the line
  540.     lc% = SendMessageByString(TextArray(X).hWnd, EM_GETLINE, linetoshow%, linebuf$)
  541.     ' linebuf$ Contains the string to look at
  542.     ' FindStr is the string we are looking for
  543.     linebuf1$ = RTrim$(linebuf$)
  544.     If CaseSensitiveFlag = True Then
  545.     i = InStr(1, linebuf1$, FindStr, 0)
  546.     Else
  547.     i = InStr(1, linebuf1$, FindStr, 1)
  548.     End If
  549.     If i > 0 Then  ' Okay we got one
  550.     If X = 1 Then   'This will scroll to proper array and line
  551.     VScroll1.Value = Y
  552.     Else
  553.     VScroll1.Value = FixedLines(X - 1) + Y
  554.     End If
  555.     pnlMessages2.Caption = ""
  556.     Exit Sub
  557.     End If
  558.     Next
  559.     TextArray(X).Enabled = False
  560. ' If we got here - no match.
  561. pnlMessages2.Caption = ""
  562. UpdateStatusBar
  563. Msg$ = "Text string " & FindStr & " not found."
  564. Response = MBoxWarning(Msg$)    ' Get user response.
  565. End Sub
  566. Sub FindTextStringPrev ()
  567. If FindStr = "" Then Exit Sub
  568. ' Where is the search starting?
  569. ' No "From Top" here.
  570. StartArray = Active        ' Array were starting in
  571. If StartArray = 1 Then
  572.     StartLine = VScroll1.Value - 1
  573.     StartLine = VScroll1.Value - FixedLines(StartArray - 1) - 1
  574. End If
  575. Dim linetoshow%, linelength%
  576. Dim linebuf$
  577. Dim lc%
  578. Dim linechar%
  579. SearchLine% = VScroll1.Value
  580. pnlMessages.Caption = "Searching line number"
  581. For X = StartArray To 1 Step -1
  582.     TextArray(X).Enabled = True
  583.     If X < StartArray Then
  584.     BoxLines% = SendMessage(TextArray(X).hWnd, EM_GETLINECOUNT, 0, 0)
  585.     StartLine = BoxLines%
  586.     End If
  587.     For Y = StartLine To 1 Step -1 'Go backwards
  588.     SearchLine% = SearchLine% - 1
  589.     If Right$(Str$(SearchLine%), 1) = "0" Then
  590.     pnlMessages2.Caption = Str$(SearchLine%)
  591.     End If
  592.     linetoshow% = Y
  593.     ' Find out the character offset to the first character
  594.     ' in the specified line
  595.     lchar& = SendMessageBynum(TextArray(X).hWnd, EM_LINEINDEX, linetoshow%, 0&)
  596.     ' Convert from long integer to usage VB integer (signed)
  597.     If lchar& > 32767 Then
  598.     SignedEquivalent% = CInt(lchar& - &H10000)
  599.     Else
  600.     SignedEquivalent% = lchar&
  601.     End If
  602.     ' The character offset is used to determine the length of the line
  603.     ' containing that character.
  604.     lc% = SendMessageBynum(TextArray(X).hWnd, EM_LINELENGTH, SignedEquivalent%, 0&) + 1
  605.     ' Now allocate a string long enough to hold the result
  606.     linebuf$ = String$(lc% + 2, 0)
  607.     Mid$(linebuf$, 1, 1) = Chr$(lc% And &HFF)
  608.     Mid$(linebuf$, 2, 1) = Chr$(lc% / &H100)
  609.     ' Now get the line
  610.     lc% = SendMessageByString(TextArray(X).hWnd, EM_GETLINE, linetoshow%, linebuf$)
  611.     ' linebuf$ Contains the string to look at
  612.     ' FindStr is the string we are looking for
  613.     linebuf1$ = RTrim$(linebuf$)
  614.     If CaseSensitiveFlag = True Then
  615.     i = InStr(1, linebuf1$, FindStr, 0)
  616.     Else
  617.     i = InStr(1, linebuf1$, FindStr, 1)
  618.     End If
  619.     If i > 0 Then  ' Okay we got one
  620.     ' Where are we?  Y is position within text array
  621.     If X = 1 Then   'This will scroll to proper array and line
  622.     VScroll1.Value = Y
  623.     Else
  624.     VScroll1.Value = FixedLines(X - 1) + Y
  625.     End If
  626.     pnlMessages2.Caption = ""
  627.     Exit Sub
  628.     End If
  629.     Next
  630.     TextArray(X).Enabled = False
  631. ' If we got here - no match
  632. pnlMessages2.Caption = ""
  633. UpdateStatusBar
  634. Msg$ = "Text string " & FindStr & " not found."
  635. Response = MBoxWarning(Msg$)    ' Get user response.
  636. End Sub
  637. Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
  638. ' Set KeyAscii to 0 in the form's KeyPress event,
  639. ' and set KeyCode to 0 in the form's KeyDown event.
  640. Select Case KeyCode
  641.     Case KEY_DOWN
  642.     If VScroll1.Value <> VScroll1.Max Then
  643.     If VScroll1.Value + 1 < VScroll1.Max Then
  644.     VScroll1.Value = VScroll1.Value + 1
  645.     Else
  646.     VScroll1.Value = VScroll1.Max
  647.     End If
  648.     End If
  649.     Case KEY_UP
  650.     If VScroll1.Value <> 1 Then
  651.     VScroll1.Value = VScroll1.Value - 1
  652.     End If
  653.     Case KEY_LEFT
  654.     If HScroll1.Value - 5 >= HScroll1.Min Then
  655.     HScroll1.Value = HScroll1.Value - 5
  656.     Else
  657.     HScroll1.Value = HScroll1.Min
  658.     End If
  659.     Case KEY_RIGHT
  660.     If HScroll1.Value + 5 <= HScroll1.Max Then
  661.     HScroll1.Value = HScroll1.Value + 5
  662.     Else
  663.     HScroll1.Value = HScroll1.Max
  664.     End If
  665.     Case KEY_PRIOR  ' Page Up
  666.     If VScroll1.Value > MaxRowsInEditBox Then
  667.     VScroll1.Value = VScroll1.Value + (MaxRowsInEditBox * -1)
  668.     Else
  669.     VScroll1.Value = 1
  670.     End If
  671.     Case KEY_NEXT   ' Page Down
  672.     If VScroll1.Value <> VScroll1.Max Then
  673.     If VScroll1.Value + MaxRowsInEditBox < VScroll1.Max Then
  674.     VScroll1.Value = VScroll1.Value + MaxRowsInEditBox
  675.     Else
  676.     VScroll1.Value = VScroll1.Max
  677.     End If
  678.     End If
  679.     Case KEY_END   ' Bottom
  680.     VScroll1.Value = VScroll1.Max
  681.     Case KEY_HOME  ' Top
  682.     VScroll1.Value = 1
  683.     Case KEY_F3 Or CTRL_MASK  ' Find
  684.     FindTextString
  685. End Select
  686. KeyCode = 0
  687. End Sub
  688. Sub Form_KeyPress (KeyAscii As Integer)
  689. KeyAscii = 0
  690. End Sub
  691. Sub Form_Load ()
  692. InitialLoad = True
  693. MenuSelect = False
  694. KeyPreview = True
  695. Virtual = False
  696. TooBig = False
  697. ScrollEvent = False
  698. InitializeVariables
  699. TextArray(Active).Text = ""
  700. ReDim FL(1 To 1)
  701. ' Get current saved settings
  702. ReadINIFile
  703. InitialLoad = False
  704. Me.Show
  705. DisableMenuItems
  706. 'Don't show the actual text box scrollbar - we use our own
  707. Call ShowScrollBar(TextArray(NumArrays).hWnd, SB_HORZ, 0)
  708. VScroll1.Value = 1
  709. VScroll1.ZOrder 0
  710. ProcessCommandLine
  711. MaxRowsInEditBox% = GetVisibleLines()
  712. End Sub
  713. Sub Form_Resize ()
  714. ' Rearrange controls to fit screen
  715. If InitialLoad = True Then Exit Sub
  716. If Me.ScaleWidth < 200 Or Me.ScaleHeight < 200 Then
  717.     Exit Sub
  718. End If
  719. For X = 1 To NumArrays
  720.     If mnuShowVerticalScroll.Checked = True Then
  721.     TextArray(X).Width = ScaleWidth - VScroll1.Width
  722.     Else
  723.     TextArray(X).Width = ScaleWidth
  724.     End If
  725.     If mnuShowHorizontalScroll.Checked = True Then
  726.     If mnuShowStatusBar.Checked = True Then
  727.     TextArray(X).Height = ScaleHeight - HScroll1.Height - Panel3D1.Height
  728.     Else
  729.     TextArray(X).Height = ScaleHeight - HScroll1.Height
  730.     End If
  731.     Else
  732.     If mnuShowStatusBar.Checked = True Then
  733.     TextArray(X).Height = ScaleHeight - Panel3D1.Height
  734.     Else
  735.     TextArray(X).Height = ScaleHeight
  736.     End If
  737.     End If
  738. 'Vertical Scroll bar
  739. VScroll1.Left = ScaleWidth - VScroll1.Width
  740. If mnuShowHorizontalScroll.Checked = True Then
  741.     If mnuShowStatusBar.Checked = True Then
  742.     VScroll1.Height = ScaleHeight - (HScroll1.Height + Panel3D1.Height)
  743.     Else
  744.     VScroll1.Height = ScaleHeight - HScroll1.Height
  745.     End If
  746.     If mnuShowStatusBar.Checked = True Then
  747.     VScroll1.Height = ScaleHeight - Panel3D1.Height
  748.     Else
  749.     VScroll1.Height = ScaleHeight
  750.     End If
  751. End If
  752. 'Horizontal Scroll bar
  753. If mnuShowVerticalScroll.Checked = True Then
  754.     HScroll1.Width = ScaleWidth - VScroll1.Width
  755.     HScroll1.Width = ScaleWidth
  756. End If
  757. If mnuShowStatusBar.Checked = True Then
  758.     HScroll1.Top = ScaleHeight - (HScroll1.Height + Panel3D1.Height)
  759.     HScroll1.Top = ScaleHeight - HScroll1.Height
  760. End If
  761. 'Picture Box
  762. If mnuShowVerticalScroll.Checked = False Or mnuShowHorizontalScroll.Checked = False Then
  763.     Picture1.Top = Me.Top
  764.     Picture1.Left = VScroll1.Left - 2
  765.     Picture1.Top = VScroll1.Height - 2
  766. '   Picture1.ZOrder 1
  767. End If
  768. MaxRowsInEditBox = GetVisibleLines()
  769. VScroll1.LargeChange = MaxRowsInEditBox
  770. UpdateStatusBar
  771. End Sub
  772. Function GetVisibleLines% ()
  773. ' Determines the number of lines actually visible in the
  774. ' text control.
  775. Dim RC As RECT
  776. Dim hdc%
  777. Dim lfont%, oldfont%
  778. Dim tm As TEXTMETRIC
  779. Dim di%
  780. ' Get the formatting rectangle - this describes the
  781. ' rectangle in the control in which text is placed.
  782. lc% = SendMessageAsAny(TextArray(1).hWnd, EM_GETRECT, 0, RC)
  783. ' Get a handle to the logical font used by the control.
  784. ' The VB font properties are accurately reflected by
  785. ' this logical font.
  786. lfont% = SendMessageBynum(TextArray(1).hWnd, WM_GETFONT, 0, 0&)
  787. ' Get a device context to the text control.
  788. hdc% = GetDC(TextArray(1).hWnd)
  789. ' Select in the logical font to obtain the exact font metrics.
  790. If lfont% <> 0 Then oldfont% = SelectObject(hdc%, lfont%)
  791. di% = GetTextMetrics(hdc%, tm)
  792. ' Select out the logical font
  793. If lfont% <> 0 Then lfont% = SelectObject(hdc%, oldfont%)
  794. ' The lines depends on the formatting rectangle and font height
  795. AveCharWidth% = tm.tmAveCharWidth
  796. HeightOfRow% = tm.tmHeight
  797. MaxRowsInEditBox = (RC.bottom - RC.Top) / tm.tmHeight
  798. GetVisibleLines% = MaxRowsInEditBox
  799. ' Release the device context when done.
  800. di% = ReleaseDC(TextArray(1).hWnd, hdc%)
  801. End Function
  802. Sub HScroll1_Change ()
  803. If TotalLines = 0 Then
  804.     HScroll1.Value = Holdh
  805.     ScrollEvent = False
  806.     Exit Sub
  807. End If
  808. If Holdh = HScroll1.Value Then Exit Sub
  809. Dim rtn&
  810. Dim Posn As RECT
  811. ' How much to scroll dependent on the Average Character Width
  812. ' For a Large change do 5 * Average Character Width
  813. ' For a Small Change do 1 * Average Character Width
  814. HType% = Abs(Holdh - HScroll1.Value)
  815. If Holdh < HScroll1.Value Then
  816.     direction% = -1 * (AveCharWidth * HType%)
  817.     For X = 1 To NumArrays
  818.     rtn& = SendMessageAsAny(TextArray(X).hWnd, EM_GETRECT, 0, Posn)
  819.     Posn.Left = Posn.Left + direction%
  820.     rtn& = SendMessageAsAny(TextArray(X).hWnd, EM_SETRECT, 0, Posn)
  821.     Next
  822.     direction% = (AveCharWidth * HType%)
  823.     For X = 1 To NumArrays
  824.     rtn& = SendMessageAsAny(TextArray(X).hWnd, EM_GETRECT, 0, Posn)
  825.     Posn.Left = Posn.Left + direction%
  826.     rtn& = SendMessageAsAny(TextArray(X).hWnd, EM_SETRECT, 0, Posn)
  827.     Next
  828. End If
  829. Holdh = HScroll1.Value
  830. UpdateStatusBar
  831. End Sub
  832. Sub HScroll1_Scroll ()
  833. ScrollEvent = True
  834. End Sub
  835. Sub InitializeVariables ()
  836. NumArrays = 1
  837. Virtual = False
  838. Active = 1
  839. Holdv = 1
  840. Holdh = 1
  841. HScroll1.Value = 1
  842. VScroll1.Min = 1
  843. VScroll1.Max = 1
  844. VScroll1.Value = 1
  845. TotalLines = 0
  846. SwitchMode = False
  847. End Sub
  848. Sub LoadHexArrays ()
  849. ' Read into temp area
  850. BytesRead& = 0
  851. Dim OneByte As String * 1
  852. NumArrays = 0
  853. ReDim FH(1 To 1)
  854. '*************
  855. ReadLoopHex:
  856. '*************
  857. If TooBig = True Then GoTo ExitReadLoopHex
  858. ManyBytes$ = ""
  859. Get #Filenum, , FH(1).FixedLengthTempHex
  860. ' Did we get an entire record?
  861. If EOF(Filenum) Then
  862.     MoveToHexBox    'move to text and exit
  863.     GoTo ExitReadLoopHex
  864. End If
  865. BytesRead& = BytesRead& + MaxBytesToReadHex
  866. MoveToHexBox
  867. GoTo ReadLoopHex
  868. ExitReadLoopHex:
  869. HScroll1.Max = 75
  870. LongestLine = 75
  871. End Sub
  872. Sub LoadTextArrays ()
  873. ' Read into temp area
  874. ' Read MaxBytesToRead then look for CRLF (do not look for CRLF on last)
  875. Dim OneByte As String * 1
  876. ManyBytes$ = ""
  877. NumArrays = 0
  878. ReDim FL(1 To 1)
  879. EOFFlag = False
  880. LongestLine = 1
  881. '*************
  882. ReadLoop:
  883. '*************
  884. If TooBig = True Then GoTo ExitReadLoop
  885. ManyBytes$ = ""
  886. Get #Filenum, , FL(1).FixedLengthTemp
  887. FindLongestLine
  888. ' Did we get an entire record?
  889. If EOF(Filenum) Then
  890.     EOFFlag = True
  891.     MoveToTextBox    'move to text and exit
  892.     GoTo ExitReadLoop
  893. End If
  894. TwoBytes$ = Right$(FL(1).FixedLengthTemp, 2)
  895. ' See if we have only a CR or only a LF on the end
  896. If Right$(TwoBytes$, 1) = Chr$(10) Then ' Remove last 2
  897.     Mid$(FL(1).FixedLengthTemp, (MaxBytestoRead - 1), 2) = "  "
  898.     MoveToTextBox
  899.     GoTo ReadLoop
  900.     If Right$(TwoBytes$, 1) = Chr$(13) Then ' Remove last 1, skip 1
  901.     Mid$(FL(1).FixedLengthTemp, MaxBytestoRead, 1) = " "
  902.     Seek #Filenum, Seek(Filenum) + 1 'skip LF
  903.     MoveToTextBox
  904.     GoTo ReadLoop
  905.     End If
  906. End If
  907. 'When we go from one array to the next we do not want split lines!
  908. For Y = 0 To 254  'Lets get a complete line
  909.     Get #Filenum, , OneByte$
  910.     If EOF(Filenum) Then
  911.     MoveToTextBox    'move to text and exit
  912.     GoTo ExitReadLoop
  913.     End If
  914.     If OneByte$ = Chr$(13) Then
  915.     Seek #Filenum, Seek(Filenum) + 1
  916.     MoveToTextBox    'move to text and exit
  917.     GoTo ReadLoop
  918.     Exit For
  919.     Else
  920.     ManyBytes$ = ManyBytes$ + OneByte$
  921.     End If
  922. MoveToTextBox
  923. GoTo ReadLoop
  924. ExitReadLoop:
  925. HScroll1.Max = LongestLine - 2
  926. End Sub
  927. Function MBoxStop (Msg$)
  928. MTitle$ = "Virtual Text"
  929. DgDef = MB_YESNO + MB_ICONSTOP + MB_DEFBUTTON2 ' Describe dialog.
  930. MBoxStop = MsgBox(Msg$, DgDef, MTitle$)    ' Get user response.
  931. End Function
  932. Function MBoxWarning (Msg$)
  933. MTitle$ = "Virtual Text"
  934. DgDef = MB_OK + MB_ICONEXCLAMATION  ' Describe dialog.
  935. MBoxWarning = MsgBox(Msg$, DgDef, MTitle$)    ' Get user response.
  936. End Function
  937. Sub mnuAboutEditBox_Click ()
  938.    About.Show MODAL
  939. End Sub
  940. Sub mnuCloseFile_Click ()
  941. CloseCurrent
  942. FullFilePath = ""
  943. End Sub
  944. Sub mnuCopy_Click ()
  945. ' Not in use !
  946. End Sub
  947. Sub mnuExitEditBox_Click ()
  948.   Unload Me
  949. End Sub
  950. Sub mnuExpandTabs_Click ()
  951. If mnuExpandTabs.Checked = True Then
  952.     mnuExpandTabs.Checked = False
  953.     ReDim tabvals%(7)  ' Using 0 does not seem to work for the array values
  954.     tabvals%(0) = 1
  955.     tabvals%(1) = 2
  956.     tabvals%(2) = 3
  957.     tabvals%(3) = 4
  958.     tabvals%(4) = 5
  959.     tabvals%(5) = 6
  960.     tabvals%(6) = 7
  961.     tabvals%(7) = 8
  962.     For X = 1 To NumArrays
  963.     TextArray(X).Enabled = True
  964.     TextArray(X).SetFocus
  965.     Success& = SendMessageAsAny(TextArray(X).hWnd, EM_SETTABSTOPS, 8, tabvals%(0))
  966.     TextArray(X).Enabled = False
  967.     TextArray(X).Refresh
  968.     Next
  969.     mnuExpandTabs.Checked = True
  970.     ' Perform routine
  971.     ExpandTabs
  972. End If
  973. End Sub
  974. Sub mnuFileList_Click (Index As Integer)
  975. FullFilePath = Mid$(mnuFileList(Index).Caption, 4)
  976. MenuSelect = True
  977. OpenFile
  978. End Sub
  979. Sub mnuFindNext_Click ()
  980. FindTextString
  981. End Sub
  982. Sub mnuFindPrevious_Click ()
  983. FindTextStringPrev
  984. End Sub
  985. Sub mnuFindText_Click ()
  986. Search.lblTo.Caption = "Enter text to search for:"
  987. Search.Show 1
  988. ' What if Canceled?
  989. If FindStr = "" Then Exit Sub
  990. FindTextString
  991. End Sub
  992. Sub mnuGotoLine_Click ()
  993. Search.lblTo.Caption = "Enter Line number to go to:"
  994. Search.FromTop.Visible = False
  995. Search.CaseSensitive.Visible = False
  996. Search.Check3D1.Visible = False
  997. Search.Check3D2.Visible = False
  998. Search.Show 1
  999. GoToLineNumber = Val(FindStr)
  1000. If GoToLineNumber > 0 And GoToLineNumber <= TotalLines Then
  1001.     VScroll1.Value = GoToLineNumber
  1002. End If
  1003. FindStr = ""
  1004. End Sub
  1005. Sub mnuHexMode_Click ()
  1006. If mnuHexMode.Checked = True Then Exit Sub
  1007. mnuHexMode.Checked = True
  1008. mnuTextMode.Checked = False
  1009. If TotalLines = 0 Then Exit Sub
  1010. SwitchMode = True
  1011. MenuSelect = True
  1012. OpenFile
  1013. End Sub
  1014. Sub mnuOpenFile_Click ()
  1015. OpenFile
  1016. End Sub
  1017. Sub mnuPrinterSetup_Click ()
  1018. On Error GoTo ErrorHandlerPS
  1019. CMDialog1.Flags = &H40&
  1020. CMDialog1.CancelError = True
  1021. CMDialog1.Action = 5
  1022. Exit Sub
  1023. ErrorHandlerPS:
  1024. Resume ErrorResumePS
  1025. ErrorResumePS:
  1026. End Sub
  1027. Sub mnuPrintFile_Click ()
  1028. On Error GoTo ErrorHandler1
  1029. 'CMDialog1.Flags = CF_PRINTERFONTS
  1030. 'CMDialog1.CancelError = True
  1031. 'CMDialog1.Action = 4
  1032. PrintFile1
  1033. Exit Sub
  1034. ErrorHandler1:
  1035. Resume ErrorResume
  1036. ErrorResume:
  1037. End Sub
  1038. Sub mnuSaveOptions_Click ()
  1039. SaveOptions
  1040. End Sub
  1041. Sub mnuSaveWindowPosition_Click ()
  1042. SaveFormPosition
  1043. End Sub
  1044. Sub mnuSetBackground_Click ()
  1045. On Error GoTo SetBackgroundError:
  1046.     CMDialog1.Color = BackColor
  1047.     CMDialog1.CancelError = True
  1048.     CMDialog1.Flags = CC_PREVENTFULLOPEN  'Or CC_SHOWHELP CC_RGBINIT
  1049.     CMDialog1.Action = 3
  1050.     BackColor = CMDialog1.Color
  1051.     For X = 1 To NumArrays
  1052.     TextArray(X).BackColor = BackColor
  1053.     Next
  1054. SetBackgroundError:
  1055.     Resume SetBackgroundError_Cont
  1056. SetBackgroundError_Cont:
  1057. End Sub
  1058. Sub mnuSetFontPrinter_Click ()
  1059. On Error GoTo Printer_Font_Error
  1060.     CMDialog1.Flags = CF_PRINTERFONTS 'CF_BOTH ' Or CF_ANSIONLY
  1061.     CMDialog1.CancelError = True
  1062.     CMDialog1.FontName = optPrinterFont
  1063.     CMDialog1.FontSize = optPrinterFontSize
  1064.     CMDialog1.FontBold = optPrinterFontBold
  1065.     CMDialog1.FontItalic = optPrinterFontItalic
  1066.     CMDialog1.Action = 4
  1067.     optPrinterFont = CMDialog1.FontName
  1068.     optPrinterFontSize = CMDialog1.FontSize
  1069.     optPrinterFontBold = CMDialog1.FontBold
  1070.     optPrinterFontItalic = CMDialog1.FontItalic
  1071. Printer_Font_Error:
  1072.     Resume Printer_Font_Error_Cont
  1073. Printer_Font_Error_Cont:
  1074. End Sub
  1075. Sub mnuSetFontScreen_Click ()
  1076. On Error GoTo Screen_Font_Error
  1077.     CMDialog1.Flags = CF_SCREENFONTS 'CF_BOTH ' Or CF_ANSIONLY
  1078.     CMDialog1.CancelError = True
  1079.     CMDialog1.FontName = TextArray(Active).FontName
  1080.     CMDialog1.FontSize = TextArray(Active).FontSize
  1081.     CMDialog1.FontBold = TextArray(Active).FontBold
  1082.     CMDialog1.FontItalic = TextArray(Active).FontItalic
  1083.     CMDialog1.Action = 4
  1084.     For X = 1 To NumArrays
  1085.     TextArray(X).FontName = CMDialog1.FontName
  1086.     TextArray(X).FontSize = CMDialog1.FontSize
  1087.     TextArray(X).FontBold = CMDialog1.FontBold
  1088.     TextArray(X).FontItalic = CMDialog1.FontItalic
  1089.     Next
  1090.     ' Get the new value for the maximum rows showing in edit box
  1091.     MaxRowsInEditBox% = GetVisibleLines()
  1092.     VerticalDrag
  1093. Screen_Font_Error:
  1094.     Resume Screen_Font_Error_Cont
  1095. Screen_Font_Error_Cont:
  1096. End Sub
  1097. Sub mnuSetForeground_Click ()
  1098. On Error GoTo SetForegroundError:
  1099.     CMDialog1.Color = ForeColor
  1100.     CMDialog1.CancelError = True
  1101.     CMDialog1.Flags = CC_PREVENTFULLOPEN  'Or CC_SHOWHELP CC_RGBINIT
  1102.     CMDialog1.Action = 3
  1103.     ForeColor = CMDialog1.Color
  1104.     For X = 1 To NumArrays
  1105.     TextArray(X).ForeColor = ForeColor
  1106.     Next
  1107. SetForegroundError:
  1108.     Resume SetForegroundError_Cont
  1109. SetForegroundError_Cont:
  1110. End Sub
  1111. Sub mnuShowHorizontalScroll_Click ()
  1112. If mnuShowHorizontalScroll.Checked = True Then
  1113.     mnuShowHorizontalScroll.Checked = False
  1114.     HScroll1.Visible = False
  1115.     mnuShowHorizontalScroll.Checked = True
  1116.     HScroll1.Visible = True
  1117. End If
  1118. Form_Resize
  1119. End Sub
  1120. Sub mnuShowInformation_Click ()
  1121. NL$ = Chr$(13) + Chr$(10)
  1122. Dim Msg1 As String, TimeStamp As String  ' Declare variables.
  1123. FName$ = FullFilePath  ' Get selected file name.
  1124. TimeStamp = FileDateTime(FName$) ' Get file date/time info.
  1125. Msg1 = "File: " & LCase(FName$) & NL$
  1126. Msg1 = Msg1 & "Date: " & Format(TimeStamp, "dddddd") & NL$
  1127. Msg1 = Msg1 & "Time: " & Format(TimeStamp, "h:mm AM/PM") & NL$
  1128. Msg1 = Msg1 & "Size: " & Format(FileLen(FName$), "###,###,###") & " bytes."
  1129. X = MsgBox(Msg1, 64, "Virtual Text")  ' Display message.
  1130. End Sub
  1131. Sub mnuShowStatusBar_Click ()
  1132. If mnuShowStatusBar.Checked = True Then
  1133.     mnuShowStatusBar.Checked = False
  1134.     Panel3D1.Visible = False
  1135.     mnuShowStatusBar.Checked = True
  1136.     Panel3D1.Visible = True
  1137. End If
  1138. Form_Resize
  1139. End Sub
  1140. Sub mnuShowVerticalScroll_Click ()
  1141. If mnuShowVerticalScroll.Checked = True Then
  1142.     mnuShowVerticalScroll.Checked = False
  1143.     VScroll1.Visible = False
  1144.     mnuShowVerticalScroll.Checked = True
  1145.     VScroll1.Visible = True
  1146. End If
  1147. Form_Resize
  1148. End Sub
  1149. Sub mnuTextMode_Click ()
  1150. If mnuTextMode.Checked = True Then Exit Sub
  1151. mnuTextMode.Checked = True
  1152. mnuHexMode.Checked = False
  1153. If TotalLines = 0 Then Exit Sub
  1154. SwitchMode = True
  1155. MenuSelect = True
  1156. OpenFile
  1157. 'Form_Resize
  1158. End Sub
  1159. Sub mnuVerticalDrag_Click ()
  1160. If mnuVerticalDrag.Checked = True Then
  1161.     mnuVerticalDrag.Checked = False
  1162.     mnuVerticalDrag.Checked = True
  1163. End If
  1164. End Sub
  1165. Sub MoveToHexBox ()
  1166. CRLF$ = Chr$(13) + Chr$(10)
  1167. NumArrays = NumArrays + 1
  1168. If NumArrays = 1 Then
  1169.     Hexline = 0
  1170.     VScroll1.LargeChange = GetVisibleLines()
  1171. End If
  1172. ' Load Hex box
  1173. If NumArrays > 1 Then
  1174.     Load TextArray(NumArrays)
  1175.     TextArray(NumArrays).Visible = True
  1176. End If
  1177. ' Let text box hold more lines
  1178. TextArray(NumArrays) = " "
  1179. Me.SetFocus
  1180. TextLimit% = &HFAAA
  1181. RetVal& = SendMessage(TextArray(NumArrays).hWnd, EM_LIMITTEXT, TextLimit%, 0)
  1182. If LOF(Filenum) > (NumArrays * MaxBytesToReadHex) Then  '? full read
  1183.     TotalHexLines& = (MaxBytesToReadHex / 16)  'This will be even
  1184.     If NumArrays = 1 Then
  1185.     TotalHexLines& = (LOF(Filenum) / 16) + 1
  1186.     Else
  1187.     TotalHexLines& = ((LOF(Filenum) - ((NumArrays - 1) * MaxBytesToReadHex)) / 16) + 1
  1188.     End If
  1189. End If
  1190. Dim RCode As Integer
  1191. Dim Pos  As Single
  1192. Dim Handle As Integer
  1193. Dim Selector As Integer
  1194. Dim OffSet As Long
  1195. Dim R As Long
  1196. Dim X As Single
  1197. ' Global allocate enough memory for TotalHexLines
  1198. Handle = GlobalAlloc(GMEM_FIXED, TotalHexLines& * ELEMENT_SIZE)
  1199. ' Display error message if alloction failed.
  1200. If Handle = 0 Then
  1201.     Screen.MousePointer = 0
  1202.     MsgBox "Could not allocate memory"
  1203.     Exit Sub
  1204. End If
  1205. ' Get the selector.
  1206. Selector = GlobalHandleToSel(Handle)
  1207. Pos! = 1
  1208. For X! = 1 To TotalHexLines&  '  TotalHexLines
  1209.     'Get 16 bytes
  1210.     W1$ = Hex$((Hexline + X! - 1) * 16)
  1211.     W2! = Len(W1$)
  1212.     HexAddress$ = " " + String$((6 - W2!), "0") + W1$ + " "
  1213.     String16$ = Mid$(FH(1).FixedLengthTempHex, Pos!, 16)
  1214.     StringT$ = " "
  1215.     For Y! = 1 To 16
  1216.     StringX$ = Hex$(Asc(Mid$(String16$, Y!, 1)))
  1217.     If Len(StringX$) = 1 Then StringX$ = "0" & StringX$
  1218.         If Y! = 8 Then
  1219.         StringT$ = StringT$ + StringX$ + "-"
  1220.         Else
  1221.         StringT$ = StringT$ + StringX$ + " "
  1222.         End If
  1223.     Select Case Mid$(String16$, Y!, 1)
  1224.     Case Is > Chr$(127), Is < Chr$(32)  ' Show "." instead of funny chars
  1225.         Mid$(String16$, Y!, 1) = Chr$(46)
  1226.     End Select
  1227.     Next
  1228.     String48 = StringT$
  1229.     If X! < TotalHexLines& Then
  1230.     Hex77 = HexAddress$ & String48 & "   " & String16$ & CRLF$
  1231.     Else
  1232.     Hex77 = HexAddress$ & String48 & "   " & String16$ & "  "
  1233.     End If
  1234.     OffSet = (X - 1) * ELEMENT_SIZE
  1235.     ' Use global memory, faster ?!
  1236.     R = MemoryWrite(Selector, OffSet, ByVal Hex77, ELEMENT_SIZE)
  1237.     Pos! = Pos! + 16
  1238. Hexline = Hexline + TotalHexLines&
  1239. BigHexBuffer = Space$(30800)
  1240. OffSet = 0
  1241. R = MemoryRead(Selector, OffSet, ByVal BigHexBuffer, TotalHexLines& * ELEMENT_SIZE)
  1242. X = GlobalFree(Handle)
  1243. If Hexline = 400 Then
  1244.     TextArray(NumArrays).Text = BigHexBuffer
  1245.     TextArray(NumArrays).Text = Left$(BigHexBuffer, TotalHexLines& * ELEMENT_SIZE)
  1246. End If
  1247. PctRead$ = Format$(BytesRead / FileLength, "0%")
  1248. pnlMessages.Caption = "Loading File " + PctRead$
  1249. pnlMessages.Refresh
  1250. ReDim Preserve FixedLines(NumArrays)
  1251. BoxLines% = SendMessage(TextArray(NumArrays).hWnd, EM_GETLINECOUNT, 0, 0)
  1252. FixedLines(NumArrays) = BoxLines% + TotalLines
  1253. TotalLines = FixedLines(NumArrays)
  1254. If FixedLines(NumArrays) > MaxLinesAllowed Then
  1255.     Msg$ = "Only " & Str$(MaxLinesAllowed) & " lines allowed, take a partial view?"
  1256.     Response = MBoxStop(Msg$)    ' Get user response.
  1257.     If Response = IDYES Then    ' Evaluate response
  1258.     If NumArrays > 1 Then
  1259.     Unload TextArray(NumArrays)
  1260.     NumArrays = NumArrays - 1
  1261.     End If
  1262.     ReDim Preserve FixedLines(NumArrays)
  1263.     TotalLines = FixedLines(NumArrays)
  1264.     TooBig = True
  1265.     Else    ' action.
  1266.     TooBig = True
  1267.     CloseCurrent
  1268.     Exit Sub
  1269.     End If
  1270. End If
  1271. 'Disable after loading
  1272. Call ShowScrollBar(TextArray(NumArrays).hWnd, SB_HORZ, 0)
  1273. TextArray(NumArrays).Enabled = False
  1274. End Sub
  1275. Sub MoveToTextBox ()
  1276. NumArrays = NumArrays + 1
  1277. If NumArrays = 1 Then
  1278.   VScroll1.LargeChange = MaxRowsInEditBox
  1279.   TextArray(NumArrays).Enabled = True
  1280. ' Load text array
  1281.     Load TextArray(NumArrays)
  1282.     TextArray(NumArrays).Visible = True  ' Will be enabled
  1283. End If
  1284. ' Let text box hold more lines
  1285. TextArray(NumArrays) = " "
  1286. Me.SetFocus
  1287. TextLimit% = &HFAAA
  1288. RetVal& = SendMessage(TextArray(NumArrays).hWnd, EM_LIMITTEXT, TextLimit%, 0)
  1289. 'RetVal& = SendMessage(TextArray(NumArrays).hWnd, EM_SETREADONLY, 1, 0)
  1290. TextArray(NumArrays).Text = FL(1).FixedLengthTemp + ManyBytes$
  1291. PctRead$ = Format$(Seek(Filenum) / FileLength, "0%")
  1292. pnlMessages.Caption = "Loading File " + PctRead$
  1293. pnlMessages.Refresh
  1294. ReDim Preserve FixedLines(NumArrays)
  1295. BoxLines% = SendMessage(TextArray(NumArrays).hWnd, EM_GETLINECOUNT, 0, 0)
  1296. FixedLines(NumArrays) = BoxLines% + TotalLines
  1297. If FixedLines(NumArrays) > MaxLinesAllowed Then
  1298.     Msg$ = "Only " & Str$(MaxLinesAllowed) & " lines allowed, take a partial view?"
  1299.     Response = MBoxStop(Msg$)    ' Get user response.
  1300.     If Response = IDYES Then    ' Evaluate response
  1301.     If NumArrays > 1 Then
  1302.     Unload TextArray(NumArrays)
  1303.     NumArrays = NumArrays - 1
  1304.     End If
  1305.     ReDim Preserve FixedLines(NumArrays)
  1306.     TooBig = True
  1307.     Else    ' action.
  1308.     TooBig = True
  1309.     CloseCurrent
  1310.     Exit Sub
  1311.     End If
  1312. End If
  1313. TotalLines = FixedLines(NumArrays)
  1314. 'Disable after loading
  1315. Call ShowScrollBar(TextArray(NumArrays).hWnd, SB_HORZ, 0)
  1316. TextArray(NumArrays).Enabled = False
  1317. End Sub
  1318. Sub OpenFile ()
  1319. 'If FullFilePath = "" Then Exit Sub
  1320. If SwitchMode = True Then GoTo ByPassOpen
  1321. MaxRowsInEditBox% = GetVisibleLines()
  1322. UserCancel = False
  1323. If MenuSelect = False And CommandLine = False Then  ' Already have file?
  1324.     OpenFileDialogue
  1325.     If UserCancel = True Then Exit Sub
  1326.     MenuSelect = False
  1327.     If Not Exists%(FullFilePath) Then
  1328.     Msg$ = FullFilePath & " - File does not exist."
  1329.     Response = MBoxWarning(Msg$)    ' Get user response.
  1330.     Exit Sub
  1331.     End If
  1332. End If
  1333. ByPassOpen:
  1334. On Error GoTo OpenFileError
  1335. SwitchMode = False
  1336. MenuSelect = False
  1337. CommandLine = False
  1338. TooBig = False
  1339. MousePointer = 11
  1340. Filenum = FreeFile
  1341. CloseCurrent
  1342. Me.Caption = "Virtual Text - " + FullFilePath
  1343. Open FullFilePath For Binary As #Filenum
  1344. FileLength& = LOF(Filenum)
  1345. VarString$ = String$(100, " ")
  1346. Get #Filenum, , VarString$
  1347. If mnuTextMode.Checked = True And ((Not TextFileCheck(VarString$)) Or (FileLength& = 0)) Then
  1348.     MousePointer = 0
  1349.     Msg$ = FullFilePath & " - is not a valid text file, open in HEX mode?"
  1350.     Response = MBoxStop(Msg$)    ' Get user response.
  1351.     If Response = IDNO Then
  1352.     Me.Caption = "Virtual Text - (Untitled)"
  1353.     Close
  1354.     Exit Sub
  1355.     Else
  1356.     MousePointer = 11
  1357.     mnuTextMode.Checked = False
  1358.     mnuHexMode.Checked = True
  1359.     End If
  1360. End If
  1361. Seek #Filenum, 1  'Reset to the beginning of the file
  1362. TextArray(1).Visible = True
  1363. TotalLines = 0
  1364. '   Read and load the text boxes
  1365. If mnuTextMode.Checked = True Then
  1366.     LoadTextArrays
  1367.     LoadHexArrays
  1368. End If
  1369. '   Set the scrollbar ranges
  1370. VScroll1.Min = 1
  1371. If TotalLines > 0 Then
  1372.     VScroll1.Max = TotalLines
  1373.     VScroll1.Max = 1 ' Do not scroll
  1374. End If
  1375. ChangeFileList (FullFilePath)
  1376. UpdateStatusBar
  1377. EnableMenuItems
  1378. Active = 1
  1379. Close #Filenum
  1380. MousePointer = 0
  1381. Exit Sub
  1382. OpenFileError:
  1383. MousePointer = 0
  1384. Msg$ = "Problem opening file - " & Error$(Err)
  1385. Response = MBoxWarning(Msg$)    ' Get user response.
  1386. Resume OpenFileError1
  1387. OpenFileError1:
  1388. End Sub
  1389. Sub OpenFileDialogue ()
  1390. On Error GoTo errhandler
  1391. ' Set filters
  1392. CMDialog1.Filter = "All Files (*.*)|*.*|Text Files (*.txt)|*.txt|Batch Files (*.bat)|*.bat"
  1393. ' Specify default filter
  1394. CMDialog1.FilterIndex = 2
  1395. ' Cancel error ON
  1396. CMDialog1.CancelError = 1
  1397. ' display the File Open dialog
  1398. CMDialog1.Action = 1
  1399. If Not Exists%(LCase$(CMDialog1.Filename)) Then
  1400.     Msg$ = LCase$(CMDialog1.Filename) & " - File does not exist."
  1401.     Response = MBoxWarning(Msg$)    ' Get user response.
  1402.     UserCancel = True
  1403.     Exit Sub
  1404. End If
  1405. FullFilePath = LCase$(CMDialog1.Filename)
  1406. Exit Sub
  1407. errhandler:
  1408. ' user pressed cancel button
  1409. UserCancel = True
  1410. Resume errhandler1
  1411. errhandler1:
  1412. End Sub
  1413. Sub PaneltoTop (TopArray%)
  1414. ' Do not bypass this routine !!!!!!
  1415. Call SetWindowPos(TextArray(TopArray%).hWnd, Panel3D1.hWnd, 0, 0, 0, 0, DONT_REPOS)
  1416. End Sub
  1417. Sub PrintFile1 ()
  1418. CRLF$ = Chr$(13) & Chr$(10)
  1419. On Error GoTo ErrorhandlerP
  1420.     MousePointer = 11
  1421. '   Do printer routine
  1422. Printer.FontName = optPrinterFont
  1423. Printer.FontSize = optPrinterFontSize
  1424. Printer.FontBold = optPrinterFontBold
  1425. Printer.FontItalic = optPrinterFontItalic
  1426. Dim TextLine As String
  1427. f = FreeFile
  1428. Open FullFilePath For Input As #f
  1429. Do While Not EOF(f) ' Check for end of file.
  1430.     Line Input #f, TextLine   ' Read data.
  1431.     Printer.Print TextLine
  1432. Close #f    ' Close file.
  1433. Printer.EndDoc
  1434. MousePointer = 0
  1435. Exit Sub
  1436. ErrorhandlerP:
  1437.     Resume ErrorResume1
  1438. ErrorResume1:
  1439.     MousePointer = 0
  1440.     Msg$ = "There was a problem printing." & CRLF$ & CRLF$ & "Check your Printer."
  1441.     Response = MBoxWarning(Msg$)
  1442.     Exit Sub
  1443. End Sub
  1444. Sub ProcessCommandLine ()
  1445. CommandLine = False
  1446. MousePointer = 11
  1447. On Error GoTo OpenFileError2
  1448. CommandTxt$ = LCase$(Trim$(Command$))
  1449. If CommandTxt$ = "" Then
  1450.     MousePointer = 0
  1451.     Exit Sub
  1452. End If
  1453. If Not Exists(CommandTxt$) Then
  1454.     MousePointer = 0
  1455.     Msg$ = CommandTxt$ & "- file does not exist."
  1456.     Response = MBoxWarning(Msg$)
  1457.     Exit Sub
  1458. End If
  1459. CommandLine = True
  1460. FullFilePath = LCase$(CommandTxt$)
  1461. HScroll1.Refresh
  1462. VScroll1.Refresh
  1463. Panel3D1.Refresh
  1464. OpenFile
  1465. Exit Sub
  1466. OpenFileError2:
  1467.     MousePointer = 0
  1468.     Msg$ = "Problem opening file - " & Error$(Err)
  1469.     Response = MBoxWarning(Msg$)
  1470. Resume OpenFileError3
  1471. OpenFileError3:
  1472.     MousePointer = 0
  1473. End Sub
  1474. Function ScrollText& (TextBox As Control, vLines As Integer, hLines As Integer)
  1475.     ' Place the number of horizontal columns to scroll in the high-
  1476.     ' order 2 bytes of Lines&. The vertical lines to scroll is
  1477.     ' placed in the low-order 2 bytes.
  1478.     Lines& = CLng(&H10000 * hLines) + vLines
  1479.     ' Get the window handle of the control that currently has the focus
  1480.     SavedWnd% = Screen.ActiveControl.hWnd
  1481.     ' Set the focus to the passed control (text control).
  1482.     TextBox.Enabled = True
  1483.     TextBox.SetFocus
  1484.     ' Scroll the lines.
  1485.     Success& = SendMessage(TextBox.hWnd, EM_LINESCROLL, 0, Lines&)
  1486.     ' Restore the focus to the original control
  1487.     R% = PutFocus%(SavedWnd%)
  1488.     ' Return the number of lines actually scrolled.
  1489.     ScrollText& = Success&
  1490.     TextBox.Enabled = False
  1491. End Function
  1492. Sub TextArray_GotFocus (Index As Integer)
  1493. ' Put back Later?
  1494. Picture1.SetFocus
  1495. End Sub
  1496. Sub TextArray_KeyDown (Index As Integer, KeyCode As Integer, Shift As Integer)
  1497. Picture1.SetFocus
  1498. End Sub
  1499. Sub TextArray_KeyPress (Index As Integer, KeyAscii As Integer)
  1500. Picture1.SetFocus
  1501. End Sub
  1502. Sub TextArray_MouseDown (Index As Integer, button As Integer, Shift As Integer, X As Single, Y As Single)
  1503. Picture1.SetFocus
  1504. End Sub
  1505. Sub TextArraytoTop (WhichArray%)
  1506. Num& = ScrollText&(TextArray(WhichArray%), ToTop%, 0) ' top
  1507. End Sub
  1508. Function TextFileCheck (VarString$)
  1509. ' Simple check for valid text file which VB can display
  1510. TextFileCheck = True
  1511. ' Look at first hundred bytes
  1512. For X = 1 To 100
  1513.     If Asc(Mid$(VarString$, X, 1)) > 128 Then
  1514.     TextFileCheck = False
  1515.     Exit For
  1516.     End If
  1517. End Function
  1518. Sub Timer1_Timer ()
  1519. If Me.WindowState = 1 Then
  1520.      DragandDrop
  1521. End If
  1522. End Sub
  1523. Sub UpdateStatusBar ()
  1524. If TotalLines = 0 Then
  1525.     pnlColValue.Caption = ""
  1526.     pnlRowValue.Caption = ""
  1527.     pnlPageValue.Caption = ""
  1528.     pnlMessages.Caption = ""
  1529.     pnlMessages2.Caption = ""
  1530.     Exit Sub
  1531. End If
  1532. pnlColValue.Caption = Format$(HScroll1.Value, "@@@@@")
  1533. pnlRowValue.Caption = Format$(VScroll1.Value, "@@@@@") + " of " + Format$(TotalLines, "@@@@@")
  1534. PageX% = Int(VScroll1.Value / MaxRowsInEditBox)
  1535. PageY = VScroll1.Value Mod MaxRowsInEditBox
  1536. If PageY <> 0 Then PageX% = PageX% + 1
  1537. TotalPagesX% = Int(VScroll1.Max / MaxRowsInEditBox)
  1538. TotalPagesY = VScroll1.Max Mod MaxRowsInEditBox
  1539. If TotalPagesY <> 0 Then TotalPagesX% = TotalPagesX% + 1
  1540. pnlPageValue.Caption = Format$(PageX%, "@@@@@") + " of " + Format$(TotalPagesX%, "@@@@@")
  1541. If Virtual = True Then
  1542.     a$ = Format$(Active, "@@@") + "/" + Format$(Active + 1, "@@@")
  1543.     a$ = Format$(Active, "@@@")
  1544. End If
  1545. VirtualPage$ = "Virtual Zone " + a$ + " of " + Str$(NumArrays)
  1546. pnlMessages.Caption = VirtualPage$
  1547. pnlMessages.Refresh
  1548. End Sub
  1549. Sub VerticalDrag ()
  1550. If TotalLines = 0 Then Exit Sub ' Resizing closed document
  1551. PriorActive% = Active
  1552. VirtualBefore% = Virtual
  1553. If VScroll1.Value <= FixedLines(1) Then
  1554.     Active = 1
  1555.     Active = NumArrays
  1556.     For X = (NumArrays - 1) To 1 Step -1
  1557.     If VScroll1.Value > FixedLines(X) Then Active = X + 1: Exit For
  1558.     Next
  1559. End If
  1560. If Active = NumArrays Then
  1561.    VirtualAfter% = False
  1562.     If VScroll1.Value + (MaxRowsInEditBox - 1) < FixedLines(Active) Then
  1563.     VirtualAfter% = False
  1564.     Else
  1565.     VirtualAfter% = True
  1566.     End If
  1567. End If
  1568. Action% = 0
  1569. If VScroll1.Value = 1 Then
  1570.     Action% = 1  ' To Top
  1571.     If VScroll1.Value = FixedLines(NumArrays) Then
  1572.     Action% = 2  ' To Bottom
  1573.     Else
  1574.     If PriorActive% = Active Then  ' Case 3 through 6 within same array
  1575.     If VirtualBefore% = False Then
  1576.     If VirtualAfter% = False Then
  1577.         Action% = 3 ' Case 3  Drag within text array no virtual - before or after.
  1578.     Else
  1579.         Action% = 4 ' Case 4  Drag within text array no virtual before, virtual after.
  1580.     End If
  1581.     Else
  1582.     If VirtualAfter% = False Then
  1583.         Action% = 6 ' Case 6  Drag within text array virtual before but not after.
  1584.     Else
  1585.         Action% = 5 ' Case 5  Drag within text array virtual - before and after.
  1586.     End If
  1587.     End If
  1588.     Else
  1589.     If VirtualBefore% = False Then
  1590.     If VirtualAfter% = False Then
  1591.         Action% = 9 ' Case 9  Drag outside text array not virtual to another array not virtual.
  1592.     Else
  1593.         Action% = 10' Case 10 Drag outside text array not virtual to another virtual.
  1594.     End If
  1595.     Else
  1596.     If VirtualAfter% = False Then
  1597.         Action% = 7 ' Case 7  Drag outside text array from virtual to another array not virtual.
  1598.     Else
  1599.         Action% = 8 ' Case 8  Drag outside text array from virtual to another virtual.
  1600.     End If
  1601.     End If
  1602.     End If
  1603.     End If
  1604. End If
  1605. Select Case Action%
  1606. Case 0   ' Problem
  1607.     MsgBox "Error no code for this action!"
  1608. Case 1 ' Drag to Top
  1609.     TextArraytoTop (Active) 'Scroll to top
  1610. '   To top
  1611.     PaneltoTop (Active)
  1612.     Virtual = False
  1613. Case 2 ' Drag to Bottom
  1614.     If TextArray(Active).Top <> 0 Then TextArray(Active).Top = 0
  1615.     Num& = ScrollText&(TextArray(Active), ToBottom%, 0) ' Bottom
  1616. '   To top
  1617.     PaneltoTop (Active)
  1618.     Virtual = False
  1619. Case 3 'Drag within text array no virtual - before or after.
  1620.     SLines% = VScroll1.Value - Holdv
  1621.     Num& = ScrollText&(TextArray(Active), SLines%, 0) ' up or down
  1622.     Virtual = False
  1623. Case 4 'Drag within text array no virtual before, virtual after.
  1624.     SLines% = VScroll1.Value - Holdv
  1625.     Num& = ScrollText&(TextArray(Active), SLines%, 0)
  1626.     TextArraytoTop (Active + 1)
  1627.     Diff% = (FixedLines(Active) - VScroll1.Value) + 1  ' lines from top
  1628.     VTop& = Diff% * HeightOfRow
  1629.     If VTop& <> 0 Then
  1630.     TextArray(Active + 1).Top = VTop& + SpaceBetweenLines
  1631.     Else
  1632.     If TextArray(Active + 1).Top <> 0 Then TextArray(Active + 1).Top = 0
  1633.     End If
  1634.     PaneltoTop (Active + 1)
  1635.     Virtual = True
  1636. Case 5 'Drag within text array virtual - before and after.
  1637.     Diff% = (FixedLines(Active) - VScroll1.Value) + 1  ' lines from top
  1638.     VTop& = Diff% * HeightOfRow
  1639.     SLines% = VScroll1.Value - Holdv
  1640.     If SLines% < 0 Then TextArray(Active + 1).Top = VTop& + SpaceBetweenLines
  1641.     Num& = ScrollText&(TextArray(Active), SLines%, 0) ' down
  1642.     If SLines% >= 0 Then TextArray(Active + 1).Top = VTop& + SpaceBetweenLines
  1643.     Virtual = True
  1644. Case 6 ' Case 6  Drag within text array virtual before but not after.
  1645.     SLines% = VScroll1.Value - Holdv
  1646.     Num& = ScrollText&(TextArray(Active), SLines%, 0) ' up or down
  1647.     Diff% = (FixedLines(Active) - VScroll1.Value) + 1  ' lines from top
  1648. '   Active + 1 down in ZOrder
  1649.     Call SetWindowPos(TextArray(Active + 1).hWnd, TextArray(Active).hWnd, 0, 0, 0, 0, DONT_REPOS)
  1650.     Virtual = False
  1651. Case 7, 9  'Case 7  Drag outside text array from virtual to another array not virtual.
  1652.        'Case 9  Drag outside text array not  virtual to another array not virtual.
  1653.     If TextArray(Active).Top <> 0 Then TextArray(Active).Top = 0
  1654.     TextArraytoTop (Active)
  1655.     If Active > 1 Then
  1656.     SLines% = (VScroll1.Value - FixedLines(Active - 1)) - 1
  1657.     Else
  1658.     SLines% = VScroll1.Value - 1
  1659.     End If
  1660.     Num& = ScrollText&(TextArray(Active), SLines%, 0) ' up or down
  1661. '   To top
  1662.     PaneltoTop (Active)
  1663.     Virtual = False
  1664. Case 8, 10 'Case 8  Drag outside text array from virtual to another virtual.
  1665.        'Case 10 Drag outside text array not virtual to another virtual.
  1666.     If TextArray(Active).Top <> 0 Then TextArray(Active).Top = 0
  1667.     TextArraytoTop (Active)
  1668.     If Active > 1 Then
  1669.     SLines% = (VScroll1.Value - FixedLines(Active - 1)) - 1
  1670.     Else
  1671.     SLines% = VScroll1.Value - 1
  1672.     End If
  1673.     Num& = ScrollText&(TextArray(Active), SLines%, 0) ' up or down
  1674.     '
  1675.     TextArraytoTop (Active + 1)
  1676.     Diff% = (FixedLines(Active) - VScroll1.Value) + 1  ' lines from top
  1677.     VTop& = Diff% * HeightOfRow
  1678.     TextArray(Active + 1).Top = VTop& + SpaceBetweenLines
  1679. '   Active, behind Active + 1
  1680. '   Active + 1 To top
  1681.     Call SetWindowPos(TextArray(Active).hWnd, TextArray(Active + 1).hWnd, 0, 0, 0, 0, DONT_REPOS)
  1682.     PaneltoTop (Active + 1)
  1683.     Virtual = True
  1684. End Select
  1685. HScroll1.ZOrder 0
  1686. Holdv = VScroll1.Value    'Keep value
  1687. UpdateStatusBar
  1688. End Sub
  1689. Static Sub VScroll1_Change ()
  1690. ' If the scroll bar is at the top or bottom this is not executed
  1691. If Holdv = VScroll1.Value Or TotalLines = 0 Then
  1692.       VScroll1.Value = Holdv
  1693.       Exit Sub
  1694. End If
  1695. VerticalDrag
  1696. End Sub
  1697. Sub VScroll1_Scroll ()
  1698. If Holdv = VScroll1.Value Then Exit Sub
  1699. If mnuVerticalDrag.Checked = True Then
  1700.     VerticalDrag
  1701. End If
  1702. End Sub
  1703.