Problem with resizing the window at application startup
-
Hi, I am getting a vague problem, and I'm unable to figure out the reason for this. I am working with MDI application. I wanted to remove maximize and minimize buttons of the CMDIMainFrame window. So I handled it in OnNewDocument as shown below. BOOL CLogAppDoc::OnNewDocument() { DWORD style = ::GetWindowLong(AfxGetMainWnd()->m_hWnd, GWL_STYLE); // Remove the thick frame style and the Minimize, Maximize buttons style &= ~(WS_MAXIMIZEBOX|WS_MINIMIZEBOX|WS_THICKFRAME); ::SetWindowLong(AfxGetMainWnd()->m_hWnd, GWL_STYLE, style); } I wanted the window to be in maximized mode at startup, so in InitInstance function of application class, I modified the ShowWindow call as follows pMainFrame->ShowWindow(SW_MAXIMIZE); Now when I run my application the window appears to be in maximized mode, but it isn't so, because when I move the mouse cursor to the title bar and right click on it, the move sub menu item is enabled. This implies that my window is not in maximized mode, though it appears to be in maximized mode by occupying the full screen area, and using the move option I can drag the window. Now if I comment the code that I've written above in OnNewDocument(), the window is in maximized mode and the move submenu item of the popup menu is disabled, but I will get the maximize and minimize buttons on the title bar. My intention is to let the window be in maximized mode at startup and minimize & maximize buttons should not be there on the title bar. Can any one please help me to figure out my mistake? Thanks Madhavi.
-
Hi, I am getting a vague problem, and I'm unable to figure out the reason for this. I am working with MDI application. I wanted to remove maximize and minimize buttons of the CMDIMainFrame window. So I handled it in OnNewDocument as shown below. BOOL CLogAppDoc::OnNewDocument() { DWORD style = ::GetWindowLong(AfxGetMainWnd()->m_hWnd, GWL_STYLE); // Remove the thick frame style and the Minimize, Maximize buttons style &= ~(WS_MAXIMIZEBOX|WS_MINIMIZEBOX|WS_THICKFRAME); ::SetWindowLong(AfxGetMainWnd()->m_hWnd, GWL_STYLE, style); } I wanted the window to be in maximized mode at startup, so in InitInstance function of application class, I modified the ShowWindow call as follows pMainFrame->ShowWindow(SW_MAXIMIZE); Now when I run my application the window appears to be in maximized mode, but it isn't so, because when I move the mouse cursor to the title bar and right click on it, the move sub menu item is enabled. This implies that my window is not in maximized mode, though it appears to be in maximized mode by occupying the full screen area, and using the move option I can drag the window. Now if I comment the code that I've written above in OnNewDocument(), the window is in maximized mode and the move submenu item of the popup menu is disabled, but I will get the maximize and minimize buttons on the title bar. My intention is to let the window be in maximized mode at startup and minimize & maximize buttons should not be there on the title bar. Can any one please help me to figure out my mistake? Thanks Madhavi.
Add Virtual Function "PreCreateWindow" to the MainFrame Class: Like this: BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { // this code disable sysmenu from mainframe cs.style &= ~WS_SYSMENU; if( !CMDIFrameWnd::PreCreateWindow(cs) ) return FALSE; // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return TRUE; }
-
Hi, I am getting a vague problem, and I'm unable to figure out the reason for this. I am working with MDI application. I wanted to remove maximize and minimize buttons of the CMDIMainFrame window. So I handled it in OnNewDocument as shown below. BOOL CLogAppDoc::OnNewDocument() { DWORD style = ::GetWindowLong(AfxGetMainWnd()->m_hWnd, GWL_STYLE); // Remove the thick frame style and the Minimize, Maximize buttons style &= ~(WS_MAXIMIZEBOX|WS_MINIMIZEBOX|WS_THICKFRAME); ::SetWindowLong(AfxGetMainWnd()->m_hWnd, GWL_STYLE, style); } I wanted the window to be in maximized mode at startup, so in InitInstance function of application class, I modified the ShowWindow call as follows pMainFrame->ShowWindow(SW_MAXIMIZE); Now when I run my application the window appears to be in maximized mode, but it isn't so, because when I move the mouse cursor to the title bar and right click on it, the move sub menu item is enabled. This implies that my window is not in maximized mode, though it appears to be in maximized mode by occupying the full screen area, and using the move option I can drag the window. Now if I comment the code that I've written above in OnNewDocument(), the window is in maximized mode and the move submenu item of the popup menu is disabled, but I will get the maximize and minimize buttons on the title bar. My intention is to let the window be in maximized mode at startup and minimize & maximize buttons should not be there on the title bar. Can any one please help me to figure out my mistake? Thanks Madhavi.
Add this:
AfxGetMainWnd()->GetSystemMenu(FALSE)->RemoveMenu(
SC_MOVE, MF_BYCOMMAND | MF_GRAYED);to the
OnNewDocument
method. Then implementON_WM_NCHITTEST()
of theCMainFrame
as follows:UINT CMainFrame::OnNcHitTest(CPoint point)
{
UINT x=CMDIFrameWnd::OnNcHitTest(point);
return (x==HTCAPTION) ? HTTRANSPARENT : x;
}Strange requirements, anyway... :suss:
"though nothing will keep us together we can beat them for ever and ever" rechi
-
Add Virtual Function "PreCreateWindow" to the MainFrame Class: Like this: BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { // this code disable sysmenu from mainframe cs.style &= ~WS_SYSMENU; if( !CMDIFrameWnd::PreCreateWindow(cs) ) return FALSE; // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return TRUE; }