Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ MFC dialog
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:

   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 3-Oct-12 23:02pm
Edited 3-Oct-12 23:31pm
v2
Comments
Richard MacCutchan at 4-Oct-12 4:28am
   
Some time since I used MFC but I think you need to use the CFormView class.
user_code at 4-Oct-12 4:30am
   
Hi, Thanks. My view is already a CFormView class.
Richard MacCutchan at 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
good
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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 6,534
1 OriginalGriff 6,258
2 Peter Leow 2,534
3 Maciej Los 2,308
4 Abhinav S 2,274


Advertise | Privacy | Mobile
Web04 | 2.8.150414.1 | Last Updated 4 Oct 2012
Copyright © CodeProject, 1999-2015
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