Re-explore MFC (IV) Create dialog box

Source: Internet
Author: User

For example, click the menu Popup Non-modal dialog box .


Step1

Resource View Add dialog box template . Renaming a dialog box resource ID.

Step2

Check the dialog box , Right-click menu to add Class .

Step3

In the message handling function of the menu item

Cdialogaddcontactdlg;

INT_PTR Nresponse =dlg. DoModal ();

if (Nresponse ==idok)

{

}

else if (nresponse== IDCANCEL)

{

}


can be domodel Create modal dialog box through create Create modeless dialog box Explains the two types of dialog boxes dialog boxes is of both Types:modal andmodeless. A modal dialog box must is closed by the user before the applicationcontinues. A modeless dialog box allows the user to display the dialog box Andreturn to another task without canceling or removing th E dialog box.

How to close a dialog box ? Remarks is described below .

A modal dialog boxcloses automatically when the user presses the OK or Cancel buttons or Whenyour code calls the EndDialog member function.

When you implement Amodeless dialog box, always override the OnCancel member function and Calldestroywindow from within it . Don ' t call the base class Cdialog::oncancel,because it calls EndDialog, which'll make the dialog box invisible but Willn OT destroy it. should also override PostNcDestroy for modeless dialogboxes in order to delete this, since modeless dialog boxes is U Suallyallocated with new. Modal dialog boxes is usually constructed on the frame Anddo not need PostNcDestroy cleanup.

Https://msdn.microsoft.com/en-us/library/132s802t.aspx

Re-explore MFC (IV) Create dialog box

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.