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 for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information
simulating_20a_20modal_20dialogue_20box.txt · Last modified: 2018/04/15 17:30 by richardrussell