Dialog Boxes in VB
Dialog Boxes in VB
The graphical control element dialog box (or dialogue box) is a small window that
communicates information between the users and prompts for a response. Dialog boxes are
classified as "modal" or "modeless", depending on whether or not they block interaction with
the software that initiated the dialog. The type of dialog box displayed is dependent upon the
desired user interaction. The simplest type of dialog box is the alert, which displays a
message and may require an acknowledgment that the message has been read, usually by
clicking "OK", or a decision as to whether or not an action should proceed, by clicking "OK"
or "Cancel".
MODELESS
Non-modal or modeless dialog boxes are used when the requested information is not
essential to continue, and so the window can be left open while work continues elsewhere. A
type of modeless dialog box is a toolbar which is either separate from the main application, or
may be detached from the main application, and items in the toolbar can be used to select
certain features or functions of the application. In general, good software design calls for
dialogs to be of this type where possible, since they do not force the user into a particular
mode of operation. An example might be a dialog of settings for the current document, e.g.
the background and text colors. The user can continue adding text to the main window
whatever color it is, but can change it at any time using the dialog. (This isn't meant to be an
example of the best possible interface for this; often the same functionality may be
accomplished by toolbar buttons on the application's main window.)
1
APPLICATION MODAL
Modal dialog boxes temporarily halt the program: the user cannot continue without
closing the dialog; the program may require some additional information before it can
continue, or may simply wish to confirm that the user wants to proceed with a potentially
dangerous course of action (confirmation dialog box). Usability practitioners generally regard
modal dialogs as bad design-solutions, since they are prone to produce mode errors.
Dangerous actions should be undoable wherever possible; a modal alert dialog that appears
unexpectedly or which is dismissed automatically (because the user has developed a habit)
will not protect from the dangerous action. A modal dialog interrupts the main workflow.
This effect has either been sought because it focuses on the completion of the task at hand or
rejected because it prevents the user from changing to a different task when needed.
DOCUMENT MODAL
The concept of a document modal dialog has recently been used, most notably in OS
X and Opera Browser. In the first case, they are shown as sheets attached to a parent window.
These dialogs block only that window until the user dismisses the dialog, permitting work in
other windows to continue, even within the same application. In OS X, dialogs appear to
emanate from a slot in their parent window, and are shown with a reinforcing animation. This
helps to let the user understand that the dialog is attached to the parent window, not just
shown in front of it. No work can be done in the underlying document itself while the dialog
is displayed, but the parent window can still be moved, re-sized, and minimized, and other
windows can be brought in front so the user can work with them. The same type of dialog
box can be compared with the "standard" modal dialog boxes used in Windows and other
operating systems. Similarities include:
the parent window is frozen when the dialog box opens, and one cannot continue
to work with the underlying document in that window
no work can be done with the underlying document in that window.
2
depending on where the parent window is located, the dialog box may open
virtually anywhere on screen
the dialog box may be moved (in almost all cases), in some cases may be
resizable, but usually cannot be minimized, and
no changes to the parent window are possible (cannot be resized, moved or
minimized) while the dialog box is open.
The Windows dialog box locks the parent window which can hide other windows
the user may need to refer to while interacting with the dialog, though this may be
mitigated since other windows are available through the task bar.
The OS X dialog box blocks the parent window, preventing the user from
referring to it while interacting with the dialog. This may require the user to close
the dialog to access the necessary information, then re-open the dialog box to
continue.
A box that appears on a display screen to present information or request input.
Typically, dialog boxes are temporary -- they disappear once you have entered the
requested information.
In the Macintosh and Microsoft Windows interfaces, there is a convention that
any menu option followed by ellipsis points (... ) will, when selected, bring up a
dialog box. Options without ellipsis points are executed directly.
3
WHEN TO USE A DIALOG BOX
Most applications use dialog boxes to prompt for additional information for menu
items that require user input. Using a dialog box is the only recommended way for an
application to retrieve the input. For example, a typical Open menu item requires the name of
a file to open, so an application should use a dialog box to prompt the user for the name. In
such cases, the application creates the dialog box when the user clicks the menu item and
destroys the dialog box immediately after the user supplies the information. Many
applications also use dialog boxes to display information or options while the user works in
another window. For example, word processing applications often use a dialog box with a
text-search option.
While the application searches for the text, the dialog box remains on the screen. The
user can then return to the dialog box and search for the same word again; or the user can
change the entry in the dialog box and search for a new word. Applications that use dialog
boxes in this way typically create one when the user clicks the menu item and continue to
display it for as long as the application runs or until the user explicitly closes the dialog box.
To support the different ways applications use dialog boxes, there are two types of dialog
box: modal and modeless. A modal dialog box requires the user to supply information or
cancel the dialog box before allowing the application to continue. Applications use modal
dialog boxes in conjunction with menu items that require additional information before they
can proceed. A modeless dialog box allows the user to supply information and return to the
previous task without closing the dialog box.
Modal dialog boxes are simpler to manage than modeless dialog boxes because they
are created, perform their task, and are destroyed by calling a single function. To create either
a modal or modeless dialog box, an application must supply a dialog box template to describe
the dialog box style and content; the application must also supply a dialog box procedure to
carry out tasks. The dialog box template is a binary description of the dialog box and the
controls it contains. The developer can create this template as a resource to be loaded from
the application's executable file, or created in memory while the application runs. The dialog
box procedure is an application-defined callback function that the system calls when it has
input for the dialog box or tasks for the dialog box to carry out. Although a dialog box
procedure is similar to a window procedure, it does not have the same responsibilities.
4
An application typically creates a dialog box by using either the DialogBox or
CreateDialog function. DialogBox creates a modal dialog box; CreateDialog creates a
modeless dialog box. These two functions load a dialog box template from the application's
executable file and create a pop-up window that matches the template's specifications. There
are other functions that create a dialog box by using templates in memory; they pass
additional information to the dialog box procedure as the dialog box is created. Dialog boxes
usually belong to a predefined, exclusive window class. The system uses this window class
and its corresponding window procedure for both modal and modeless dialog boxes.
When the function is called, it creates the window for the dialog box, as well as the
windows for the controls in the dialog box, then sends selected messages to the dialog box
procedure. While the dialog box is visible, the predefined window procedure manages all
messages, processing some messages and passing others to the dialog box procedure so that
the procedure can carry out tasks. Applications do not have direct access to the predefined
window class or window procedure, but they can use the dialog box template and dialog box
procedure to modify the style and behavior of a dialog box.
Most dialog boxes have an owner window (or more simply, an owner). When creating
the dialog box, the application sets the owner by specifying the owner's window handle. The
system uses the owner to determine the position of the dialog box in the Z order so that the
dialog box is always positioned above its owner. Also, the system can send messages to the
window procedure of the owner, notifying it of events in the dialog box.
REFERENCES
http://en.wikipedia.org/wiki/Dialog_box
http://msdn.microsoft.com/en-us/library/windows/desktop/ms645452%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ms632588%28v=vs.85%29.aspx
http://www.webopedia.com/TERM/D/dialog_box.html