(modeless?)dialog in sdi
-
Hello, i want to embed a dialog in an SDI Window. I created a new SDI project without Doc/View architecure. Then created a new dialog, disabled the border, system menue etc.. Now, in the designer the dialog looks like en empty gray plane. I also added a class to this dialog derived from CDialog. I did this with the designers help, right click on the dialog and "add class". My goal is to embed this dialog in the ChildView window and make it as large as the ChildView window. I found an example here on code project thats similiar to my problem but anyway it doesn't meet my requirements. So, how can I embed this dialog in the SDI application? best regards, cmos
-
Hello, i want to embed a dialog in an SDI Window. I created a new SDI project without Doc/View architecure. Then created a new dialog, disabled the border, system menue etc.. Now, in the designer the dialog looks like en empty gray plane. I also added a class to this dialog derived from CDialog. I did this with the designers help, right click on the dialog and "add class". My goal is to embed this dialog in the ChildView window and make it as large as the ChildView window. I found an example here on code project thats similiar to my problem but anyway it doesn't meet my requirements. So, how can I embed this dialog in the SDI application? best regards, cmos
First: // Simple MDI child. class MDIChildWnd : public ClsMDIChildWindow { _NO_COPY( MDIChildWnd ); public: // Construction/destruction. MDIChildWnd() {;} virtual ~MDIChildWnd() {;} // Create a child. BOOL Create( ClsString& str, ClsMDIMainWindow *pFrame ) { // We let the base create it for us. This will automatically call the // OnMDINCCreate() overidable in which we do our thing... ClsRect rc( CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT ); // Create it. BOOL bMaximized; if ( pFrame->MDIGetActive( &bMaximized ) == NULL ) bMaximized = TRUE; return ClsMDIChildWindow::Create( str, WS_VISIBLE | ( bMaximized ? WS_MAXIMIZE : 0 ), rc, pFrame ); } protected: // Handle the WM_CLOSE messages. virtual LRESULT OnClose() { // Destroy the window. MDIDestroy(); return 0; } // WM_SIZE handler. virtual LRESULT OnSize( UINT nSizeType, int nWidth, int nHeight ) { ........... // Base class. return ClsMDIChildWindow::OnSize( nSizeType, nWidth, nHeight ); } // WM_MDICREATE handler. virtual LRESULT OnMDINCCreate( LPCREATESTRUCT pCS ) { // Make sure the child has a client edge. NOTE: Simply adding this // bit to the CREATESTRUCT.dwExStyle will not work... // // We do it here like this also because the PreCreateWindow() overide // will not be called when creating MDI child windows. ModifyExStyle( 0, WS_EX_CLIENTEDGE ); return TRUE; } };
-
First: // Simple MDI child. class MDIChildWnd : public ClsMDIChildWindow { _NO_COPY( MDIChildWnd ); public: // Construction/destruction. MDIChildWnd() {;} virtual ~MDIChildWnd() {;} // Create a child. BOOL Create( ClsString& str, ClsMDIMainWindow *pFrame ) { // We let the base create it for us. This will automatically call the // OnMDINCCreate() overidable in which we do our thing... ClsRect rc( CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT ); // Create it. BOOL bMaximized; if ( pFrame->MDIGetActive( &bMaximized ) == NULL ) bMaximized = TRUE; return ClsMDIChildWindow::Create( str, WS_VISIBLE | ( bMaximized ? WS_MAXIMIZE : 0 ), rc, pFrame ); } protected: // Handle the WM_CLOSE messages. virtual LRESULT OnClose() { // Destroy the window. MDIDestroy(); return 0; } // WM_SIZE handler. virtual LRESULT OnSize( UINT nSizeType, int nWidth, int nHeight ) { ........... // Base class. return ClsMDIChildWindow::OnSize( nSizeType, nWidth, nHeight ); } // WM_MDICREATE handler. virtual LRESULT OnMDINCCreate( LPCREATESTRUCT pCS ) { // Make sure the child has a client edge. NOTE: Simply adding this // bit to the CREATESTRUCT.dwExStyle will not work... // // We do it here like this also because the PreCreateWindow() overide // will not be called when creating MDI child windows. ModifyExStyle( 0, WS_EX_CLIENTEDGE ); return TRUE; } };
Second: // Simple MDI frame. class MDIFrame : public ClsMDIMainWindow { _NO_COPY( MDIFrame ); public: // Construction/destruction. MDIFrame() {;} virtual ~MDIFrame() {;} protected: // A child window has been closed. void OnMDIChildRemoved( ClsMDIChildWindow *pWnd ) { // Look it up in our array. for ( int i = 0; i < m_Children.GetSize(); i++ ) { // Is this the one? if ( m_Children[ i ] == reinterpret_cast( pWnd )) { // Free it and remove the entry // from the array. delete pWnd; m_Children.RemoveAt( i, 1 ); break; } } } // We do not want the system to erase the background of // the frame window. virtual LRESULT OnEraseBkgnd( ClsDC *pDC ) { return 1; } // WM_CLOSE handler. virtual LRESULT OnClose() { // Make sure the children are all destroyed. while ( m_Children.GetSize()) m_Children[ 0 ]->MDIDestroy(); PostQuitMessage( 0 ); return 0; } // WM_SIZE handler. virtual LRESULT OnSize( UINT nSizeType, int nWidth, int nHeight ) { // Size the splitter which will in turn size and // move it's panes. ClsRect rc, tb; GetClientRect( rc ); // Does it exist already? if ( m_Toolbar.GetSafeHWND()) { // Pass the message on to the toolbar. m_Toolbar.SendMessage( WM_SIZE, nSizeType, MAKELPARAM( nWidth, nHeight )); // Adjust client rectangle. m_Toolbar.GetWindowRect( tb ); rc.Top() += tb.Height(); } // Setup splitter rectangle. This will automatically // resize and reposition the panes aswell. m_Splitter.SetSplitRect( rc ); m_Splitter.RedrawPanes(); return 0; } // WM_CREATE overidable. virtual LRESULT OnCreate( LPCREATESTRUCT pCS ) { // First the base. if ( ClsMDIMainWindow::OnCreate( pCS ) == -1 ) return -1; // Create file/dir treeview. ClsRect rc( 0, 0, 0, 0 ); if ( m_Tree.Create( this, rc, IDC_FILEDIRTREE, WS_CHILD | WS_VISIBLE | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS )) { // Setup the tree. m_Tree.ModifyExStyle( 0, WS_EX_CLIENTEDGE ); m_Tree.FileFilter() = _T( "*.c;*.cpp;*.h;*.hpp;*.txt" ); m_Tree.DoubleBuffer() = TRUE; m_Tree.LoadingTextColor() = RGB( 255, 0, 0 ); if ( m_Tree.SetupTree()) { // Create splitter. if ( m_Splitter.Create( this, 0 )) { // Setup the splitter and it's panes. m_Splitter.SetPanes( m_Tree, GetMDIClient()->GetSafeHWND()); m_Splitter.SetPaneMinSize( 100, 100 ); m_Splitter.Set
-
Hello, i want to embed a dialog in an SDI Window. I created a new SDI project without Doc/View architecure. Then created a new dialog, disabled the border, system menue etc.. Now, in the designer the dialog looks like en empty gray plane. I also added a class to this dialog derived from CDialog. I did this with the designers help, right click on the dialog and "add class". My goal is to embed this dialog in the ChildView window and make it as large as the ChildView window. I found an example here on code project thats similiar to my problem but anyway it doesn't meet my requirements. So, how can I embed this dialog in the SDI application? best regards, cmos