Click here to Skip to main content
15,072,433 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I create current CDailog in class MainWnd: public CFrameWnd ?
Can't you give an code exaple.

Darryl Bryk 6-Jun-12 12:01pm
Are you trying to open a dialog window like MessageBox?

1 solution

I'm not pretty sure what you're talking about here, but if you just want to display a modal (that is, the user can only interact with the dialog) dialog that has your main frame as a parent, it's really easy.
What I like to do, is to derive a class from CDialog like this:
class CMyDialog : public CDialog
   /* CDialog declarations here */

Then I map it to a dialog resource. The best way to create this class is by using the MFC class wizard. First create the dialog resource and then create the MFC class using the wizard. Set the Base Class to CDialog and the ID to your dialog's ID (e.g. IDD_MYDIALOG). Then instantiate the class and call the DoModal() function.
CMyDialog* pDialog = new CMyDialog();

That's all.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900