modal and modeless
I would just like to know if anyone here can please tell me what the difference is between a modal and modeless dialog box, in english please.
I have read numerous books on the Win32 API on this subject, but none of them seem to mention clear differences between modal and modeless dialog boxes. they give very simple descriptions like "a modeless dialog is more independant than a modal" and "a modal is the most common" however that tells me nothing about the real difference.
in the last release of my program I used a simple call to DialogBox to create the main dialog box window. but in this release, I will be implementing a whole bunch of GUI enhancements, including more menus and accelerator keys.
however in this release I don't see how I am going to be able to position a function like TranslateAccelerator in my WinMain and pass the dialog window the translated accelerator messages if I don't have a valid handle of the dialog window inside of WinMain. replacing DialogBox with CreateDialog would solve this, but DialogBox creates a modal dialog box, and CreateDialog creates a modeless dialog box :confused: .
could anyone please help me out with this modal and modeless thing? also do you think its possible for me to use DialogBox and still handle things like accelerator keys, and if so how should I go about that (would it be ok without a message loop containing a TranslateMessage?)?
any help here would be greatly appreciated. thank you in advance. :)
A modeless dialog lets the program that created it run on. The user can still select and use the other windows of the program.
A modal dialog on the other hand is always active, and will disable all other windows of your program until it's closed. The user cannot select the other windows of a program if the program is waiting for a modal dialog to finish.
They're both based on the same system defined window class(window class name "#32770") with slightly different system defined behaviour - a bit like push buttons and radio buttons which are both manifestations of the 'button' system defined window class, except the differences between the dialog box types are not quite so visually nor, perhaps, behaviourally pronounced.
A modal dialog box (created with DialogBox,DialogBoxParam) basically hogs attention until it's dismissed - they're intended for situations where user input or user response/acknowledgement are required before proceeding; they don't allow you to switch to other windows within the same application(application modal) or even other applications(system modal) until the modal dialog box is dismissed.
A modeless dialog is just like another window; you can switch between it and other windows within the same application.
Neither type of dialog is intended to be used as a main application window although some people do this anyway - at least until they discover some limitation to this approach. They are generally intended to elicit or provide user information/response/selections and it's the type of response/input required by the application that ideally should determine your choice of which to use.
For further clarification consider creating simple test case applications which produce both types of dialog and examine both the code differences (for example the requirement for your own application message loop for modeless dialogs, destruction with DestroyWindow etc.), the implications of these differences and observe their default behaviour while referring to the msdn documentation and any other texts you have to hand.