Maximising CMDIChildWnd
-
I'm trying to create an MDI app, I want any child windows to be automatically Maximised at all times. I've overidden the Create function and removed the style WS_SYSMENU and added the style WS_MAXIMIZE. (see bellow) The window wtill doesn't display maximised though? What am I missing? Cheers
BOOL CSegmentationFrame::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CMDIFrameWnd* pParentWnd, CCreateContext* pContext)
{
// Remove the System Menu from the Frame
dwStyle ^= WS_SYSMENU ;// Create a Maximised Window dwStyle |= WS\_MAXIMIZE ; return CMDIChildWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, pContext);
}
Asim Hussain e: asim@jawache.net w: www.jawache.net
-
I'm trying to create an MDI app, I want any child windows to be automatically Maximised at all times. I've overidden the Create function and removed the style WS_SYSMENU and added the style WS_MAXIMIZE. (see bellow) The window wtill doesn't display maximised though? What am I missing? Cheers
BOOL CSegmentationFrame::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CMDIFrameWnd* pParentWnd, CCreateContext* pContext)
{
// Remove the System Menu from the Frame
dwStyle ^= WS_SYSMENU ;// Create a Maximised Window dwStyle |= WS\_MAXIMIZE ; return CMDIChildWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, pContext);
}
Asim Hussain e: asim@jawache.net w: www.jawache.net
try moving your functionality into PreCreateWindow.
virtual BOOL CSegmentationFrame::PreCreateWindow( CREATESTRUCT& cs )
{
cs.style ^= WS_SYSMENU;
cs.sytle |= WS_MAXIMIZE;
return CFrameWnd::PreCreateWindow( cs );
}That may help you out. Is kinda hard to tell w/o seeing more of your source. The style could be getting overriden somewhere else. Joseph Dempsey joseph_r_dempsey@yahoo.com "Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning." --anonymous
-
try moving your functionality into PreCreateWindow.
virtual BOOL CSegmentationFrame::PreCreateWindow( CREATESTRUCT& cs )
{
cs.style ^= WS_SYSMENU;
cs.sytle |= WS_MAXIMIZE;
return CFrameWnd::PreCreateWindow( cs );
}That may help you out. Is kinda hard to tell w/o seeing more of your source. The style could be getting overriden somewhere else. Joseph Dempsey joseph_r_dempsey@yahoo.com "Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning." --anonymous
Cheers, but that doesn't work either. The only other code I have in the class is the OnCreateClient function. Its displaying a splitter window as bellow:
BOOL CSegmentationFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
//calculate client size
CRect cr;
GetClientRect( &cr);
// Window Styles
DWORD dwStyle = WS_BORDER | WS_CHILD | WS_VISIBLE;// Main splitter wnd, two rows 1 columns if ( !m\_mainSplitterWnd.CreateStatic( this, 2, 1 ) ) { MessageBox( "Error setting up splitter frames!", "Init Error!", MB\_OK | MB\_ICONERROR ); return FALSE; } // Top splitter win, 2 rows 4 columns (To hold the slice views) if ( !m\_topSplitterWnd.CreateStatic( &m\_mainSplitterWnd, 2, 4, dwStyle ,m\_mainSplitterWnd.IdFromRowCol(0,0) ) ) { MessageBox( "Error setting up splitter frames!", "Init Error!", MB\_OK | MB\_ICONERROR ); return FALSE; } // Bottom Splitter window, 1 row 2 columns ( to hold the form and histogram view ) if ( !m\_botSplitterWnd.CreateStatic( &m\_mainSplitterWnd, 1, 2, dwStyle ,m\_mainSplitterWnd.IdFromRowCol(1,0) ) ) { MessageBox( "Error setting up splitter frames!", "Init Error!", MB\_OK | MB\_ICONERROR ); return FALSE; } // Top Slice Views for (int row = 0; row < 2; row ++) { for (int col = 0; col < 4; col ++) { if ( !m\_topSplitterWnd.CreateView( row, col, RUNTIME\_CLASS(CSliceView), CSize(cr.Width()/4, cr.Height()/3), pContext ) ) { MessageBox( "Error setting up splitter frames!", "Init Error!", MB\_OK | MB\_ICONERROR ); return FALSE; } } } // Bottom Slice Views if ( !m\_botSplitterWnd.CreateView( 0, 0, RUNTIME\_CLASS(CSegmentationForm), CSize(cr.Width()/2, cr.Height()/3), pContext ) ) { MessageBox( "Error setting up splitter frames!", "Init Error!", MB\_OK | MB\_ICONERROR ); return FALSE; } if ( !m\_botSplitterWnd.CreateView( 0, 1, RUNTIME\_CLASS(CHistogramView), CSize(cr.Width()/2, cr.Height()/3), pContext ) ) { MessageBox( "Error setting up splitter frames!", "Init Error!", MB\_OK | MB\_ICONERROR ); return FALSE; } return true; //CMDIChildWnd::OnCreateClient(lpcs, pContext);
Asim Hussain e: asim@jawache.net w: www.jawache.net
-
Cheers, but that doesn't work either. The only other code I have in the class is the OnCreateClient function. Its displaying a splitter window as bellow:
BOOL CSegmentationFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
//calculate client size
CRect cr;
GetClientRect( &cr);
// Window Styles
DWORD dwStyle = WS_BORDER | WS_CHILD | WS_VISIBLE;// Main splitter wnd, two rows 1 columns if ( !m\_mainSplitterWnd.CreateStatic( this, 2, 1 ) ) { MessageBox( "Error setting up splitter frames!", "Init Error!", MB\_OK | MB\_ICONERROR ); return FALSE; } // Top splitter win, 2 rows 4 columns (To hold the slice views) if ( !m\_topSplitterWnd.CreateStatic( &m\_mainSplitterWnd, 2, 4, dwStyle ,m\_mainSplitterWnd.IdFromRowCol(0,0) ) ) { MessageBox( "Error setting up splitter frames!", "Init Error!", MB\_OK | MB\_ICONERROR ); return FALSE; } // Bottom Splitter window, 1 row 2 columns ( to hold the form and histogram view ) if ( !m\_botSplitterWnd.CreateStatic( &m\_mainSplitterWnd, 1, 2, dwStyle ,m\_mainSplitterWnd.IdFromRowCol(1,0) ) ) { MessageBox( "Error setting up splitter frames!", "Init Error!", MB\_OK | MB\_ICONERROR ); return FALSE; } // Top Slice Views for (int row = 0; row < 2; row ++) { for (int col = 0; col < 4; col ++) { if ( !m\_topSplitterWnd.CreateView( row, col, RUNTIME\_CLASS(CSliceView), CSize(cr.Width()/4, cr.Height()/3), pContext ) ) { MessageBox( "Error setting up splitter frames!", "Init Error!", MB\_OK | MB\_ICONERROR ); return FALSE; } } } // Bottom Slice Views if ( !m\_botSplitterWnd.CreateView( 0, 0, RUNTIME\_CLASS(CSegmentationForm), CSize(cr.Width()/2, cr.Height()/3), pContext ) ) { MessageBox( "Error setting up splitter frames!", "Init Error!", MB\_OK | MB\_ICONERROR ); return FALSE; } if ( !m\_botSplitterWnd.CreateView( 0, 1, RUNTIME\_CLASS(CHistogramView), CSize(cr.Width()/2, cr.Height()/3), pContext ) ) { MessageBox( "Error setting up splitter frames!", "Init Error!", MB\_OK | MB\_ICONERROR ); return FALSE; } return true; //CMDIChildWnd::OnCreateClient(lpcs, pContext);
Asim Hussain e: asim@jawache.net w: www.jawache.net
It works now if i just use cs.style = WS_CHILD | WS_VISIBLE | WS_MAXIMIZE; in PreCreateWidow. Cheers Asim Hussain e: asim@jawache.net w: www.jawache.net
-
It works now if i just use cs.style = WS_CHILD | WS_VISIBLE | WS_MAXIMIZE; in PreCreateWidow. Cheers Asim Hussain e: asim@jawache.net w: www.jawache.net
another solution which works well is the following: void CChildFrame::ActivateFrame(int nCmdShow) { // TODO: Modify this function to change how the frame is activated. nCmdShow = SW_SHOWMAXIMIZED; CMDIChildWnd::ActivateFrame(nCmdShow); }