Discussion:
Creating multiple child views in MDI vs6 c++
(too old to reply)
f***@leeds.ac.uk
2007-08-30 15:07:07 UTC
Permalink
I have an MDI application where the application automatically displays
a dialogbox (derived from CFormView) on start up. I have created
another dialogbox (dialog2) and use the class wizard to derive this
from CFormView also (I want these boxes to have the properties
associated with child formviews i.e tile, cascade etc).

Please can somebody tell me a general method for displaying this
dialog2 (and later dialog3, etc) as a child within the confines of the
main frame?

The new child view (dialog2) should be displayed together with the old
one that is displayed on startup
The new view should be part of the original document (1 document only
for now)

At the moment I have:
void CMainFrame::OnViewDialog2()
{

CDialog2 * pView = NULL;
pView = new CDialog2();
pView ->Create(NULL, NULL, NULL, CFrameWnd::rectDefault, pView-
GetParent(), NULL, NULL);
pView ->ShowWindow(SW_SHOW);

CMDIChildWnd* pFrame = (CMDIChildWnd*)GetParentFrame();
pFrame->SetActiveView(pView);
pFrame->RecalcLayout();
}

However this replaces my original dialog with the new dialog2 and I
want to see them both. Any help is very much appreciated.
Tom Serface
2007-08-30 17:12:16 UTC
Permalink
You may want to put your views in a splitter window so you can show both
and the user can adjust how much they see of either:

http://msdn2.microsoft.com/en-us/library/0dyc0e53(VS.80).aspx

Tom
Post by f***@leeds.ac.uk
I have an MDI application where the application automatically displays
a dialogbox (derived from CFormView) on start up. I have created
another dialogbox (dialog2) and use the class wizard to derive this
from CFormView also (I want these boxes to have the properties
associated with child formviews i.e tile, cascade etc).
Please can somebody tell me a general method for displaying this
dialog2 (and later dialog3, etc) as a child within the confines of the
main frame?
The new child view (dialog2) should be displayed together with the old
one that is displayed on startup
The new view should be part of the original document (1 document only
for now)
void CMainFrame::OnViewDialog2()
{
CDialog2 * pView = NULL;
pView = new CDialog2();
pView ->Create(NULL, NULL, NULL, CFrameWnd::rectDefault, pView-
GetParent(), NULL, NULL);
pView ->ShowWindow(SW_SHOW);
CMDIChildWnd* pFrame = (CMDIChildWnd*)GetParentFrame();
pFrame->SetActiveView(pView);
pFrame->RecalcLayout();
}
However this replaces my original dialog with the new dialog2 and I
want to see them both. Any help is very much appreciated.
f***@leeds.ac.uk
2007-08-30 19:38:12 UTC
Permalink
I would prefer not to use a splitter window plus i think i am very
close to solving the problem with the code above. I think it's
something to do with the arguments in the create function???

In my class CDialog2 i also have added a virtual function override of
CWnd::Create:

BOOL CMyBaseView::Create(LPCTSTR /*lpszClassName*/, LPCTSTR /
*lpszWindowName*/,
DWORD dwRequestedStyle, const RECT& rect, CWnd* pParentWnd, UINT
nID,
CCreateContext* pContext)
{
return CFormView::Create(NULL, NULL, dwRequestedStyle, rect,
pParentWnd, nID, pContext);
}
RainMan
2007-11-11 23:33:01 UTC
Permalink
I think you are confusing dialog resource with classes that MFC delivers to
handle dialog.
CDialog class handles windows dialog as modal or non modal dialog,
standalone entity that does need frame window and is not a part of SDI/MDI
application.

MFC introduced CFormView that uses dialog resource as a view and this view
is displayed in a frame and is attached (usually) to a document as a part of
MDI/SDI architecture.

In MDI app you can show multiple views that are hosted by different child
frames (not a main frame) and are wired to the same document instance but it
would require writing code to handle that scenario.
You can also display multiple views that are hosted by one frame and are
hooked to the same document and this requires little or no code.

Splitter is one of the answers; not too good if you want to add and remove
views dynamically.

My advice: go http://www.codeguru.com/forum/forumdisplay.php?f=7 and do a
search using keywords: view, swap switch. There are plenty samples, some of
them written by me.
You can also go
http://www.codeguru.com/cpp/controls/controls/tabcontrols/article.php/c13085/
and see my article that explains how to use tab bar to maintain multiple
views.
--
RainMan
Post by f***@leeds.ac.uk
I have an MDI application where the application automatically displays
a dialogbox (derived from CFormView) on start up. I have created
another dialogbox (dialog2) and use the class wizard to derive this
from CFormView also (I want these boxes to have the properties
associated with child formviews i.e tile, cascade etc).
Please can somebody tell me a general method for displaying this
dialog2 (and later dialog3, etc) as a child within the confines of the
main frame?
The new child view (dialog2) should be displayed together with the old
one that is displayed on startup
The new view should be part of the original document (1 document only
for now)
void CMainFrame::OnViewDialog2()
{
CDialog2 * pView = NULL;
pView = new CDialog2();
pView ->Create(NULL, NULL, NULL, CFrameWnd::rectDefault, pView-
GetParent(), NULL, NULL);
pView ->ShowWindow(SW_SHOW);
CMDIChildWnd* pFrame = (CMDIChildWnd*)GetParentFrame();
pFrame->SetActiveView(pView);
pFrame->RecalcLayout();
}
However this replaces my original dialog with the new dialog2 and I
want to see them both. Any help is very much appreciated.
Loading...