MDI custom tile with open/close of childeren?
-
VC6, MFC, Win95/98 I have a question that I can not seem to find an answer or sample code. I want the following behavior: The first opened child windows, w1, fills the CMDIFrameWnd Client window from corner to corner. If the user opens a second window, w1 and w2 tile vertically. If a third child window is opens, w1 and w2 stay side by side at the top half and w3 tiles bellow w1 and w2 from far left to right. If a fourth window opens, child w3 moves over to the left 1/2 and child w4 takes it place bellow w2 and to the right of w3. The end result equals four child windows; w1 upper/left, w2 upper/right, w3 lower/left, w4 lower/right. As the end user closes the windows, I want to reverse the open process. What is the best way to achieve my goal? Is there any source code showing how to do this? All suggestion welcome and source greatly appreciated
-
VC6, MFC, Win95/98 I have a question that I can not seem to find an answer or sample code. I want the following behavior: The first opened child windows, w1, fills the CMDIFrameWnd Client window from corner to corner. If the user opens a second window, w1 and w2 tile vertically. If a third child window is opens, w1 and w2 stay side by side at the top half and w3 tiles bellow w1 and w2 from far left to right. If a fourth window opens, child w3 moves over to the left 1/2 and child w4 takes it place bellow w2 and to the right of w3. The end result equals four child windows; w1 upper/left, w2 upper/right, w3 lower/left, w4 lower/right. As the end user closes the windows, I want to reverse the open process. What is the best way to achieve my goal? Is there any source code showing how to do this? All suggestion welcome and source greatly appreciated
- Write a window class dervied from CWnd. class MdiClient : public CWnd { DECLARE_DYNAMIC( MdiClient ) public: // Construction/Destruction MdiClient(); protected: // ClassWizard generated message map functions //{{AFX_MSG( MdiClient ) //}}AFX_MSG afx_msg LRESULT OnMDICreate( WPARAM, LPARAM lParam ); afx_msg LRESULT OnMDIDestroy( WPARAM wParam, LPARAM ); DECLARE_MESSAGE_MAP() int m_nMDICount; }; IMPLEMENT_DYNAMIC( MdiClient, CWnd ) // Construction/Destruction MdiClient::MdiClient() : m_nMDICount( 0 ) { } // ClassWizard generated message map functions BEGIN_MESSAGE_MAP( CLASS, BASE ) //{{AFX_MSG_MAP( MdiClient ) //}}AFX_MSG_MAP ON_MESSAGE( WM_MDICREATE, OnMDICreate ) ON_MESSAGE( WM_MDIDESTROY, OnMDIDestroy ) END_MESSAGE_MAP() LRESULT MdiClient::OnMDICreate( WPARAM, LPARAM lParam ) { LPMDICREATESTRUCT lpmdic = (LPMDICREATESTRUCT)lParam; HWND hwndMDIChild = (HWND)CWnd::DefWindowProc( WM_MDICREATE, 0L, (LRESULT)lpmdic ); if ( hwndMDIChild != NULL ) { ++m_nMDICount; // Reposition the MDI childs like you want } return (LRESULT)hwndMDIChild; } LRESULT MdiClient::OnMDIDestroy( WPARAM wParam, LPARAM ) { --m_nMDICount; if ( m_nMDICount > 0 ) { // Reposition the MDI childs like you want } return CWnd::DefWindowProc( WM_MDIDESTROY, wParam, 0L ); } 2) Derive a class from CMDIFrameWnd, and overwrite OnCreate. int MdiFrameWnd::OnCreate( LPCREATESTRUCT lpCreateStruct ) { if( CMDIFrameWnd::OnCreate( lpCreateStruct ) == -1 ) { return -1; } m_pwndMdiClient = new MdiClient; if( !m_pwndMdiClient->SubclassWindow( m_hWndMDIClient ) ) { return -1; } return 0; } HTH Martin