Multiple Windows in Windoz
Does anybody know how you would go about creating multiple windows in an MFC app? I need to create multiple views for a map editor, but it seems kind of difficult. I know that many map editors do cool things like all four resizeable in one. Is there any good books (preferably online) that would show me, or could anybody tell me?
-----------------------------1. "Diplomacy is the art of saying 'Nice doggie!'... till you can find a rock." 2. "Always remember you're unique, just like everyone else." 3. "If we don't succeed, we run the risk of failure."-Dan Quayle4. If life gives you sour grapes, squash them and make wine!
Not quite that simple. I''m assuming by MFC app you mean an AppWizard generated doc/view architecture full-on MFC app. There are several ways of doing it. First is using a splitter window. Second is implementing multiple view classes linked to a single document class. They don''t do exactly the same thing so it really depends on your use. If it''s a 3d editor and you want each window to have it''s own kind of view (3d, front, side, etc.) then you could use a splitter window (it''s what''s used in programs like WorldCraft). If the other windows are for things like editing objects and scripts then having multiple windows is probably better because each window can be maximized.
-RWarden (roberte@maui.net)
-RWarden (roberte@maui.net)
Yeah, I know somewhat of splitter windows. I''ve initialized the splitter window, I think, but I don''t know how to do the actual rendering of the different views. Here''s how I''m doing it now:
BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
int x, y;
RECT r;
ShowWindow( SW_MAXIMIZE );
if( !m_wndSplitter.CreateStatic( this, 2, 2 ) )
{
TRACE0("CCF::OCC\n") ;
return FALSE;
}
GetClientRect(&r);
x=r.right>>1;
y=r.bottom>>1;
if( !m_wndSplitter.CreateView(0, 0,
RUNTIME_CLASS(CEditorView), CSize(x, y), pContext) )
{
TRACE0("CCF::OCC\n");
return FALSE;
}
if( !m_wndSplitter.CreateView(0, 1,
RUNTIME_CLASS(SceneView), CSize(x, y), pContext))
{
TRACE0("CCF::OCC\n");
return FALSE;
}
if( !m_wndSplitter.CreateView(1, 0,
RUNTIME_CLASS(SceneView), CSize(x, y), pContext))
{
TRACE0("CCF::OCC\n");
return FALSE;
}
if( !m_wndSplitter.CreateView(1, 1,
RUNTIME_CLASS(SceneView), CSize(x, y), pContext))
{
TRACE0("CCF::OCC\n");
return FALSE;
}
// activate the top right view
SetActiveView( (CView*)m_wndSplitter.GetPane(0,1) ) ;
return CMDIChildWnd::OnCreateClient(lpcs, pContext);
}
It''s hard to read with this narrow of columns. Anyways, how would I go about rendering the middle splitter thing? Could I just render normally when my OnDraw functions are called, or would I need an extra step to worry about the splitter? All that I have now is one window that doesn''t seem to do the splitter. I''m thinking that this is because I need another step... Any ideas?
Thanks for replying, by the way.
-----------------------------1. "Diplomacy is the art of saying 'Nice doggie!'... till you can find a rock." 2. "Always remember you're unique, just like everyone else." 3. "If we don't succeed, we run the risk of failure."-Dan Quayle4. If life gives you sour grapes, squash them and make wine!
So then, does anybody know how I could do this?
-----------------------------1. "Diplomacy is the art of saying 'Nice doggie!'... till you can find a rock." 2. "Always remember you're unique, just like everyone else." 3. "If we don't succeed, we run the risk of failure."-Dan Quayle4. If life gives you sour grapes, squash them and make wine!
OK, first off, you are not setting the size of the different windows.
All you need to do for the rendering to screen is write the code as per normal (i.e. as if the window was in it''s own FrameWnd.
the code below :
m_wndSplitter.CreateView(0, 0,
RUNTIME_CLASS(CEditorView), CSize(x, y), pContext)
is using CSize( x, y ), but these variables are not set., set them to say 100 each.
I''ve got a few books on MFC (actually 1 on MFC and one on VC4) and I followed the directions in them to create my splitter window. I do not know if these are available online.
Essential Visual C++ 4, Mickey Williams SAMS Publishingabout $25
MFC Developers Workshop, Frank Crockett Microsoft Press $40
I bought them when I was actually working inside of the game programming comunity (what a waste of time that was). That was 3 years ago and when I left I voyed never to program games again, and now I''m trying to get back in.
Here''s my code to init a 2 pane splitter window:
I know I should use the source tages, but they alway screw up when I use them.
All you need to do for the rendering to screen is write the code as per normal (i.e. as if the window was in it''s own FrameWnd.
the code below :
m_wndSplitter.CreateView(0, 0,
RUNTIME_CLASS(CEditorView), CSize(x, y), pContext)
is using CSize( x, y ), but these variables are not set., set them to say 100 each.
I''ve got a few books on MFC (actually 1 on MFC and one on VC4) and I followed the directions in them to create my splitter window. I do not know if these are available online.
Essential Visual C++ 4, Mickey Williams SAMS Publishingabout $25
MFC Developers Workshop, Frank Crockett Microsoft Press $40
I bought them when I was actually working inside of the game programming comunity (what a waste of time that was). That was 3 years ago and when I left I voyed never to program games again, and now I''m trying to get back in.
Here''s my code to init a 2 pane splitter window:
BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext){ if( !m_wndSplitter.CreateStatic(this, 1, 2) ) // TODO: adjust the number of rows, columns { TRACE0("Failed to create splitter bar "); return FALSE; // failed to create } if( !m_wndSplitter.CreateView( 0, 0, RUNTIME_CLASS( CLevelGraphicsView ), CSize( 0, 0 ), pContext ) ) { TRACE0( "Failed to create Graphic pane" ); return FALSE; // failed to create } if( !m_wndSplitter.CreateView( 0, 1, RUNTIME_CLASS( CLevelEditorView ), CSize( 100, 100 ), pContext ) ) { TRACE0( "Failed to create Edit pane" ); return FALSE; // failed to create } SetActiveView( (CView*) m_wndSplitter.GetPane( 0, 1 ) ); return TRUE;// return CMDIChildWnd::OnCreateClient(lpcs, pContext);}
I know I should use the source tages, but they alway screw up when I use them.
When I find my code in tons of trouble,Friends and colleages come to me,Speaking words of wisdom:"Write in C."My Web Site
Wow! Thanks alot for your help, I got it up and working... In my original source, I set the size, but that''s just details. The problem was that I was returning CMDIChildWnd::OnCreateClient(lpcs, pContext); instead of returning true! Oh well, it was just a small mistake, I guess... not something like a bad plan. Anyways, thanks for your help. I should be able to get going much further now (my last editor only had one view, and you could switch where it viewed from. It sucked!)
-----------------------------1. "Diplomacy is the art of saying 'Nice doggie!'... till you can find a rock." 2. "Always remember you're unique, just like everyone else." 3. "If we don't succeed, we run the risk of failure."-Dan Quayle4. If life gives you sour grapes, squash them and make wine!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement