1
votes

I'm not necessarily looking for code help, but rather a high level answer so I can research the solution myself. Basically, I have an MDI app with multiple docs and their views, I'd like all the views to open up as tabs in the one child frame that I have. The thing is my child frame is statically configured with a splitter window with two views, a form and a list view, in the OnCreateClient method. I'd like to keep this as the default tab that appears when the app is launched.

I have a third view (editview) with it's own document template, which I'd like to be able to open as a separate tab. I will have other views that will behave this way. What's the best way to approach this?

Will I need to create separate child frames for each view? Will I lose the 'tab' feature if I create separate child frames?

Or will I have to modify the child frame's OnCreateClient method to test which document template is the current one and create the view for that doc template? I'd like to know how some of you seasoned programmers have had or would do it.

Thanks.

1
Still looking around. Man, this is frustrating when there's no example online. Maybe I'm just not searching using the correct terms. I'll keep digging, but if anyone has anything to offer, I'd really appreciate it!subject_x

1 Answers

0
votes

In case this helps others, from what I've gathered, it is perfectly acceptable to create a new child frame class derived from CChildFrame or just use that as your frame with your new view. The doc, frame, and view will be added to the doc template in the initInstance method. for example, let say you have a pair of trios (2 docs, 2 views, 2 frames):

pDocTemplate = new CMultiDocTemplate(IDR_testappTYPE,
    RUNTIME_CLASS(CMydoc1),
    RUNTIME_CLASS(CMyframe1), 
    RUNTIME_CLASS(CMyview1));
if (!pDocTemplate)
    return FALSE;
AddDocTemplate(pDocTemplate);

pDocTemplate2 = new CMultiDocTemplate(IDR_testappTYPE,
    RUNTIME_CLASS(CMydoc2),
    RUNTIME_CLASS(CMyframe2), 
    RUNTIME_CLASS(CMyview2));
if (!pDocTemplate2)
    return FALSE;
AddDocTemplate(pDocTemplate2); 

If you add another trio with a different childframe because this new frame doesn't use splitters like the ones above, you would do it this way.

pDocTemplate3 = new CMultiDocTemplate(IDR_mditest3TYPE,
    RUNTIME_CLASS(CMydoc), //same doc
    RUNTIME_CLASS(CMyframeWithoutSplitters), //new frame
    RUNTIME_CLASS(CMyview3)); //new view
if (!pDocTemplate3)
    return FALSE;
AddDocTemplate(pDocTemplate3);