I. Advantages of non-mode dialog box compared with mode dialog boxYes, it is opened as an independent window and does not affect the status of the parent window. When the latter opens, it cannot be used to close the former parent window. In addition, the function returns the next statement of the generated dialog box after the dialog box is closed. The Mode dialog box can return the location of the next program without being closed.
For example:
// When the mode dialog box is displayed, <br/> hwndresultdlg = createdialog (hinst, text ("result"), hwnd, resultdlg); <br/> Statement 2; // when the dialog box is enabled, the execution cannot be returned. You must close it first. <br/> // In the non-mode dialog box <br/> dialogboxparam (hinst, text ("send"), hwnd, senddlg, 0); <br/> Statement 2; // execution can also be returned when the dialog box is enabled.
Ii. Differences between dialogboxparam () and dialogboxYes. The former has one more parameter, which can be passed to the iparam parameter.
Both are destroyed using enddialog ()
3. Use createdialg to create a non-mode dialog box.
You can create a main window in winmain, and save the dialog box handle for backup.
Hdlgmodeless = createdialog (hinstance, text ("colorscrdlg"), // dialog box template hwnd, colorscrdlg // dialog box message processing function );
4. Add a non-mode dialog box for processing the message cyclically
Unlike the mode dialog box, the mode dialog box has its internal message pump mechanism when it is working.
The non-mode dialog box, like a normal window, is driven by the message loop written in winmain.
However, as a dialog box, it has special processing for some messages, such as the "tab" key and "enter" key used for navigation between subcontrols in the dialog box.
Therefore, in a message loop, the dialog box must be provided with the opportunity to intercept messages.
while (GetMessage (&msg, NULL, 0, 0)){if (hDlgModeless == 0 || !IsDialogMessage (hDlgModeless, &msg)){TranslateMessage (&msg) ;DispatchMessage (&msg) ;}}
If the received message is a dialog box message, isdialgmessage submits it to the dialog message processing function and returns true.
It does not need to be distributed.
5. Destruction of the non-mode dialog box
Usage:
DestroyWindow (hDlg);
The non-mode dialog box is created using createdialg.
You can create a main window in winmain, and save the dialog box handle for backup.
Hdlgmodeless = createdialog (hinstance, text ("colorscrdlg"), // dialog box template hwnd, colorscrdlg // dialog box message processing function );
Add a message loop for non-mode dialog box Processing
Unlike the mode dialog box, the mode dialog box has its internal message pump mechanism when it is working.
The non-mode dialog box, like a normal window, is driven by the message loop written in winmain.
However, as a dialog box, it has special processing for some messages, such as the "tab" key and "enter" key used for navigation between subcontrols in the dialog box.
Therefore, in a message loop, the dialog box must be provided with the opportunity to intercept messages.
while (GetMessage (&msg, NULL, 0, 0)){if (hDlgModeless == 0 || !IsDialogMessage (hDlgModeless, &msg)){TranslateMessage (&msg) ;DispatchMessage (&msg) ;}}
If the received message is a dialog box message, isdialgmessage submits it to the dialog message processing function and returns true.
It does not need to be distributed.
Vi. Destruction of the non-mode dialog box
Usage:
DestroyWindow (hDlg);