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**:

code format="bb4w" PROC_showdialog(dlg%) SYS "EnableWindow", @hwnd%, 0 code Second, explicitly enable your main window immediately before the call to **PROC_closedialog**:

code format="bb4w" SYS "EnableWindow", @hwnd%, 1 PROC_closedialog(dlg%) code 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:

code format="bb4w" ON CLOSE SYS "EnableWindow",@hwnd%,1:PROC_closedialog(dlg%):QUIT ON ERROR SYS "EnableWindow",@hwnd%,1:PROC_closedialog(dlg%):.... code 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**:

code format="bb4w" PROC_showdialog(dlg%) SYS "EnableWindow", @hwnd%, 0 SYS "EnableWindow", !otherdlg%, 0

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