Skip to content

C / C++ / MFC

C, Visual C++ and MFC discussions

This category can be followed from the open social web via the handle c-c-mfc@forum.codeproject.com

111.5k Topics 465.7k Posts
  • Trying to print with a CWinThread...

    help question
    1
    0 Votes
    1 Posts
    16 Views
    No one has replied
  • CHtmlView

    question
    1
    0 Votes
    1 Posts
    5 Views
    No one has replied
  • MDI custom tile with open/close of childeren?

    question c++ tutorial
    2
    0 Votes
    2 Posts
    19 Views
    M
    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