BCX_MDIALOG creates a modal dialog box and the system then makes the modal dialog box the active window. When a dialog box is modal, other dialogs of the same application cannot be put on top of it and the modal dialog box owner window cannot be made active until the modal dialog box is destroyed.
Syntax:RetVal = BCX_MDIALOG(DlgProcName AS DLGPROC, _ DlgTitle AS STRING, _ hwndParent AS HWND, _ Xpos AS INTEGER, _ Ypos AS INTEGER, _ Width AS INTEGER, _ Height AS INTEGER _ [, WinStyle AS INTEGER] _ [, ExWinStyle AS INTEGER] _ [, FontFace AS STRING] _ [, FontSize AS INTEGER]) Return Value:
Parameters:
|
For a dialog box based application, a modal BCX_MDIALOG is best.
When BCX_MDIALOG is detected within the WinMain function the following globals will be defined: BCX_HINSTANCE, BCX_SCALEX and BCX_SCALEY In addition to this BCX_HINSTANCE = hinst will be emitted immediately before the first occurrence of BCX_MDIALOG.
This allows Dialog based apps to be setup as:
FUNCTION WinMain FUNCTION = BCX_MDIALOG(...) END FUNCTION
In dialogs (callback functions), when declaring variables that you wish to hold a value for the life of the function, it is best to avoid using DIM or LOCAL and instead use STATIC. The reason for doing this is that code is emitted to clear the variable each time the callback function calls itself, which would be many times while the dialog is open.
So instead of declaring as
DIM hwndHot AS CONTROL
it is better to use
STATIC hwndHot AS CONTROL
The following demo shows how a dialog box based application can be setup
$BCXVERSION "5.05.172" GLOBAL hEdit1 AS HWND GLOBAL hButton1 AS HWND GLOBAL hButton2 AS HWND GLOBAL hStatic1 AS HWND FUNCTION WINMAIN () FUNCTION = BCX_MDIALOG(InputBox,"InputBox App",0,157, 76, 146, 41) END FUNCTION BEGIN MODAL DIALOG AS InputBox LOCAL Txt$ SELECT CASE Msg CASE WM_INITDIALOG hEdit1 = BCX_EDIT("BCX is cool!",hWnd,101, 3, 6, 69, 12) hButton1 = BCX_BUTTON("Okay",hWnd,102,4, 23, 40, 14) hButton2 = BCX_BUTTON("Cancel",hWnd, 104, 100, 23, 40, 14) hStatic1 = BCX_LABEL(" ",hWnd, 103, 78, 6, 64, 10) CENTER(hWnd) CASE WM_COMMAND IF CBCTLMSG = BN_CLICKED THEN IF CBCTL = 102 THEN 'clicked the okay button Txt$ = BCX_GET_TEXT$(hEdit1) BCX_SET_TEXT(hStatic1,Txt$) END IF IF CBCTL = 104 THEN 'clicked the cancel button CLOSEDIALOG END IF END IF END SELECT END DIALOG
The following demo shows how a dialog box based application can be setup
$BCXVERSION "7.1.8" GLOBAL hEdit1 AS HWND GLOBAL hButton1 AS HWND GLOBAL hButton2 AS HWND GLOBAL hStatic1 AS HWND FUNCTION WINMAIN () FUNCTION = BCX_MDIALOG(InputBox,"InputBox App", _ 0, 157, 76, 146, 61, 0, 0, "TAHOMA", 16) END FUNCTION BEGIN MODAL DIALOG AS InputBox LOCAL Txt$ SELECT CASE Msg CASE WM_INITDIALOG hEdit1 = BCX_EDIT("BCX is cool!", hWnd, 101, 3, 6, 69, 30) hButton1 = BCX_BUTTON("Okay", hWnd, 102, 4, 43, 40, 14) hButton2 = BCX_BUTTON("Cancel", hWnd, 104, 100, 43, 40, 14) hStatic1 = BCX_LABEL(" ", hWnd, 103, 78, 6, 64, 30) BCX_SET_FONT(hStatic1, "TAHOMA", 12) 'for comparison CENTER(hWnd) CASE WM_COMMAND IF CBCTLMSG = BN_CLICKED THEN IF CBCTL = 102 THEN 'clicked the okay button Txt$ = BCX_GET_TEXT$(hEdit1) BCX_SET_TEXT(hStatic1, Txt$) END IF IF CBCTL = 104 THEN 'clicked the cancel button CLOSEDIALOG END IF END IF END SELECT END DIALOG
BCX_DIALOG creates a modeless dialog box and the system makes it the active window. The user or the application can change, at any time, the active modeless dialog box window, unlike a modal dialog box.
BCX_DIALOG calls a user created callback function that has this basic form
BEGIN DIALOG AS DlgProcName END DIALOG
and which contains code that is responsible for monitoring and responding to messages and commands to and from the dialog box like mouse clicks, button presses, radio controls and so on.
The keyword CLOSEDIALOG may be used to close a dialog box window in response to a button or keypress.
👉 There is currently a limit of 32 unique modeless dialogs that may be open at any one time.
It is important to remember that this block is a callback routine which can be called several times before any specific task contained in the block is completed. For this reason, it is best that any variables, which must be declared in the BEGIN DIALOG ... END DIALOG block, should be declared as STATIC or DIM RAW. When DIM or LOCAL are used, BCX emits code to automatically clear the variable to zero and so if a callback occurs before a task is completed the DIM or LOCAL variables will be cleared to zero and the task will fail.
Syntax:hCtl = BCX_DIALOG(DlgProcName, _ DlgTitle AS STRING, _ hwndParent AS HWND, _ Xpos AS INTEGER, _ Ypos AS INTEGER, _ Width AS INTEGER, _ Height AS INTEGER _ [, WinStyle AS INTEGER] _ [, ExWinStyle AS INTEGER] _ [, FontFace AS STRING] _ [, FontSize AS INTEGER]) Return Value:
Parameters:
|
In dialogs (callback functions), when declaring variables that you wish to hold a value for the life of the function, it is best to avoid using DIM or LOCAL and instead use STATIC. The reason for doing this is so that code is emitted to clear the variable each time the callback function calls itself, which would be many times while the dialog is open.
So instead of declaring as
DIM hwndHot AS CONTROL
it is better to use
STATIC hwndHot AS CONTROL
$BCXVERSION "5.05.174" GUI "DialogTest" GLOBAL Form1 AS CONTROL SUB FORMLOAD Form1 = BCX_FORM("Dialog Test",0,0,120,60) BCX_BUTTON("Modal",Form1,98,8,10,100,16) BCX_BUTTON("Modeless",Form1,99,8,30,100,16) CENTER(Form1) SHOW(Form1) END SUB '---------------------------------------------------- BEGIN EVENTS SELECT CASE CBMSG CASE WM_COMMAND IF CBCTLMSG = BN_CLICKED THEN IF CBCTL = 98 THEN BCX_MDIALOG(DialogOne,"BCX Modal Dialog",Form1,-110,-110,110,110) END IF IF CBCTL = 99 THEN BCX_DIALOG(DialogTwo,"BCX Modeless Dialog",Form1,110,110,110,110) END IF END IF END SELECT END EVENTS '---------------------------------------------------- BEGIN MODAL DIALOG AS DialogOne SELECT CASE CBMSG CASE WM_INITDIALOG SHOW(hWnd) END SELECT END DIALOG '---------------------------------------------------- BEGIN DIALOG AS DialogTwo SELECT CASE CBMSG CASE WM_INITDIALOG SHOW(hWnd) END SELECT END DIALOG