A dialog box is a pop-up windows that contains a system menu and a variety of dialog box items. Dialog boxes are created from with in a batch file using the DLGBOX command. The items are added to a dialog box using the DLGITEM command. Dialog boxes may include any of the following items :-
- Push button
- Radio button
- List box
- Check box
- Group box
- Combo box
- Edit text
- static text
After a dialog box has been created and all the items have been added the DLGSHOW command is used to display the dialog box and activate it. Events generated by the items in the dialog box are handled by the procedures assigned to each item. Not all dialog items require procedures since many items do not generate any events, for example, Group boxes, Edit text, Static text, Rectangles and Frames do not generate any events. Dialog box items that do generate events may also not require a procedure when the event generated by the item requires no action. Typically, this will not be the case and items that do generate events will have a procedure assigned to them.
Unlike the procedures assigned to items, which handle events generated by each item, a dialog box may also be assigned a procedure, which is called only once just before the dialog box is displayed. Typically, the procedure assigned to a dialog box is used to initialise any of the items contained in the dialog box.
There are a number of commands that may be used to manipulate items contained in a dialog box. In general, these commands will be used from with in the procedures assigned to the items in a dialog box that generate events. Once a dialog box is no longer needed the DLGEND command may be used to close the dialog box and cause the batch file to return control to the respective DLGSHOW command that was used to displayed the dialog box.
Essentially, dialog boxes are written using a methodology which is commonly referred to as event-driven programming which differs from a typical batch file which uses a sequential programming methodology. Sequential programs have a distinct beginning, flow of control (ie. a logical sequence of events) and a distinct end, as follows :-
Event-driven batch files are controlled by the occurrence of events generated by the items contained in each dialog box and unlike the sequential methodology, these events may occur in any order. The following outlines the event-driven methodology :-
Dialog boxes may be nested, that is, dialog boxes may be created, displayed and manipulated from with in another dialog box. This includes using any of the special purpose built in dialog boxes such as MSGBOX, EDITBOX, DISPBOX, OPENBOX and SAVEBOX.