Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MDI as a SDI

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello all,
I usually only need to use dialog and SDI applications or the two mixed but I now need to create a MDI app.With SDI all views are attached to the main frame.In MDI you create child frames with in the main frame and each view is attached to the child frame.I will only be using one document but want many view to access it's data and remain visible so I need an MDI app.Right?
Here's what I have.My first view that is preseted to the user is done by creating a template, it works fine:

pDocTemplate = new CMultiDocTemplate(
IDR_MDIPRATYPE,
RUNTIME_CLASS(CMDIPracticeDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CMDIPracticeView));
AddDocTemplate(pDocTemplate);

Now I want to add another view to that template.I've tried the following in the main frame class:

int CMainFrame::OnViewSelect(UINT nID)
{

CMDIChildWnd *pChild = MDIGetActive(NULL); // get active MDI child window
CDocument* pDoc = pChild->GetActiveDocument(); // get document from window
if(pDoc == NULL)
TRACE0("NO DOC POINTER !!!\n");

switch( nID )
{
case ID_VIEWONE:
TRACE0("Button one\n");
if(iCurrentView == ID_VIEWONE) // exit if view is opened
return TRUE;
pChild->ShowWindow(SW_SHOWMAXIMIZED);//GetActiveView();
pSecondView->ShowWindow(SW_HIDE);
iCurrentView = ID_VIEWONE;
break;

case ID_VIEWTWO:
TRACE0("Button two\n");

if(iCurrentView == ID_VIEWTWO) // exit if view is opened
return TRUE;
if(pSecondView == NULL){
pSecondView = new CSecondView; // create instance of second view
pSecondView->Create(NULL,"View Two",WS_OVERLAPPEDWINDOW,
rectDefault,this,AFX_IDW_PANE_FIRST +1,NULL); // create second view
pDoc->AddView(pSecondView); // add second view
}
pSecondView->ShowWindow(SW_SHOWMINIMIZED);
pChild->ShowWindow(SW_HIDE); // hide MDI child one
iCurrentView = ID_VIEWTWO;
break;
}
return FALSE;
}

It works but my second view is docking to the main frame.I believe this is because I have not created a child frame for it so it's using the main frame.What can I do?I don't want another template becasue it will create another document and I want both views accessing the data from one document.
Please let me know if you can help,
Brother C
 
You can use "split view" instead "multi view".
Wang Hong Tai From China
E-Mail:
hongtai@eyou.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top