Non-mode dialog box createdialog () and mode dialog box dialogboxparam () and dialogbox ()

Source: Internet
Author: User

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);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.