Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have an MFC view, and I have another project which implements and MFC dialog.
I want to host the dialog in my view.
My view is of class CFormView.

I did it that way in my view code:

C++
m_myDialog->Create(myDialog::IDD, this);


Now, I see my dialog, but I can't set focus on it and can't use it.

What do I have to change in order to host my dialog in my view, and be able to use it and set focus to it, just as part of the view?

Thanks
Posted
Updated 3-Oct-12 22:31pm
v2
Comments
Richard MacCutchan 4-Oct-12 4:28am    
Some time since I used MFC but I think you need to use the CFormView class.
user_code 4-Oct-12 4:30am    
Hi, Thanks. My view is already a CFormView class.
Richard MacCutchan 4-Oct-12 4:47am    
In that case, the form should automatically load the dialog, you do not need to call Create() outside of the class. See CFormView Class for details.

To embed controls into a view defined by a dialog template you can use a CDialogBar object. Then all notifications from the controls are send to the view and can be handled there.

To do this with your project, change the type of your m_myDialog object to CDialogBar * and move all control handlers from your CDialog derived class to your view class.
 
Share this answer
 
Make sure you've set the Style property to Child.
 
Share this answer
 

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