The following contains screens for general full screen PBCC applications.
Graphic screens have built-in support for keyboard and mouse.
As an extra, a function for mouse and keyboard support for an arbitrary graphic window has been included.
The code below is divided in two sections : an include file "PBScreen.inc", and a small program to demonstrate the various functions.
------------------------------------------------------------
Revision march 19, 2008 : Graphic Font style parameter corrected, with thanks to Chris Holbrook
Revision march 21, 2008 : #If Not %Def (%ExampleHandler).. block moved out of primary #If / #EndIf block
Revision march 31, 2008 : Mouse and keyboard support for arbitrary graphic window added
Presentation changed : Include file and demonstration program now presented separately
------------------------------------------------------------
Include file "PBScreen.inc"
Demonstration program for PBScreen functions
Graphic screens have built-in support for keyboard and mouse.
As an extra, a function for mouse and keyboard support for an arbitrary graphic window has been included.
The code below is divided in two sections : an include file "PBScreen.inc", and a small program to demonstrate the various functions.
------------------------------------------------------------
Revision march 19, 2008 : Graphic Font style parameter corrected, with thanks to Chris Holbrook
Revision march 21, 2008 : #If Not %Def (%ExampleHandler).. block moved out of primary #If / #EndIf block
Revision march 31, 2008 : Mouse and keyboard support for arbitrary graphic window added
Presentation changed : Include file and demonstration program now presented separately
------------------------------------------------------------
Include file "PBScreen.inc"
Code:
[FONT=Courier New][SIZE=1]' -------------------------------------------------------------------------------[/SIZE][/FONT] [SIZE=1][FONT=Courier New]' PBScreen.inc - screens for general keyboard based PBCC applications[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' Arie Verheul[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' -------------------------------------------------------------------------------[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' This file contains a set of screens for general keyboard based PBCC applications.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' Except for the arbitrary graphic window, the screens fill the whole desktop, [/FONT][/SIZE] [SIZE=1][FONT=Courier New]' taking into account the presence or absence of a system tray.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' The set includes the following :[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' -------------------------------------------------------------------------------[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' a. Full screen console window[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' -------------------------------------------------------------------------------[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' Function ConsoleScreen () As Dword[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' The function takes no arguments and returns the console handle.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' -------------------------------------------------------------------------------[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' b. Split screen[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' -------------------------------------------------------------------------------[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' The screen consists of a console window of the specified size, either along the[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' full width of the bottom of the screen, or to the left of the screen across the[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' full height, while the remainder of the screen is filled with a graphic window.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' The graphic screen has built-in Left and Right-click mouse support.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' Function SplitScreen ( Dimension As Long, ByVal RowsOrCols As Asciiz*2 ) As Dword[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' The function returns the handle of the graphic window.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' Arguments :[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' [Dimension] : the desired size of the console window.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' Windows may refuse very small console windows.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' If this is the case, or if the specified value[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' is otherwise invalid, the value is ignored.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' [RowsOrCols] : valid values include "Rows", "Cols" or "Columns"[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' (only the first character is processed)[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' The routine directs the focus to the console, and it is recommended that the[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' program does the same, to avoid improper closure of the screen.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' -------------------------------------------------------------------------------[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' c. Full screen graphic window[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' -------------------------------------------------------------------------------[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' Installs a full screen graphic window, with or without title bar, and with[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' built-in keyboard and Left and Right-click mouse support.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' Function GraphicScreen (Caption As String) As Dword[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' The function returns the graphic handle[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' Argument : [Caption][/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' If a title is specified, a window with titlebar is installed, if [Caption][/FONT][/SIZE] [SIZE=1][FONT=Courier New]' is an empty string the titlebar is omitted, exactly like in Powerbasic.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' The console becomes redundant and is turned off with the FreeConsole function.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' If needed again at a later stage, it has to be turned on again with AllocConsole.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' The graphic window with titlebar may be closed either with the Close-button or[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' with Alt-F4, the window without titlebar may be closed with Alt-F4 or with means[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' provided by the main program.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' To terminate the program after the window has been closed, a global variable[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' [WindowClosed] is provided, which receives the value -1 at window closure,[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' and should be processed in a suitable way.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' -------------------------------------------------------------------------------[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' d. Arbitrary graphic window with mouse and keyboard support[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' -------------------------------------------------------------------------------[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' Installs an arbitrary graphic window, with or without title bar, and with[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' built-in keyboard and Left and Right-click mouse support.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' Function GraphicWindow (Caption As String, Xo As Long, Yo As Long,_[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' WindowWidth As Long, WindowHeight As Long) As Dword[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' The parameterlist is identical to that of the PBCC function, and the resulting[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' graphic window is exactly the same, but with added built-in support for mouse[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' and keyboard. Also supported is the global variable [WindowClosed], to terminate[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' the program after the window has been closed.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' The console is turned off with the Windows function FreeConsole.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' -------------------------------------------------------------------------------[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' Mouse support[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' -------------------------------------------------------------------------------[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' The Splitscreen and GraphicScreen graphic windows have Left-click and[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' Right-click mouse support.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' For this purpose the global DWord variables [LMouse_HA] and [RMouse_HA] are[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' provided. The screen calls with a Call DWord procedure the handlers whose[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' addresses are placed in these variables. The handlers must take as argument[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' one DWord variable that holds the mouse coordinates as follows:[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' x = Hi(Word,lparam)[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' y = Lo(Word,lparam)[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' If [LMouse_HA] and/or [RMouse_HA] are set to, or remain zero, the mouse support[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' for the respective button(s) is in effect turned off.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' Other types of mouse support may be added, if desired, by changing the Select Case[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' block accordingly (see also list of Windows equates). Mouse support for the console [/FONT][/SIZE] [SIZE=1][FONT=Courier New]' window may be obtained with the regular means provided by PowerBasic compiler.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' -------------------------------------------------------------------------------[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' Keyboard support[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' -------------------------------------------------------------------------------[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' The GraphicScreen routine features keyboard support in a similar way.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' Two global DWord variables [Char_HA] and [Key_HA] are provided.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' If the address of an appropriate handler routine is placed in these variables,[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' the handler will be called if a key in the specified class is pressed.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' Support for two classes of keys is provided :[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' [Char_HA] is associated with all text characters + Enter, Escape, Tab, Backspace[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' [Key_HA] is associated with a list of auxiliar keys, see list of equates below.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' If [Char_HA] and/or [Key_HA] are set to, or remain zero, the keyboard support[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' for the respective class of keys is in effect turned off.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' -------------------------------------------------------------------------------[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' Avoiding redundant code[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' -------------------------------------------------------------------------------[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' To compile only relevant code, the following equates may be defined :[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' %ConsoleScreen = 1[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' %Splitscreen = 1[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' %GraphicScreen = 1[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' It is sufficient to define just the equate for the desired section.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' The equate(s) should be placed above the include call.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' Omitting the equates does not affect the functionality of the routines,[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' but may cause up to 17.5 kBytes of redundant code to be compiled.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' The include file contains two example handlers : ExampleMouseHandler[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' and ExampleCharHandler, which will only be included if an equate[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' %ExampleHandler = 1 has been defined.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' -------------------------------------------------------------------------------[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' Restoring the console[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' -------------------------------------------------------------------------------[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' Some screens modify the properties of the console window.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' The Splitscreen and ConsoleScreen functions turn the resize and/or minimize[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' buttons off. The graphic screen turns the console completely off. These changes[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' remain of course in effect as long as the program is running. Therefore, in the[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' case that the same program needs at a later stage a regular console window, a[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' new console window must be installed using the FreeConsole and AllocConsole[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' functions. The respective Windows declarations are included in this file.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' -------------------------------------------------------------------------------[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' Acknowledgement[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' -------------------------------------------------------------------------------[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' Many features of the described routines were freely borrowed from posts on the[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' PBForum, for which i want to thank those who made the contributions.[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' -------------------------------------------------------------------------------[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' START OF PBScreen CODE[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' -------------------------------------------------------------------------------[/FONT][/SIZE] [FONT=Courier New][SIZE=1]' Includes for conditional compilation[/SIZE][/FONT] [FONT=Courier New][SIZE=1]#If Not (%Def (%ConsoleScreen)) Or (%Def (%SplitScreen)) Or (%Def (%GraphicScreen))[/SIZE][/FONT] [FONT=Courier New][SIZE=1] ' Turn everything on if no equates defined[/SIZE][/FONT] [FONT=Courier New][SIZE=1] %ConsoleScreen = 1[/SIZE][/FONT] [SIZE=1][FONT=Courier New] %SplitScreen = 1[/FONT][/SIZE] [SIZE=1][FONT=Courier New] %GraphicScreen = 1[/FONT][/SIZE] [FONT=Courier New][SIZE=1]#Else ' Set unused equates to zero[/SIZE][/FONT] [FONT=Courier New][SIZE=1] #If Not %Def (%ConsoleScreen)[/SIZE][/FONT] [SIZE=1][FONT=Courier New] %ConsoleScreen = 0[/FONT][/SIZE] [SIZE=1][FONT=Courier New] #EndIf[/FONT][/SIZE] [FONT=Courier New][SIZE=1] #If Not %Def (%SplitScreen)[/SIZE][/FONT] [SIZE=1][FONT=Courier New] %SplitScreen = 0[/FONT][/SIZE] [SIZE=1][FONT=Courier New] #EndIf[/FONT][/SIZE] [FONT=Courier New][SIZE=1] #If Not %Def (%GraphicScreen)[/SIZE][/FONT] [SIZE=1][FONT=Courier New] %GraphicScreen = 0[/FONT][/SIZE] [SIZE=1][FONT=Courier New] #EndIf[/FONT][/SIZE] [FONT=Courier New][SIZE=1]#EndIf[/SIZE][/FONT] [FONT=Courier New][SIZE=1] #If Not %Def (%ExampleHandler) ' Include ExampleHandlers only if specified[/SIZE][/FONT] [SIZE=1][FONT=Courier New] %ExampleHandler = 0[/FONT][/SIZE] [SIZE=1][FONT=Courier New] #EndIf[/FONT][/SIZE] [FONT=Courier New][SIZE=1]' -------------------------------------------------------------------------------[/SIZE][/FONT] [SIZE=1][FONT=Courier New]' User defined settings, may be edited[/FONT][/SIZE] [FONT=Courier New][SIZE=1]%PBS_TextColor = &H50FF50 ' Default graphic colors (BGR)[/SIZE][/FONT] [SIZE=1][FONT=Courier New]%PBS_Background = &H200000[/FONT][/SIZE] [FONT=Courier New][SIZE=1]$PBS_Font = "Courier New" ' Default graphic font[/SIZE][/FONT] [SIZE=1][FONT=Courier New]%PBS_FontSize = 16[/FONT][/SIZE] [FONT=Courier New][SIZE=1]' -------------------------------------------------------------------------------[/SIZE][/FONT] [SIZE=1][FONT=Courier New]' Key code equates to be used in handlers[/FONT][/SIZE] [FONT=Courier New][SIZE=1]%Key_Bsp = 8[/SIZE][/FONT] [SIZE=1][FONT=Courier New]%Key_Tab = 9[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_Enter = 13[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_Shift = 16[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_Ctl = 17[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_Break = 19[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_CapsLck = 20[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_Esc = 27[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_PgUp = 33[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_PgDwn = 34[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_End = 35[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_Home = 36[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_CsrLeft = 37[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_CsrUp = 38[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_CsrRight = 39[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_CsrDwn = 40[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_Ins = 45[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_Del = 46[/FONT][/SIZE] [FONT=Courier New][SIZE=1]%Key_Menu = 93[/SIZE][/FONT] [FONT=Courier New][SIZE=1]%Key_F1 = 112[/SIZE][/FONT] [SIZE=1][FONT=Courier New]%Key_F2 = 113[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_F3 = 114[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_F4 = 115[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_F5 = 116[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_F6 = 117[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_F7 = 118[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_F8 = 119[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_F9 = 120[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_F10 = 121[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_F11 = 122[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%Key_F12 = 123[/FONT][/SIZE] [FONT=Courier New][SIZE=1]' -------------------------------------------------------------------------------[/SIZE][/FONT] [SIZE=1][FONT=Courier New]' Windows system equates[/FONT][/SIZE] [FONT=Courier New][SIZE=1]%GW_CHILD = 5[/SIZE][/FONT] [SIZE=1][FONT=Courier New]%GWL_WNDPROC = -4[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%WM_DESTROY = &H2[/FONT][/SIZE] [FONT=Courier New][SIZE=1]%WM_MOUSEMOVE = &H200[/SIZE][/FONT] [SIZE=1][FONT=Courier New]%WM_LBUTTONDOWN = &H201[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%WM_LBUTTONUP = &H202[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%WM_LBUTTONDBLCLK = &H203[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%WM_RBUTTONDOWN = &H204[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%WM_RBUTTONUP = &H205[/FONT][/SIZE] [SIZE=1][FONT=Courier New]%WM_RBUTTONDBLCLK = &H206[/FONT][/SIZE] [FONT=Courier New][SIZE=1]%WM_KEYDOWN = &H100[/SIZE][/FONT] [SIZE=1][FONT=Courier New]%WM_CHAR = &H102[/FONT][/SIZE] [FONT=Courier New][SIZE=1]%SM_CXDLGFRAME = 7[/SIZE][/FONT] [SIZE=1][FONT=Courier New]%SM_CYCAPTION = 4[/FONT][/SIZE] [FONT=Courier New][SIZE=1]%SC_MINIMIZE = &HF020&[/SIZE][/FONT] [SIZE=1][FONT=Courier New]%SC_RESTORE = &HF120&[/FONT][/SIZE] [FONT=Courier New][SIZE=1]' -------------------------------------------------------------------------------[/SIZE][/FONT] [FONT=Courier New][SIZE=1]' Windows declarations[/SIZE][/FONT] [FONT=Courier New][SIZE=1]Declare Function AllocConsole Lib "KERNEL32.DLL" Alias "AllocConsole" () As Long[/SIZE][/FONT] [FONT=Courier New][SIZE=1]Declare Function CallWindowProc Lib "USER32.DLL" Alias "CallWindowProcA" (_[/SIZE][/FONT] [SIZE=1][FONT=Courier New] ByVal lpPrevWndFunc As Dword,_[/FONT][/SIZE] [SIZE=1][FONT=Courier New] ByVal hWnd As Dword,_[/FONT][/SIZE] [SIZE=1][FONT=Courier New] ByVal uMsg As Dword,_[/FONT][/SIZE] [SIZE=1][FONT=Courier New] ByVal wParam As Dword,_[/FONT][/SIZE] [SIZE=1][FONT=Courier New] ByVal lParam As Long) As Long[/FONT][/SIZE] [FONT=Courier New][SIZE=1]Declare Function DeleteMenu Lib "USER32.DLL" Alias "DeleteMenu"(_[/SIZE][/FONT] [SIZE=1][FONT=Courier New] ByVal hMenu As Dword,_[/FONT][/SIZE] [SIZE=1][FONT=Courier New] ByVal nPosition As Long,_[/FONT][/SIZE] [SIZE=1][FONT=Courier New] ByVal wFlags As Dword) As Long[/FONT][/SIZE] [FONT=Courier New][SIZE=1]Declare Function FreeConsole Lib "KERNEL32.DLL" Alias "FreeConsole" () As Long[/SIZE][/FONT] [FONT=Courier New][SIZE=1]Declare Function GetLargestConsoleWindowSize Lib "KERNEL32.DLL"_[/SIZE][/FONT] [SIZE=1][FONT=Courier New] Alias "GetLargestConsoleWindowSize"(_[/FONT][/SIZE] [SIZE=1][FONT=Courier New] ByVal hConsoleOutput As Dword) As Dword[/FONT][/SIZE] [FONT=Courier New][SIZE=1]Declare Function GetSystemMenu Lib "USER32.DLL" Alias "GetSystemMenu"(_[/SIZE][/FONT] [SIZE=1][FONT=Courier New] ByVal hWnd As Dword,_[/FONT][/SIZE] [SIZE=1][FONT=Courier New] ByVal bRevert As Long) As Long[/FONT][/SIZE] [FONT=Courier New][SIZE=1]Declare Function GetSystemMetrics Lib "USER32.DLL" Alias "GetSystemMetrics"(_[/SIZE][/FONT] [SIZE=1][FONT=Courier New] ByVal nIndex As Long) As Long[/FONT][/SIZE] [FONT=Courier New][SIZE=1]Declare Function GetWindow Lib "USER32.DLL" Alias "GetWindow" (_[/SIZE][/FONT] [SIZE=1][FONT=Courier New] ByVal hWnd As Dword,_[/FONT][/SIZE] [SIZE=1][FONT=Courier New] ByVal wCmd As Dword) As Long[/FONT][/SIZE] [FONT=Courier New][SIZE=1]Declare Function SetWindowLong Lib "USER32.DLL" Alias "SetWindowLongA" (_[/SIZE][/FONT] [SIZE=1][FONT=Courier New] ByVal hWnd As Dword,_[/FONT][/SIZE] [SIZE=1][FONT=Courier New] ByVal nIndex As Long,_[/FONT][/SIZE] [SIZE=1][FONT=Courier New] ByVal lNewLong As Long) As Long[/FONT][/SIZE] [FONT=Courier New][SIZE=1]Declare Function ShowWindow Lib "USER32.DLL" Alias "ShowWindow" (_[/SIZE][/FONT] [SIZE=1][FONT=Courier New] ByVal hWnd As Dword, ByVal nCmdShow As Long) As Long[/FONT][/SIZE] [FONT=Courier New][SIZE=1]' -------------------------------------------------------------------------------[/SIZE][/FONT] [FONT=Courier New][SIZE=1]#If %ConsoleScreen[/SIZE][/FONT] [FONT=Courier New][SIZE=1]Function ConsoleScreen () As Dword[/SIZE][/FONT] [FONT=Courier New][SIZE=1] 'Installs a full screen console window[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Local WindowSize As Dword[/SIZE][/FONT] [SIZE=1][FONT=Courier New] Local Rows, Columns As Long[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Console Set Loc 0,0[/SIZE][/FONT] [FONT=Courier New][SIZE=1] WindowSize = GetLargestConsoleWindowSize (GetStdOut)[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Rows = (Hi(Word, WindowSize))[/SIZE][/FONT] [SIZE=1][FONT=Courier New] Columns = (Lo(Word, WindowSize))[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Console Set Screen Rows, Columns[/SIZE][/FONT] [FONT=Courier New][SIZE=1] ShowWindow ConsHndl, 3[/SIZE][/FONT] [SIZE=1][FONT=Courier New] DeleteMenu GetSystemMenu(ConsHndl, 0), %SC_Restore, 0 ' Turn resize button off[/FONT][/SIZE] [SIZE=1][FONT=Courier New] Cursor Off[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Function = ConsHndl[/SIZE][/FONT] [FONT=Courier New][SIZE=1]End Function[/SIZE][/FONT] [FONT=Courier New][SIZE=1]#EndIf[/SIZE][/FONT] [FONT=Courier New][SIZE=1]' -------------------------------------------------------------------------------[/SIZE][/FONT] [FONT=Courier New][SIZE=1]#If %SplitScreen[/SIZE][/FONT] [FONT=Courier New][SIZE=1]Function SplitScreen ( Dimension As Long, ByVal RowsOrCols As Asciiz*2 ) As Dword[/SIZE][/FONT] [FONT=Courier New][SIZE=1] ' Installs a console window + graphic window on the full screen[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Global OldProc As Long[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Global LMouse_HA, RMouse_HA As Dword[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Local hWin, hStatic, ConsoleSize As Dword[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Local ClientX, ClientY, ClientWidth, ClientHeight As Long[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Local ConX, ConY, Rows, Cols, ConWidth, ConHeight As Long[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Local GraphicX, GraphicY, GraphicWidth, GraphicHeight As Long[/SIZE][/FONT] [FONT=Courier New][SIZE=1] ' Determine Clientsize and location[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Desktop Get Client To ClientWidth, ClientHeight[/SIZE][/FONT] [SIZE=1][FONT=Courier New] Desktop Get Loc To ClientX, ClientY[/FONT][/SIZE] [FONT=Courier New][SIZE=1] ' Determine maximum console size[/SIZE][/FONT] [FONT=Courier New][SIZE=1] ConsoleSize = GetLargestConsoleWindowSize (GetStdOut)[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Select Case UCase$ (RowsOrCols)[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Case "R" ' Graphic screen above console[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Rows = Dimension[/SIZE][/FONT] [SIZE=1][FONT=Courier New] Cols = (Lo(Word, ConsoleSize)) ' Contains max. Cols[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Console Set Screen Rows, Cols ' Set up console window[/SIZE][/FONT] [SIZE=1][FONT=Courier New] Console Get Size To ConWidth, ConHeight ' Determine size in pixels[/FONT][/SIZE] [FONT=Courier New][SIZE=1] GraphicWidth = ClientWidth - 2 ' Two pixels border line[/SIZE][/FONT] [SIZE=1][FONT=Courier New] GraphicHeight = ClientHeight - ConHeight - 1[/FONT][/SIZE] [FONT=Courier New][SIZE=1] ConX = ClientX + (ClientWidth - ConWidth) \ 2 ' Distribute the difference[/SIZE][/FONT] [SIZE=1][FONT=Courier New] ConY = ClientY + GraphicHeight + 1[/FONT][/SIZE] [FONT=Courier New][SIZE=1] GraphicX = ClientX[/SIZE][/FONT] [SIZE=1][FONT=Courier New] GraphicY = ClientY[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Case "C" ' Graphic screen next to console[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Rows = (Hi(Word, ConsoleSize)) ' Contains max. Rows[/SIZE][/FONT] [SIZE=1][FONT=Courier New] Cols = Dimension[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Console Set Screen Rows, Cols ' Set up console window[/SIZE][/FONT] [SIZE=1][FONT=Courier New] Console Get Size To ConWidth, ConHeight ' Determine size in pixels[/FONT][/SIZE] [FONT=Courier New][SIZE=1] GraphicWidth = ClientWidth - ConWidth - 2[/SIZE][/FONT] [SIZE=1][FONT=Courier New] GraphicHeight = ClientHeight - 2[/FONT][/SIZE] [FONT=Courier New][SIZE=1] ConX = ClientX[/SIZE][/FONT] [SIZE=1][FONT=Courier New] ConY = ClientY + (ClientHeight - ConHeight) \ 2 ' Distribute the difference[/FONT][/SIZE] [FONT=Courier New][SIZE=1] GraphicX = ConWidth + ClientX[/SIZE][/FONT] [SIZE=1][FONT=Courier New] GraphicY = ClientY[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Case Else : Print Dimension; RowsOrCols; "...What ?"[/SIZE][/FONT] [FONT=Courier New][SIZE=1] End Select[/SIZE][/FONT] [FONT=Courier New][SIZE=1] ShowWindow (ConsHndl, 3)[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Console Set Loc ConX, ConY[/SIZE][/FONT] [FONT=Courier New][SIZE=1] DeleteMenu GetSystemMenu(ConsHndl, 0), %SC_Minimize, 0 ' Turn mimimize button off[/SIZE][/FONT] [SIZE=1][FONT=Courier New] DeleteMenu GetSystemMenu(ConsHndl, 0), %SC_Restore, 0 ' Turn resize button off[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Graphic Window "", GraphicX, GraphicY, GraphicWidth, GraphicHeight To hWin[/SIZE][/FONT] [FONT=Courier New][SIZE=1] hStatic = GetWindow(hWin, %GW_CHILD)[/SIZE][/FONT] [FONT=Courier New][SIZE=1] OldProc = SetWindowLong(hStatic, %GWL_WNDPROC, CodePtr (Process_SS_Message))[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Graphic Attach hWin, 0[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Graphic Color %PBS_TextColor, %PBS_Background[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Graphic Font $PBS_Font, %PBS_FontSize, 0[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Graphic Clear[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Console Set Focus[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Cursor Off[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Function = hWin[/SIZE][/FONT] [FONT=Courier New][SIZE=1]End Function[/SIZE][/FONT] [FONT=Courier New][SIZE=1]' -------------------------------------------------------------------------------[/SIZE][/FONT] [FONT=Courier New][SIZE=1]Sub Process_SS_Message( ByVal hWnd As Dword, ByVal wMsg As Dword,_[/SIZE][/FONT] [SIZE=1][FONT=Courier New] ByVal wParam As Dword, ByVal lParam As Long)[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Graphic Attach hWnd,0[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Select Case wMsg[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Case %WM_LBUTTONDOWN[/SIZE][/FONT] [FONT=Courier New][SIZE=1] If LMouse_HA Then Call Dword LMouse_HA BDecl (lparam)[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Case %WM_RBUTTONDOWN[/SIZE][/FONT] [FONT=Courier New][SIZE=1] If RMouse_HA Then Call Dword RMouse_HA BDecl (lparam)[/SIZE][/FONT] [FONT=Courier New][SIZE=1] End Select[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Console Set Focus[/SIZE][/FONT] [FONT=Courier New][SIZE=1] CallWindowProc(OldProc, hWnd, wMsg, wParam, lParam)[/SIZE][/FONT] [FONT=Courier New][SIZE=1]End Sub[/SIZE][/FONT] [FONT=Courier New][SIZE=1]#EndIf[/SIZE][/FONT] [FONT=Courier New][SIZE=1]' -------------------------------------------------------------------------------[/SIZE][/FONT] [FONT=Courier New][SIZE=1]#If %GraphicScreen[/SIZE][/FONT] [FONT=Courier New][SIZE=1]Function GraphicWindow (Caption As String, Xo As Long, Yo As Long,_[/SIZE][/FONT] [SIZE=1][FONT=Courier New] WindowWidth As Long, WindowHeight As Long) As Dword[/FONT][/SIZE] [FONT=Courier New][SIZE=1] ' Installs an arbitrary graphic window with or without titlebar[/SIZE][/FONT] [SIZE=1][FONT=Courier New] ' and with support for mouse and keyboard[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Global OldProc, WindowClosed As Long[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Global LMouse_HA, RMouse_HA, Char_HA, Key_HA As Dword[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Local hWin, hStatic As Dword[/SIZE][/FONT] [FONT=Courier New][SIZE=1] WindowClosed = 0[/SIZE][/FONT] [SIZE=1][FONT=Courier New] FreeConsole[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Graphic Window Caption, Xo, Yo, WindowWidth, WindowHeight To hWin[/SIZE][/FONT] [FONT=Courier New][SIZE=1] hStatic = GetWindow(hWin, %GW_CHILD)[/SIZE][/FONT] [FONT=Courier New][SIZE=1] OldProc = SetWindowLong(hStatic, %GWL_WNDPROC, CodePtr(Process_GS_Message))[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Graphic Attach hWin, 0[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Graphic Set Focus[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Graphic Color %PBS_TextColor, %PBS_Background[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Graphic Font $PBS_Font, %PBS_FontSize, 0[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Graphic Clear[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Function = hWin[/SIZE][/FONT] [FONT=Courier New][SIZE=1]End Function[/SIZE][/FONT] [FONT=Courier New][SIZE=1]' -------------------------------------------------------------------------------[/SIZE][/FONT] [FONT=Courier New][SIZE=1]Function GraphicScreen (Caption As String) As Dword[/SIZE][/FONT] [FONT=Courier New][SIZE=1] ' Determines the parameters for a full screen graphic window[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Local ClientX, ClientY, ClientWidth, ClientHeight As Long[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Local CaptionHeight, FrameWidth, WindowWidth, WindowHeight As Long[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Desktop Get Client To ClientWidth, ClientHeight[/SIZE][/FONT] [SIZE=1][FONT=Courier New] Desktop Get Loc To ClientX, ClientY[/FONT][/SIZE] [FONT=Courier New][SIZE=1] If Caption = "" Then[/SIZE][/FONT] [FONT=Courier New][SIZE=1] FrameWidth = 2[/SIZE][/FONT] [SIZE=1][FONT=Courier New] CaptionHeight = 0[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Else[/SIZE][/FONT] [FONT=Courier New][SIZE=1] FrameWidth = 2 * GetSystemMetrics (%SM_CXDLGFRAME)[/SIZE][/FONT] [SIZE=1][FONT=Courier New] CaptionHeight = GetSystemMetrics (%SM_CYCAPTION)[/FONT][/SIZE] [FONT=Courier New][SIZE=1] End If[/SIZE][/FONT] [FONT=Courier New][SIZE=1] WindowWidth = ClientWidth - FrameWidth[/SIZE][/FONT] [FONT=Courier New][SIZE=1] WindowHeight = ClientHeight - FrameWidth - CaptionHeight[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Function = GraphicWindow (Caption, ClientX, ClientY, WindowWidth, WindowHeight)[/SIZE][/FONT] [FONT=Courier New][SIZE=1]End Function[/SIZE][/FONT] [FONT=Courier New][SIZE=1]' -------------------------------------------------------------------------------[/SIZE][/FONT] [FONT=Courier New][SIZE=1]Sub Process_GS_Message( ByVal hWnd As Dword, ByVal wMsg As Dword,_[/SIZE][/FONT] [SIZE=1][FONT=Courier New] ByVal wParam As Dword, ByVal lParam As Long)[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Graphic Attach hWnd,0[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Select Case wMsg[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Case %WM_DESTROY : WindowClosed = -1 ' To be properly processed[/SIZE][/FONT] [SIZE=1][FONT=Courier New] ' after window has been closed[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Case %WM_LBUTTONDOWN[/SIZE][/FONT] [FONT=Courier New][SIZE=1] If LMouse_HA Then Call Dword LMouse_HA BDecl (lparam)[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Case %WM_RBUTTONDOWN[/SIZE][/FONT] [FONT=Courier New][SIZE=1] If RMouse_HA Then Call Dword RMouse_HA BDecl (lparam)[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Case %WM_CHAR[/SIZE][/FONT] [FONT=Courier New][SIZE=1] If Char_HA Then Call Dword Char_HA BDecl (wparam)[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Case %WM_KEYDOWN[/SIZE][/FONT] [FONT=Courier New][SIZE=1] If Key_HA Then Call Dword Key_HA BDecl (wparam)[/SIZE][/FONT] [FONT=Courier New][SIZE=1] End Select[/SIZE][/FONT] [FONT=Courier New][SIZE=1] CallWindowProc(OldProc, hWnd, wMsg, wParam, lParam)[/SIZE][/FONT] [FONT=Courier New][SIZE=1]End Sub[/SIZE][/FONT] [FONT=Courier New][SIZE=1]#EndIf[/SIZE][/FONT] [FONT=Courier New][SIZE=1]' -------------------------------------------------------------------------------[/SIZE][/FONT] [FONT=Courier New][SIZE=1]#If %ExampleHandler[/SIZE][/FONT] [FONT=Courier New][SIZE=1]Sub ExampleMouseHandler (MousePos As Dword)[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Local x, y As Single[/SIZE][/FONT] [FONT=Courier New][SIZE=1] x = Lo (Word,MousePos)[/SIZE][/FONT] [SIZE=1][FONT=Courier New] y = Hi (Word,MousePos)[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Graphic Line (x - 3, y) - (x + 4, y), %White[/SIZE][/FONT] [SIZE=1][FONT=Courier New] Graphic Line (x, y - 3) - (x, y + 4), %White[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Print x, y[/SIZE][/FONT] [FONT=Courier New][SIZE=1]End Sub[/SIZE][/FONT] [FONT=Courier New][SIZE=1]' -------------------------------------------------------------------------------[/SIZE][/FONT] [FONT=Courier New][SIZE=1]Sub ExampleCharHandler (Character As Dword)[/SIZE][/FONT] [FONT=Courier New][SIZE=1] %PBS_TopMargin = 10[/SIZE][/FONT] [SIZE=1][FONT=Courier New] %PBS_LeftMargin = 10[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Static x, y As Single[/SIZE][/FONT] [SIZE=1][FONT=Courier New] Local CharWidth, CharHeight As Single[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Graphic Chr Size To CharWidth, CharHeight[/SIZE][/FONT] [FONT=Courier New][SIZE=1] x = Max (x, %PBS_LeftMargin)[/SIZE][/FONT] [SIZE=1][FONT=Courier New] y = Max (y, %PBS_TopMargin)[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Select Case Character[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Case %Key_Bsp[/SIZE][/FONT] [FONT=Courier New][SIZE=1] x = x - CharWidth[/SIZE][/FONT] [SIZE=1][FONT=Courier New] Graphic Set Pos (x,y)[/FONT][/SIZE] [SIZE=1][FONT=Courier New] Graphic Print Chr$(32)[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Case %Key_Enter[/SIZE][/FONT] [FONT=Courier New][SIZE=1] x = %PBS_LeftMargin[/SIZE][/FONT] [SIZE=1][FONT=Courier New] y = y + CharHeight[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Case > 31[/SIZE][/FONT] [FONT=Courier New][SIZE=1] Graphic Set Pos (x,y)[/SIZE][/FONT] [SIZE=1][FONT=Courier New] Graphic Print Chr$(Character);[/FONT][/SIZE] [SIZE=1][FONT=Courier New] x = x + Charwidth[/FONT][/SIZE] [SIZE=1][FONT=Courier New] End Select[/FONT][/SIZE] [FONT=Courier New][SIZE=1]End Sub[/SIZE][/FONT] [FONT=Courier New][SIZE=1]#EndIf[/SIZE][/FONT] [FONT=Courier New][SIZE=1]' -------------------------------------------------------------------------------[/SIZE][/FONT] [SIZE=1][FONT=Courier New]' END OF PBScreen INCLUDE FILE[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' -------------------------------------------------------------------------------[/FONT][/SIZE]
Code:
[FONT=Courier New][SIZE=1]'------------------------------------------------------------------------[/SIZE][/FONT] [SIZE=1][FONT=Courier New]' Demonstration of PBScreen.inc[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'[/FONT][/SIZE] [SIZE=1][FONT=Courier New]' Arie Verheul[/FONT][/SIZE] [SIZE=1][FONT=Courier New]'------------------------------------------------------------------------[/FONT][/SIZE] [FONT=Courier New][SIZE=1]#Compile Exe[/SIZE][/FONT] [SIZE=1][FONT=Courier New]#Dim All[/FONT][/SIZE] [FONT=Courier New][SIZE=1]%ExampleHandler = 1[/SIZE][/FONT] [FONT=Courier New][SIZE=1]#Include "PBScreen.inc"[/SIZE][/FONT] [FONT=Courier New][SIZE=1]'------------------------------------------------------------------------[/SIZE][/FONT] [FONT=Courier New][SIZE=1]Sub DoSomething (Capture As String)[/SIZE][/FONT] [FONT=Courier New][SIZE=1] ' In case no console or graphic window is present[/SIZE][/FONT] [SIZE=1][FONT=Courier New] ' the respective instructions are ignored.[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Locate 3,5[/SIZE][/FONT] [SIZE=1][FONT=Courier New] Print "Console window"[/FONT][/SIZE] [SIZE=1][FONT=Courier New] Print[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Graphic Set Pos (50,200)[/SIZE][/FONT] [SIZE=1][FONT=Courier New] Graphic Print Capture[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Graphic Box (350,350)-(500,500),0,%Blue[/SIZE][/FONT] [SIZE=1][FONT=Courier New] Graphic Box (300,300)-(450,450),0,%Yellow[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Sleep 5000[/SIZE][/FONT] [FONT=Courier New][SIZE=1]End Sub[/SIZE][/FONT] [FONT=Courier New][SIZE=1]'------------------------------------------------------------------------[/SIZE][/FONT] [FONT=Courier New][SIZE=1]Function PBMain () As Long[/SIZE][/FONT] [FONT=Courier New][SIZE=1] ConsoleScreen[/SIZE][/FONT] [SIZE=1][FONT=Courier New] Console Name "Full screen console window"[/FONT][/SIZE] [SIZE=1][FONT=Courier New] DoSomething ("")[/FONT][/SIZE] [FONT=Courier New][SIZE=1] SplitScreen (30, "Cols")[/SIZE][/FONT] [SIZE=1][FONT=Courier New] Console Name "Split screen"[/FONT][/SIZE] [SIZE=1][FONT=Courier New] LMouse_HA = CodePtr (ExampleMouseHandler) ' Install mouse handler[/FONT][/SIZE] [SIZE=1][FONT=Courier New] RMouse_HA = CodePtr (ExampleMouseHandler)[/FONT][/SIZE] [SIZE=1][FONT=Courier New] DoSomething ("Graphic window, mouse click is supported")[/FONT][/SIZE] [SIZE=1][FONT=Courier New] Graphic Window End[/FONT][/SIZE] [FONT=Courier New][SIZE=1] SplitScreen (10, "Rows")[/SIZE][/FONT] [SIZE=1][FONT=Courier New] DoSomething ("Graphic window, mouse click is supported")[/FONT][/SIZE] [SIZE=1][FONT=Courier New] Graphic Window End[/FONT][/SIZE] [FONT=Courier New][SIZE=1] GraphicWindow "Graphic window with built-in mouse and keyboard support",100,100,800,550[/SIZE][/FONT] [SIZE=1][FONT=Courier New] Char_HA = CodePtr (ExampleCharHandler) ' Install keyboard handler[/FONT][/SIZE] [SIZE=1][FONT=Courier New] DoSomething ("Graphic window with mouse click and keyboard support")[/FONT][/SIZE] [SIZE=1][FONT=Courier New] Graphic Window End[/FONT][/SIZE] [FONT=Courier New][SIZE=1] GraphicScreen ("")[/SIZE][/FONT] [SIZE=1][FONT=Courier New] DoSomething ("Graphic screen without titlebar, keyboard and mouse click are supported")[/FONT][/SIZE] [SIZE=1][FONT=Courier New] Graphic Window End[/FONT][/SIZE] [FONT=Courier New][SIZE=1] GraphicScreen ("Graphic screen")[/SIZE][/FONT] [SIZE=1][FONT=Courier New] DoSomething ("Graphic screen with titlebar, keyboard and mouse click are supported")[/FONT][/SIZE] [SIZE=1][FONT=Courier New] Graphic Set Pos (50,230)[/FONT][/SIZE] [SIZE=1][FONT=Courier New] Graphic Print "Close window when done ..."[/FONT][/SIZE] [FONT=Courier New][SIZE=1] Do : Sleep 1000 : Loop Until WindowClosed[/SIZE][/FONT] [FONT=Courier New][SIZE=1]End Function[/SIZE][/FONT] [FONT=Courier New][SIZE=1]'------------------------------------------------------------------------[/SIZE][/FONT]
Comment