User Tools

Site Tools


simulating_20a_20modal_20dialogue_20box

Simulating a modal dialogue box

by Richard Russell, October 2006

Dialogue boxes created using the functions in the WINLIB2 library are modeless dialogue boxes, that is the main window (and any other dialogue boxes) remain active whilst they are open. If you want to simulate the behaviour of a modal dialogue box, which disables the main window whilst it is open, you can do that quite easily.

First, explicitly disable your main window immediately after the call to PROC_showdialog:

        PROC_showdialog(dlg%)
        SYS "EnableWindow", @hwnd%, 0

Second, explicitly enable your main window immediately before the call to PROC_closedialog:

        SYS "EnableWindow", @hwnd%, 1
        PROC_closedialog(dlg%)

If necessary replace dlg% with the appropriate value returned from FN_newdialog.

It is also wise to re-enable your window on exit or in the event of an error:

        ON CLOSE SYS "EnableWindow",@hwnd%,1:PROC_closedialog(dlg%):QUIT
        ON ERROR SYS "EnableWindow",@hwnd%,1:PROC_closedialog(dlg%):....

Generally this is all you will need to do. If you have other open dialogue boxes, and you wish to disable them, you can do so using the same technique, remembering that the dialogue box handle is stored in memory at the address returned from FN_newdialog:

        PROC_showdialog(dlg%)
        SYS "EnableWindow", @hwnd%, 0
        SYS "EnableWindow", !otherdlg%, 0
 
        SYS "EnableWindow", @hwnd%, 1
        SYS "EnableWindow", !otherdlg%, 1
        PROC_closedialog(dlg%)
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
simulating_20a_20modal_20dialogue_20box.txt · Last modified: 2024/01/05 00:21 by 127.0.0.1