Modeless Dialog Boxes


Typically a dialog box accepts user input and processes that input when the OK button is pressed. After processing, the dialog box is dismissed. The dialog box is modal because the processing steps most occur sequentially and the main application is effectively blocked such that no further application processing can occur until the dialog box is dismissed,


A modeless dialog box is similar to a toolbar. After the OK button is pressed,  the dialog box remains on the screen until it is explicitly cancelled by the use. When the dialog box is on screen, the application is not blocked and the user can continue to interact with the application. For example, a modeless dialog box that generates a waveform allows the user to scroll, zoom or alter the contents of a window while the dialog box is displayed.


Specifying a value of 1 for the @modeless option creates a modeless dialog box. The menureturn function must be used in the execution statement area to prevent the dialog box from being dismissed after the OK button is pressed.


// modeless.pan - modeless dialog box



// modeless

@modeless 1


// adjust width and height

@adjust_width  1

@adjust_height 1


// default values

{defvar("dist", 0);defvar("len", 100);defvar("dx", 0.01)}

Generate Random Data

Distribution <r n>~dist = <{dist}>~<Uniform><Normal>

Length:      <w=20>~len = <{len}>~input(2)

Delta X:     <w=20>~dx  = <{dx}>~input(1)


~if(dist==0, gfunc = "Grandom", gfunc = "Gnormal")

~eval(sprintf("W0 := %s(%d, %g)", gfunc, len, dx))




Although there is no change in appearance, the dialog box remains on screen after the OK button is pressed. The dialog box is not dismissed until the Cancel button is pressed. When the dialog box is displayed, the user can select the target window by using the mouse or keyboard in the main application.


To keep the dialog box displayed on top of the main application when the application is activated, use @modeless 2.


The MENUDELETE function explicitly dismisses a modeless dialog box identified by a menu handle. For example:


// invoke dialog box and save handle

m = menufile("modeless.pan");


// dismiss dialog box



MENUFILE returns the menu handle suitable for MENUDLETE.