Click here to Skip to main content
14,330,528 members
Rate this:
Please Sign up or sign in to vote.
See more:
How can I create current CDailog in class MainWnd: public CFrameWnd ?
Can't you give an code exaple.

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

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

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();
pDialog->DoModal();

That's all.
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100