Click here to Skip to main content
13,192,426 members (47,101 online)
Rate this:
Please Sign up or sign in to vote.
See more:

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:

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?

Posted 3-Oct-12 22:02pm
Updated 3-Oct-12 22:31pm
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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Make sure you've set the Style property to Child.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.171017.2 | Last Updated 4 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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