GUI statement
Purpose: The GUI
statement
specifies that the program is a Graphical User Interface application and
provides a ClassName for the program. The GUI statement must be placed
at the start of the program and can not be placed inside any SUB,
FUNCTION
or within the BEGIN EVENTS...END EVENTS
loop. It must be placed at the module level, the same level at which your directives
and global variables are declared.
Syntax 1: GUI "ClassName" [,PIXELS, ICON, ResInt%] Syntax 2: GUI NOMAIN [,PIXELS, ICON, ResInt%]
Parameters:
|
Remarks:
As well as the GUI
statement, a minimal BCX
GUI
program must have a SUB FORMLOAD ... END SUB
procedure , which translates to a WinMain function, and as well a
BEGIN EVENTS ... END EVENTS
procedure. See below for an example.
In a BCX GUI
program,
all expressions must be inside a FUNCTION, SUB or the BEGIN EVENTS...END EVENTS
procedure.
Note well, a GUI NOMAIN
(see below) program
must NOT use a SUB FORMLOAD ... END SUB
procedure
but instead GUI NOMAIN
requires that the programmer
provide a WinMain equivalent and the other basic functions
to register a ClassName and provide a message pump.
BCX_WndClass and BCX_GUI_Init
When a BCX GUI program is translated, a WNDCLASSEX structure named BCX_WndClass is created and declared GLOBAL. It is initialized to the default values in the internal BCX translator BCX_InitGUI() procedure and then registered using the internal BCX translator BCX_REGWND procedure. BCX_REGWND checks to see if a window class of the name being registered has already been used and if so does not register it again. It allows 256 different(non case sensitive) window classes to be registered. It also sets the BCX_GUI_INIT variable to TRUE, indicating that the procedure has been run and it will exit without doing anything next time it is called.
BCX_HINSTANCE
When a BCX GUI program is translated, an HINSTANCE named BCX_HINSTANCE is created and declared GLOBAL. It is initialized to the value of the HINSTANCE of WinMain. From that point on, you are free to reference it. BCX_HINSTANCE should be considered a READ-ONLY HINSTANCE -- changing its value at runtime is not advisable.
BCX_SCALEX and BCX_SCALEY variables.
As well as BCX_HINSTANCE, two other user accessible variables, BCX_SCALEX and BCX_SCALEY are created when a BCX GUI program is translated. BCX provides the ability to read the value of BCX_SCALEX and BCX_SCALEY variables.
Purpose: BCX_SCALEX and BCX_SCALEY variables are used by BCX to scale horizontal and vertical placement and size of GUI controls. A default scaling factor is calculated by BCX based on the Win32API function GetDialogBaseUnits() which always assumes the system font is being used when calculating the dialog units that form the basis of the scaling values.
If any font other than the system font is used, then the return value from the default scaling may not be correct for your dialog box. And if different fonts are used in controls in a dialog box, then user modifiable scaling is needed.
To be clear ... BCX_SCALEX and BCX_SCALEY are intended to be READ ONLY variables to assist in modifying the values used in dimensioning GUI controls. If the value of BCX_SCALEX or BCX_SCALEY is modified after the system initializes them, then unforeseen consequences may occur.
Syntax: NumberX = BCX_SCALEX NumberY = BCX_SCALEY Parameters:
|
The following is a minimal BCX GUI
program.
' -------BCX Code start-------------------- GUI "BCX_Template" SUB FORMLOAD GLOBAL Form1 AS HWND Form1 = BCX_FORM("BCX_TEMPLATE", 0, 0, 110, 110) BCX_SET_FORM_COLOR(Form1,QBCOLOR(31)) CENTER(Form1) SHOW(Form1) END SUB BEGIN EVENTS SELECT CASE CBMSG CASE WM_CLOSE DestroyWindow(Form1) EXIT FUNCTION END SELECT END EVENTS ' -------BCX Code end----------------------
GUI NOMAIN statement
Purpose: The GUI NOMAIN
statement specifies
that a WinMain function will not be automatically emitted.
NOMAIN requires, at least, that the programmer provide a WinMain equivalent,
register a ClassName and provide a message pump.
The GUI NOMAIN
statement is similar to the
$NOMAIN
directive used in console mode programs.
The GUI NOMAIN statement must be placed
at the start of the program and can not be placed inside any SUB,
FUNCTION
or within the BEGIN EVENTS...END EVENTS
loop. It must be placed at the module level, the same level at which your directives
and global variables are declared.
Syntax: GUI NOMAIN [,PIXELS, ICON, ResInt%]
Parameters:
|
Remarks:
In a BCX GUI NOMAIN
program,
all expressions must be inside a FUNCTION, SUB or the BEGIN EVENTS...END EVENTS
procedure.
BCX_WndClass and BCX_GUI_Init
When a BCX GUI NOMAIN program is translated, a WNDCLASSEX structure named BCX_WndClass is created and declared GLOBAL. It is initialized to the default values by the internal BCX translator BCX_INITGUI() procedure and then registered using the internal BCX translator BCX_REGWND procedure. BCX_REGWND checks to see if a window class of the name being registered has already been used and if so does not register it again. It allows 256 different(non case sensitive) window classes to be registered. It also sets the BCX_GUI_INIT variable to TRUE, indicating that the procedure has been run and it will exit without doing anything next time it is called.
BCX_REGWND statement
Purpose: BCX_REGWND registers a window class. If the WndProc is NULL then ClassName$ will be removed from the list of windows classes registered in BCX and the class will be unregisted with UnregisterClass WinAPI call.
Syntax:
Parameters:
|
BCX_MSGPUMP statement
Purpose: BCX_MSGPUMP creates a message loop to retrieve messages, from the message queue of the non-MDI gui programs, and dispatch them to the destination window procedures.
Syntax:
Parameters:
|
BCX_MDI_MSGPUMP statement
Purpose: BCX_MDI_MSGPUMP creates a message loop to retrieve messages, from the message queue of a MDI gui program, and dispatch them to the destination window procedures.
Syntax:
Parameters:
|
BCX_SETMETRIC statement
Purpose: sets either pixels or dlgunits can be either "pixels" or "dlgUnits"(not case sensitive).
Syntax:
Parameters:
|
The following procedures are used to replace members of the WNDCLASSEX structure. For more details on this replacement see the SetClassLong Function in your Win32 SDK or PSDK Reference help.
BCX_SETBKGRDBRUSH statement
Purpose: BCX_SETBKGRDBRUSH sets the background brush.
Syntax:
Parameters:
|
BCX_SETCLASSSTYLE statement
Purpose: BCX_SETCLASSSTYLE sets the class style.
Syntax:
Parameters:
|
BCX_SETICON statement
Purpose: BCX_SETICON sets the Icon.
Syntax:
Parameters:
|
BCX_SETICONSM statement
Purpose: BCX_SETICONSM sets the small Icon .
Syntax:
Parameters:
|
BCX_SETCURSOR statement
Purpose:BCX_SETCURSOR sets the cursor.
Syntax:
Parameters:
|
Example
BCX_RESOURCE
123
ICON
"bcx.ico"
GUI
NOMAIN
,ICON
,123
DIM
FooBlooAS
HACCELFUNCTION
WINMAINGLOBAL
Form1AS
HWNDBCX_SETMETRIC
(
"DialogUnits"
)
BCX_REGWND
(
"MAINFORM"
, form1Proc)
Form1=
BCX_FORM
(
"BCX_TEMPLATE"
,0
,0
,110
,110
)
BCX_SET_FORM_COLOR
(
Form1,QBCOLOR
(
31
)
)
CENTER
(
Form1)
SHOW
(
Form1)
FUNCTION
=
BCX_MSGPUMP
(
FooBloo)
END
FUNCTION
BEGIN
EVENTS
form1ProcSELECT
CASE
CBMSG
CASE
WM_KEYDOWNSELECT
CASE
wParamCASE
VK_HOMEMSGBOX
"VK_HOME"
CASE
VK_ENDMSGBOX
"VK_END"
CASE
VK_NEXTMSGBOX
"VK_NEXT"
CASE
VK_PRIORMSGBOX
"VK_PRIOR"
CASE
VK_DOWNMSGBOX
"VK_DOWN"
CASE
VK_UPMSGBOX
"VK_UP"
CASE
VK_LEFTMSGBOX
"VK_LEFT"
CASE
VK_RIGHTMSGBOX
"VK_RIGHT"
CASE
VK_RETURNMSGBOX
"VK_RETURN"
END
SELECT
CASE
WM_CLOSE DestroyWindow(
Form1)
END
SELECT
END
EVENTS
MAIN