1
votes

I have a single document MFC app, which consists of the MainFrame (derived from CFrameWnd) and within contained CChildView (derived form CWnd). These are generated by the VS MFC Wizard.

In resource editor I have designed a simple UI and tagged it as IDD_CUSTOMCONTROL with few buttons and text fields. I would like to connect it to the CChildView without generating it as a new dialog.

What is the right way to do it? Is it possible to do it? Or should I connect the ID directly to MainFrame?

EDIT: I have just found the right MSDN page which states which classes can have dialog id's assigned.

The scope of the question is depleted. Can/should it be closed? Or can I ask how to achieve my goal and apply the designed resource to MainFrame? (The title is now misleading).

1
You can answer your own question.Jabberwocky
Umm, maybe confused a little? A "view" is window (a CWnd-derived class) displaying and modifying the "document" (call GetDocument()). CView is the base-class, while CFormView is the derivative that can display a dialog resource. So your view class must be derived from CFormView - and no, the frame window has nothing to do with resources or the document. As an advice, try to NOT #include the view's header file (childview.h ?) in the document's source (the opposite is necessary, of course, ie the view must "know" the document).Constantine Georgiou
@ConstantineGeorgiou: Yes I am actually on this: Connecting the resource to CFormView, which in my case is the MainFrame (Parent Window). As soon as I get this I will provide the answer to question together with the solution to the problem.Rafal
"Connecting the resource to CFormView, which in my case is the MainFrame (Parent Window)" - this is wrong! The view and the frame are separate classes. Your view must be derived from CFormView (the MainFrame could be left as is). Better create a new test project with the wizard, initially deriving the view from CFormView, to see how it is done.Constantine Georgiou
Ok, thank you for pointing that out. If I understand correct, I will have the CFormView as MainFrame which will encapsulate also a CFormView that will be connected to the resource dialog.Rafal

1 Answers

0
votes

In short: No.

I have just found the right MSDN page which states which classes can have dialog id's assigned.

Classes such as CButton, CWnd, or CDocument, which do not require a dialog ID or resource ID. These classes do not use a dialog or resource ID. If you select one of these classes for your base class, the Dialog ID box and the DHTML resource ID box are dimmed.

Classes such as CDialog, CFormView, or CPropertyPage, which require a dialog ID.

The class CDHtmlDialog, which requires a dialog ID, a DHTML resource ID, and an HTML file name.

I should go with CFormView instead as @ConstantineGeorgiou proposed in comments.