GFConsole/GFConsolefrm.frm

VERSION 5.00
Begin VB.Form GFConsolefrm
   BorderStyle     =   0 'Kein
   Caption         =   "GFConsole"
   ClientHeight    =   3195
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   4680
   ShowInTaskbar   =   0 'False
   StartUpPosition =   3 'Windows‑Standard
   Begin VB.PictureBox ConsoleBackGroundPicturePicture
      Height          =   315
      Left            =   0
      ScaleHeight     =   255
      ScaleWidth      =   135
      TabIndex        =   0
      Top             =   0
      Visible         =   0 'False
      Width           =   195
   End
   Begin VB.Label ConsoleInputLabel
      BackStyle       =   0 'Transparent
      Height          =   195
      Left            =   60
      TabIndex        =   4
      Top             =   2880
      Width           =   4515
   End
   Begin VB.Label ConsoleInfoLabel
      BackStyle       =   0 'Transparent
      Enabled         =   0 'False
      Height          =   195
      Left            =   300
      TabIndex        =   3
      Top             =   660
      Visible         =   0 'False
      Width           =   2355
   End
   Begin VB.Label GFConsoleLabel
      BackColor       =   &H00C0C0FF&
      BackStyle       =   0 'Transparent
      Enabled         =   0 'False
      Height          =   195
      Index           =   0
      Left            =   300
      TabIndex        =   2
      Top             =   360
      Visible         =   0 'False
      Width           =   2355
   End
   Begin VB.Label GFConsoleTestLabel
      Caption         =   "test label"
      Enabled         =   0 'False
      Height          =   195
      Left            =   300
      TabIndex        =   1
      Top             =   60
      Visible         =   0 'False
      Width           =   2355
   End
End
Attribute VB_Name = "GFConsolefrm"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'(c)2001 by Louis.
'
'THIS FORM IS PLUG‑IN CODE, DO NOT CHANGE!
'
'NOTE: terminate the console by typing 'exit console'.
'
'GFTilePicture
Private Declare Function BitBlt Lib "gdi32.dll" (ByVal hDestDC As LongByVal X As LongByVal Y As LongByVal nWidth As LongByVal nHeight As LongByVal hSrcDC As LongByVal xSrc As LongByVal ySrc As LongByVal dwRop As Long) As Long
'ProgramGetMousePos[X, Y]
Private Declare Function GetCursorPos Lib "user32.dll" (lpPoint As POINTAPI) As Long
'Form_Unload()
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'ProgramGetMousePos[X, Y]
Private Type POINTAPI
    X As Long
    Y As Long
End Type
'GFConsoleStruct
Private Type GFConsoleStruct
    MoveFlag As Boolean
    MoveDeltaXPos As Single
    MoveDeltaYPos As Single
    ConsoleCursorString As String 'i.e. ']' (Half‑Life) or '‑‑>'
    ConsoleInfoText As String 'displayed in right top corner
    ConsoleLineNumberMax As Integer
    ConsoleLineNumberEntered As Integer 'increased by Console_AddLine (used to avoid displaying empty pages)
    ConsoleLabelPageCurrent As Integer 'changed by 'look [up/down]'
    ConsoleLabelPageCurrentStartIndex As Integer
    ConsoleLabelPageCurrentEndIndex As Integer
End Type
Dim GFConsoleStructVar As GFConsoleStruct
'ConsoleLabelStruct
Private Type ConsoleLabelStruct
    ConsoleLabelForeColor As Long
    ConsoleLabelFontName As String
    ConsoleLabelFontBoldFlag As Boolean
    ConsoleLabelFontItalicFlag As Boolean
    ConsoleLabelFontSize As Single
End Type
Dim ConsoleLabelStructVar As ConsoleLabelStruct
'Version
Const Version As String = "v1.0"

Private Sub Form_Load()
    'on error resume next
    Call DefineWindow
    Call DefineStatus
    'preset console style
    Call Console_SetFont("ARIAL", 8, False, False) 'preset (do at first)
    Call Console_SetForeColor(RGB(0, 0, 0)) 'preset
    Call Console_SetLineNumberMax(128) 'preset
    Call Console_SetCursorString("GFConsole" + " " + GetConsoleVersionString + " ready >")
    'end of presetting console style
End Sub

Private Sub DefineWindow()
    'on error resume next
    GFConsolefrm.ScaleMode = vbTwips
End Sub

Private Sub DefineStatus()
    'on error resume next
    ConsoleBackGroundPicturePicture.AutoSize = True
    ConsoleBackGroundPicturePicture.AutoRedraw = True
    GFConsolefrm.AutoRedraw = True 'for background picture
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    'on error resume next
    Select Case Button
    Case vbLeftButton
        If GFConsolefrm.WindowState = vbNormal Then 'verify (important)
            GFConsoleStructVar.MoveFlag = True
            GFConsoleStructVar.MoveDeltaXPos = GetFormattedTwipsX(ProgramGetMousePosX * Screen.TwipsPerPixelX ‑ GFConsolefrm.Left)
            GFConsoleStructVar.MoveDeltaYPos = GetFormattedTwipsY(ProgramGetMousePosY * Screen.TwipsPerPixelY ‑ GFConsolefrm.Top)
            '
            'NOTE: the code above was partially copied from Wahlen.
            'NOTE: it is important to use the screen mouse coordinates as the
            'picture box mouse coordinates will change if the form is moved.
            '
        Else
            'moving is not possible
        End If
    End Select
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    'on error resume next
    GFConsoleStructVar.MoveFlag = False 'reset
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    'on error resume next
    Dim ConsolefrmXPos As Single
    Dim ConsolefrmYPos As Single
    Select Case Button
    Case vbLeftButton
        If GFConsoleStructVar.MoveFlag = True Then
            ConsolefrmXPos = GetFormattedTwipsX(ProgramGetMousePosX * Screen.TwipsPerPixelX ‑ GFConsoleStructVar.MoveDeltaXPos)
            ConsolefrmYPos = GetFormattedTwipsY(ProgramGetMousePosY * Screen.TwipsPerPixelY ‑ GFConsoleStructVar.MoveDeltaYPos)
            Call GFConsolefrm.Move(ConsolefrmXPos, ConsolefrmYPos)
        End If
    End Select
End Sub

Private Sub GFConsoleLabel_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    'on error resume next
    Call Form_MouseDown(Button, Shift, X + GFConsoleLabel(Index).Left, Y + GFConsoleLabel(Index).Top)
End Sub

Private Sub GFConsoleLabel_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    'on error resume next
    Call Form_MouseUp(Button, Shift, X + GFConsoleLabel(Index).Left, Y + GFConsoleLabel(Index).Top)
End Sub

Private Sub GFConsoleLabel_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
    'on error resume next
    Call Form_MouseMove(Button, Shift, X + GFConsoleLabel(Index).Left, Y + GFConsoleLabel(Index).Top)
End Sub

Private Sub ConsoleInfoLabel_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    'on error resume next
    Call Form_MouseDown(Button, Shift, X + ConsoleInfoLabel.Left, Y + ConsoleInfoLabel.Top)
End Sub

Private Sub ConsoleInfoLabel_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    'on error resume next
    Call Form_MouseUp(Button, Shift, X + ConsoleInfoLabel.Left, Y + ConsoleInfoLabel.Top)
End Sub

Private Sub ConsoleInfoLabel_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    'on error resume next
    Call Form_MouseMove(Button, Shift, X + ConsoleInfoLabel.Left, Y + ConsoleInfoLabel.Top)
End Sub

Private Sub Form_Resize()
    'on error resume next
    Call Console_Refresh(GFConsoleStructVar)
    Call ConsoleBackGroundPicture_Refresh
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
    'on error resume next
    Call ConsoleInputLabel_KeyPress(KeyAscii)
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    'on error resume next
    Call ConsoleInputLabel_KeyDown(KeyCode, Shift)
End Sub

Private Sub ConsoleInputLabel_KeyDown(KeyCode As Integer, Shift As Integer)
    'on error resume next
    Select Case KeyCode
    Case 33 'look up
        GFConsoleStructVar.ConsoleLabelPageCurrent = GFConsoleStructVar.ConsoleLabelPageCurrent ‑ 1
        Call Console_Refresh(GFConsoleStructVar) 'will verify ...PageCurrent
    Case 34 'look down
        GFConsoleStructVar.ConsoleLabelPageCurrent = GFConsoleStructVar.ConsoleLabelPageCurrent + 1
        Call Console_Refresh(GFConsoleStructVar) 'will verify ...PageCurrent
    Case Else
        'processed by ConsoleInputLabel_KeyPress()
    End Select
End Sub

Private Sub ConsoleInputLabel_KeyPress(KeyAscii As Integer)
    'on error resume next
    If (KeyAscii = 13) Or (KeyAscii = 10) Then
        KeyAscii = 0 'avoid BIIM
        Call Console_AddLine(ConsoleInputLabel.Caption)
        ConsoleInputLabel.Caption = GFConsoleStructVar.ConsoleCursorString 'reset
        Exit Sub 'important
    End If
    Select Case KeyAscii
    Case 32 To 255
        ConsoleInputLabel.Caption = ConsoleInputLabel.Caption + Chr$(KeyAscii)
    Case 8
        If Len(ConsoleInputLabel.Caption) > Len(GFConsoleStructVar.ConsoleCursorString) Then
            ConsoleInputLabel.Caption = Left$(ConsoleInputLabel.Caption, Len(ConsoleInputLabel.Caption) ‑ 1)
        End If
    End Select
    Exit Sub
End Sub

'****************************************CONSOLE****************************************

Public Sub Console_Size(ByVal WindowState As IntegerByVal ConsoleWidthOrZero As SingleByVal ConsoleHeightOrZero As Single)
    'on error resume next 'pass size values in format pixels
    Select Case WindowState
    Case vbMinimized
        GFConsolefrm.Visible = False
        GFConsolefrm.WindowState = vbMinimized
        GFConsolefrm.Visible = True
        Call Console_Refresh(GFConsoleStructVar)
        Call ConsoleBackGroundPicture_Refresh
    Case vbNormal
        GFConsolefrm.Visible = False
        GFConsolefrm.WindowState = vbNormal
        If Not ConsoleWidthOrZero = 0 Then GFConsolefrm.Width = ConsoleWidthOrZero * Screen.TwipsPerPixelX
        If Not ConsoleHeightOrZero = 0 Then GFConsolefrm.Height = ConsoleHeightOrZero * Screen.TwipsPerPixelY
        GFConsolefrm.Visible = True
        Call Console_Refresh(GFConsoleStructVar)
        Call ConsoleBackGroundPicture_Refresh
    Case vbMaximized
        GFConsolefrm.Visible = False
        GFConsolefrm.WindowState = vbMaximized
        GFConsolefrm.Visible = True
        Call Console_Refresh(GFConsoleStructVar)
        Call ConsoleBackGroundPicture_Refresh
    Case Else
        MsgBox "internal error in Console_Size(): passed value invalid !", vbOKOnly + vbExclamation
    End Select
End Sub

Public Sub Console_SetBackGroundPicture(ByVal BackGroundPictureName As String)
    'on error goto error: 'if memory is low
    If Not ((Dir(BackGroundPictureName) = "") Or (Right$(BackGroundPictureName, 1) = "\") Or (BackGroundPictureName = "")) Then 'verify
        'preset
        ConsoleBackGroundPicturePicture.AutoRedraw = True 'important
        ConsoleBackGroundPicturePicture.AutoSize = True 'important
        ConsoleBackGroundPicturePicture.Refresh
        'begin
        Set ConsoleBackGroundPicturePicture.Picture = LoadPicture(BackGroundPictureName)
        'Set ConsoleBackGroundPicturePicture.Picture = LoadPicture("") 'reset (free up memory) 'no
        Call ConsoleBackGroundPicture_Refresh
    Else
        MsgBox "internal error in Console_SetBackGroundPicture(): file not found !", vbOKOnly + vbExclamation
    End If
    Exit Sub
Error:
    MsgBox "internal error in Console_SetBackGroundPicture(): " + Left$(Err.Description, 512) + " !", vbOKOnly + vbExclamation
    Exit Sub
End Sub

Private Sub ConsoleBackGroundPicture_Refresh()
    'on error resume next 'call when size of GFConsolefrm was changed
    Call GFTilePictureEx(ConsoleBackGroundPicturePicture, GFConsolefrm)
End Sub

Public Sub Console_SetLineNumberMax(ByVal LineNumberMax As Integer)
    'on error resume next
    Dim Temp As Long
    'verify
    Select Case LineNumberMax
    Case Is < 16
        LineNumberMax = 16 'something useful
    End Select
    'begin
    If LineNumberMax > GFConsoleStructVar.ConsoleLineNumberMax Then
        For Temp = (GFConsoleStructVar.ConsoleLineNumberMax + 1) To LineNumberMax
            Load GFConsoleLabel(Temp)
        Next Temp
    End If
    If LineNumberMax < GFConsoleStructVar.ConsoleLineNumberMax Then
        For Temp = (LineNumberMax + 1) To GFConsoleStructVar.ConsoleLineNumberMax
            Unload GFConsoleLabel(Temp)
        Next Temp
    End If
    GFConsoleStructVar.ConsoleLineNumberMax = LineNumberMax
End Sub

Public Sub Console_SetCursorString(ByVal CursorString As String)
    'on error resume next
    If Not (GFConsoleStructVar.ConsoleCursorString = CursorString) Then
        If Left$(ConsoleInputLabel.Caption, Len(GFConsoleStructVar.ConsoleCursorString)) = GFConsoleStructVar.ConsoleCursorString Then
            'remove old cursor string
            ConsoleInputLabel.Caption = Right$(ConsoleInputLabel.Caption, Len(ConsoleInputLabel.Caption) ‑ Len(GFConsoleStructVar.ConsoleCursorString))
        End If
        'set new cursor string
        GFConsoleStructVar.ConsoleCursorString = CursorString
        ConsoleInputLabel.Caption = GFConsoleStructVar.ConsoleCursorString + ConsoleInputLabel.Caption
    Else
        'do nothing (cursor string already set)
    End If
End Sub

Public Sub Console_SetInfoText(ByVal InfoText As String)
    'on error resume next
    GFConsoleStructVar.ConsoleInfoText = InfoText
End Sub

Public Sub Console_AddLine(ByVal Line As String)
    'on error resume next
    Dim Temp As Long
    'verify
    If Right$(UCase$(Line), Len(Line) ‑ Len(GFConsoleStructVar.ConsoleCursorString)) = "EXIT CONSOLE" Then Call Form_Unload(False)
    'preset
    If Not (GFConsoleStructVar.ConsoleLineNumberEntered = 32767) Then 'verify
        'NOTE: the value below if used to avoid displaying empty pages.
        GFConsoleStructVar.ConsoleLineNumberEntered = GFConsoleStructVar.ConsoleLineNumberEntered + 1
    End If
    'begin
    For Temp = 1 To (GFConsoleStructVar.ConsoleLineNumberMax ‑ 1)
        GFConsoleLabel(Temp).Caption = GFConsoleLabel(Temp + 1).Caption
    Next Temp
    GFConsoleLabel(GFConsoleStructVar.ConsoleLineNumberMax).Caption = Line
    GFConsoleStructVar.ConsoleLabelPageCurrent = 32767 'scroll to last page
    Call Console_Refresh(GFConsoleStructVar) 'display changes
End Sub

Public Function GetConsoleVersionString() As String
    'on error resume next
    GetConsoleVersionString = Version
End Function

'************************************END OF CONSOLE*************************************
'*************************************CONSOLE LABEL*************************************
'NOTE: the following subs/functions use the ConsoleLabelStructVar to save label specific information.

Public Sub Console_SetFont(ByVal FontName As StringByVal FontSize As SingleByVal FontBoldFlag As BooleanByVal FontItalicFlag As Boolean)
    On Error GoTo Error: 'important (if passed font data is invalid)
    GFConsoleTestLabel.Font.Name = FontName
    GFConsoleTestLabel.Font.Size = FontSize
    GFConsoleTestLabel.Font.Bold = FontBoldFlag
    GFConsoleTestLabel.Font.Italic = FontItalicFlag
    ConsoleLabelStructVar.ConsoleLabelFontName = FontName
    ConsoleLabelStructVar.ConsoleLabelFontSize = FontSize
    ConsoleLabelStructVar.ConsoleLabelFontBoldFlag = FontBoldFlag
    ConsoleLabelStructVar.ConsoleLabelFontItalicFlag = FontItalicFlag
    Call Console_Refresh(GFConsoleStructVar) 'display changes
    Exit Sub
Error:
    MsgBox "internal error in Console_SetFont(): passed value invalid !", vbOKOnly + vbExclamation
    Exit Sub
End Sub

Public Sub Console_SetForeColor(ByVal ConsoleLabelForeColor As Long)
    'on error resume next
    ConsoleLabelStructVar.ConsoleLabelForeColor = ConsoleLabelForeColor
    Call Console_Refresh(GFConsoleStructVar) 'display changes
End Sub

Private Sub Console_Refresh(ByRef GFConsoleStructVar As GFConsoleStruct)
    'on error resume next
    Dim ConsoleFirstLabelIndex As Integer
    Dim ConsoleLastLabelIndex As Integer
    Dim CurrentLabelIndex As Integer
    'begin
    'ConsoleInputLabel; appearance
    ConsoleInputLabel.ForeColor = ConsoleLabelStructVar.ConsoleLabelForeColor
    ConsoleInputLabel.Font.Name = ConsoleLabelStructVar.ConsoleLabelFontName
    ConsoleInputLabel.Font.Size = ConsoleLabelStructVar.ConsoleLabelFontSize
    ConsoleInputLabel.Font.Bold = ConsoleLabelStructVar.ConsoleLabelFontBoldFlag
    ConsoleInputLabel.Font.Italic = ConsoleLabelStructVar.ConsoleLabelFontItalicFlag
    'size/position
    ConsoleInputLabel.Width = GFConsolefrm.ScaleWidth ‑ (4 * Screen.TwipsPerPixelY)
    ConsoleInputLabel.Height = (GFConsoleLabel(CurrentLabelIndex).Font.Size + 4) * Screen.TwipsPerPixelY
    ConsoleInputLabel.Left = (2 * Screen.TwipsPerPixelX)
    ConsoleInputLabel.Top = GFConsolefrm.ScaleHeight ‑ ConsoleInputLabel.Height ‑ (2 * Screen.TwipsPerPixelY)
    'GFConsoleLabel()
    For CurrentLabelIndex = 1 To GFConsoleStructVar.ConsoleLineNumberMax
        'appearance
        GFConsoleLabel(CurrentLabelIndex).ForeColor = ConsoleLabelStructVar.ConsoleLabelForeColor
        GFConsoleLabel(CurrentLabelIndex).Font.Name = ConsoleLabelStructVar.ConsoleLabelFontName
        GFConsoleLabel(CurrentLabelIndex).Font.Size = ConsoleLabelStructVar.ConsoleLabelFontSize
        GFConsoleLabel(CurrentLabelIndex).Font.Bold = ConsoleLabelStructVar.ConsoleLabelFontBoldFlag
        GFConsoleLabel(CurrentLabelIndex).Font.Italic = ConsoleLabelStructVar.ConsoleLabelFontItalicFlag
        'size/position
        GFConsoleLabel(CurrentLabelIndex).Width = GFConsolefrm.ScaleWidth ‑ (4 * Screen.TwipsPerPixelX)
        GFConsoleLabel(CurrentLabelIndex).Height = (GFConsoleLabel(CurrentLabelIndex).Font.Size + 6) * Screen.TwipsPerPixelY
        'page scrolling
        ConsoleFirstLabelIndex = GetConsoleFirstLabelIndex(GFConsoleStructVar)
        ConsoleLastLabelIndex = GetConsoleLastLabelIndex(GFConsoleStructVar)
        'display/hide labels
        If (Not (CurrentLabelIndex < ConsoleFirstLabelIndex)) And (Not (CurrentLabelIndex > ConsoleLastLabelIndex)) Then
            'label visible
            GFConsoleLabel(CurrentLabelIndex).Enabled = True
            GFConsoleLabel(CurrentLabelIndex).Visible = True
            GFConsoleLabel(CurrentLabelIndex).Top = (GetConsoleLineNumber ‑ (ConsoleLastLabelIndex ‑ ConsoleFirstLabelIndex) + (CurrentLabelIndex ‑ ConsoleFirstLabelIndex) ‑ 1) * GFConsoleLabel(CurrentLabelIndex).Height
            GFConsoleLabel(CurrentLabelIndex).Left = (2 * Screen.TwipsPerPixelX)
        Else
            'label not visible
            GFConsoleLabel(CurrentLabelIndex).Visible = False
            GFConsoleLabel(CurrentLabelIndex).Enabled = False
            GFConsoleLabel(CurrentLabelIndex).Top = (2 * Screen.TwipsPerPixelY)
            GFConsoleLabel(CurrentLabelIndex).Left = (2 * Screen.TwipsPerPixelX)
        End If
    Next CurrentLabelIndex
    'ConsoleInfoLabel
    If Not (GFConsoleStructVar.ConsoleInfoText = "") Then 'verify
        'appearance
        ConsoleInfoLabel.ForeColor = ConsoleLabelStructVar.ConsoleLabelForeColor
        ConsoleInfoLabel.Font.Name = ConsoleLabelStructVar.ConsoleLabelFontName
        ConsoleInfoLabel.Font.Size = ConsoleLabelStructVar.ConsoleLabelFontSize
        ConsoleInfoLabel.Font.Bold = ConsoleLabelStructVar.ConsoleLabelFontBoldFlag
        ConsoleInfoLabel.Font.Italic = ConsoleLabelStructVar.ConsoleLabelFontItalicFlag
        ConsoleInfoLabel.Caption = GFConsoleStructVar.ConsoleInfoText 'do after appearance has been set
        'size/position
        ConsoleBackGroundPicturePicture.Font.Name = ConsoleInfoLabel.Font.Name
        ConsoleBackGroundPicturePicture.Font.Size = ConsoleInfoLabel.Font.Size
        ConsoleInfoLabel.Width = ConsoleBackGroundPicturePicture.TextWidth(GFConsoleStructVar.ConsoleInfoText) + (2 * Screen.TwipsPerPixelX)
        ConsoleInfoLabel.Height = (ConsoleInfoLabel.Font.Size + 6) * Screen.TwipsPerPixelY 'NOTE: if changing this value, also update GetConsoleLineNumber.
        ConsoleInfoLabel.Left = GFConsolefrm.ScaleWidth ‑ ConsoleInfoLabel.Width
        ConsoleInfoLabel.Top = (2 * Screen.TwipsPerPixelY)
        'display/hide info label
        ConsoleInfoLabel.Enabled = True
        ConsoleInfoLabel.Visible = True
    Else
        'display no info text
        ConsoleInfoLabel.Visible = False
        ConsoleInfoLabel.Enabled = False
    End If
End Sub

Private Function GetConsoleLineNumber() As Integer
    'on error resume next
    GetConsoleLineNumber = Int(((ConsoleInputLabel.Top) / ((ConsoleInfoLabel.Font.Size + 6) * Screen.TwipsPerPixelY))) 'calculate using space between form top and ConsoleInputLabel
End Function

Private Function GetConsoleFirstLabelIndex(ByRef GFConsoleStructVar As GFConsoleStruct) As Integer
    'on error resume next 'uses page scrolling
    'preset
    Call UpdateConsoleLabelPage(GFConsoleStructVar)
    'begin
    GetConsoleFirstLabelIndex = GFConsoleStructVar.ConsoleLabelPageCurrentStartIndex
End Function

Private Function GetConsoleLastLabelIndex(ByRef GFConsoleStructVar As GFConsoleStruct) As Integer
    'on error resume next 'uses page scrolling
    'preset
    Call UpdateConsoleLabelPage(GFConsoleStructVar)
    'begin
    GetConsoleLastLabelIndex = GFConsoleStructVar.ConsoleLabelPageCurrentEndIndex
End Function

Private Sub UpdateConsoleLabelPage(ByRef GFConsoleStructVar As GFConsoleStruct)
    'on error resume next
    Dim ConsoleUsedLabelNumber As Integer
    Dim ConsoleFirstUsedLabelIndex As Integer
    Dim ConsoleLastUsedLabelIndex As Integer
    Dim ConsolePageMin As Integer
    Dim ConsolePageMax As Integer
    'preset
    ConsoleUsedLabelNumber = GFConsoleStructVar.ConsoleLineNumberEntered
    If ConsoleUsedLabelNumber > GetConsoleLineNumber Then ConsoleUsedLabelNumber = GetConsoleLineNumber
    '
    ConsoleFirstUsedLabelIndex = GFConsoleStructVar.ConsoleLineNumberMax ‑ ConsoleUsedLabelNumber
    ConsoleLastUsedLabelIndex = GFConsoleStructVar.ConsoleLineNumberMax
    '
    ConsolePageMin = ‑Int(ConsoleFirstUsedLabelIndex / GetConsoleLineNumber * ‑1)
    ConsolePageMax = ‑Int(ConsoleLastUsedLabelIndex / GetConsoleLineNumber * ‑1)
    'verify
    Select Case GFConsoleStructVar.ConsoleLabelPageCurrent
    Case Is < ConsolePageMin
        GFConsoleStructVar.ConsoleLabelPageCurrent = ConsolePageMin
    Case Is > ConsolePageMax
        GFConsoleStructVar.ConsoleLabelPageCurrent = ConsolePageMax
    End Select
    'begin
    GFConsoleStructVar.ConsoleLabelPageCurrentStartIndex = (GFConsoleStructVar.ConsoleLabelPageCurrent ‑ 1) * GetConsoleLineNumber
    GFConsoleStructVar.ConsoleLabelPageCurrentEndIndex = GFConsoleStructVar.ConsoleLabelPageCurrent * GetConsoleLineNumber
    '
    If GFConsoleStructVar.ConsoleLabelPageCurrentStartIndex > ConsoleFirstUsedLabelIndex Then
        GFConsoleStructVar.ConsoleLabelPageCurrentStartIndex = ConsoleFirstUsedLabelIndex
    End If
    If GFConsoleStructVar.ConsoleLabelPageCurrentEndIndex > ConsoleLastUsedLabelIndex Then
        GFConsoleStructVar.ConsoleLabelPageCurrentEndIndex = ConsoleLastUsedLabelIndex
    End If
    '
End Sub

'*********************************END OF CONSOLE LABEL**********************************
'***********************************GENERAL FUNCTIONS***********************************

Private Sub GFTilePictureEx(ByRef TileSourcePicture As PictureBox, ByRef TileTargetPicture As Form)
    'on error resume next 'NOTE: this is a Console‑specific version of GFTilePicture(), use the code in the general function directory for further projects.
    Dim TileSourcePictureScaleModeUnchanged As Integer
    Dim TileTargetPictureScaleModeUnchanged As Integer
    Dim TileXSizeCurrent As Long
    Dim TileYSizeCurrent As Long
    Dim TileXSizeTotal As Long
    Dim TileYSizeTotal As Long
    'preset
    TileSourcePictureScaleModeUnchanged = TileSourcePicture.ScaleMode
    TileSourcePicture.ScaleMode = vbPixels 'important
    TileTargetPictureScaleModeUnchanged = TileTargetPicture.ScaleMode
    TileTargetPicture.ScaleMode = vbPixels 'important
    'verify
    If (TileSourcePicture.ScaleWidth = 0) Or (TileSourcePicture.ScaleHeight = 0) Then 'verify
        Exit Sub
    End If
    'begin
    Do
        TileYSizeCurrent = TileSourcePicture.ScaleHeight
        If (TileYSizeTotal + TileYSizeCurrent) > TileTargetPicture.ScaleHeight Then
            TileYSizeCurrent = TileTargetPicture.ScaleHeight ‑ TileYSizeTotal
        End If
        TileXSizeTotal = 0 'reset
        Do
            TileXSizeCurrent = TileSourcePicture.ScaleWidth
            If (TileXSizeTotal + TileXSizeCurrent) > TileTargetPicture.ScaleWidth Then
                TileXSizeCurrent = TileTargetPicture.ScaleWidth ‑ TileXSizeTotal
            End If
            Call BitBlt(TileTargetPicture.hDC, TileXSizeTotal, TileYSizeTotal, TileXSizeCurrent, TileYSizeCurrent, TileSourcePicture.hDC, 0, 0, vbSrcCopy)
            TileXSizeTotal = TileXSizeTotal + TileXSizeCurrent
            If Not (TileXSizeTotal < TileTargetPicture.ScaleWidth) Then Exit Do
        Loop
        TileYSizeTotal = TileYSizeTotal + TileYSizeCurrent
        If Not (TileYSizeTotal < TileTargetPicture.ScaleHeight) Then Exit Do
    Loop
    'reset
    TileSourcePicture.ScaleMode = TileSourcePictureScaleModeUnchanged
    TileTargetPicture.ScaleMode = TileTargetPictureScaleModeUnchanged
End Sub

Private Function ProgramGetMousePosX() As Long
    On Error Resume Next 'the format is: pixels
    Dim ProgramGetMousePosXTemp As Long
    Dim CurrentMousePos As POINTAPI
    ProgramGetMousePosXTemp = GetCursorPos(CurrentMousePos)
    ProgramGetMousePosX = CurrentMousePos.X
End Function

Private Function ProgramGetMousePosY() As Long
    On Error Resume Next 'the format is: pixels
    Dim ProgramGetMousePosYTemp As Long
    Dim CurrentMousePos As POINTAPI
    ProgramGetMousePosYTemp = GetCursorPos(CurrentMousePos)
    ProgramGetMousePosY = CurrentMousePos.Y
End Function

Private Function GetFormattedTwipsX(ByVal TwipsX As Single) As Single
    'on error resume next 'verifies return value is Screen.TwipsPerPixelX * x (x E N)
    GetFormattedTwipsX = Int(TwipsX) ‑ (Int(TwipsX) Mod Screen.TwipsPerPixelX)
End Function

Private Function GetFormattedTwipsY(ByVal TwipsY As Single) As Single
    'on error resume next 'verifies return value is Screen.TwipsPerPixelY * x (x E N)
    GetFormattedTwipsY = Int(TwipsY) ‑ (Int(TwipsY) Mod Screen.TwipsPerPixelY)
End Function

Private Sub Form_Unload(Cancel As Integer)
    'on error resume next
    GFConsolefrm.MousePointer = vbHourglass
    Call Sleep(500) 'looks better
    GFConsolefrm.MousePointer = vbNormal
    End
End Sub


[END OF FILE]