Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MDI custom tile with open/close of childeren?

MDI custom tile with open/close of childeren?

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++tutorial
2 Posts 2 Posters 19 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Michael Peters
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • M Michael Peters

      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

      M Offline
      M Offline
      Martin Speiser
      wrote on last edited by
      #2
      1. 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
      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups