Maximizing app at startup - how?
-
Can someone please enlighten me about how to maximize the app's mainframe at startup? I have tried calling ShowWindow() from the InitInstance() and that doesn't do it. I've looked through the MS docs in the Visual Studio 6 and not come accross anything relevant (like a code snippet, for example!) Some pointers would be greatly appreciated! One person suggested setting the style to WS_MAXIMIZE in PreCreateWindow() but that does not do it.
-
Can someone please enlighten me about how to maximize the app's mainframe at startup? I have tried calling ShowWindow() from the InitInstance() and that doesn't do it. I've looked through the MS docs in the Visual Studio 6 and not come accross anything relevant (like a code snippet, for example!) Some pointers would be greatly appreciated! One person suggested setting the style to WS_MAXIMIZE in PreCreateWindow() but that does not do it.
In the CWinApp descendent: // The one and only window has been initialized, so show and update it. m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED); m_pMainWnd->UpdateWindow(); SW_SHOWMAXIMIZED does it for you. Also in the Application wizard in step 4 of 6 there's an Advanced Button. Follow that button to the Windows Style Tab and check the Maximized box.
-
Can someone please enlighten me about how to maximize the app's mainframe at startup? I have tried calling ShowWindow() from the InitInstance() and that doesn't do it. I've looked through the MS docs in the Visual Studio 6 and not come accross anything relevant (like a code snippet, for example!) Some pointers would be greatly appreciated! One person suggested setting the style to WS_MAXIMIZE in PreCreateWindow() but that does not do it.
-
Both of them are correct!! but only if you join both of their answers at InitInstanse there is a variable called p_MainWnd do the following p_MainWnd->ShowWindow(WS_MAXIMISE); a good place to put it is at the end of that function
You don't want to pass WS_MAXIMIZE, a style code, to ShowWindow. You're supposed to do as Mr. Warg pointed out: Change pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); to pMainFrame->ShowWindow(SW_SHOWMAXIMIZED); pMainFrame->UpdateWindow(); Note the WS_* in front means a *W*indow *S*tyle code, whereas the SW_* in front means a *S*how*W*indow code. AppWizard supplies the pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); code for you; all you have to do is to replace the m_nCmdShow with SW_SHOWMAXIMIZED, and you're in business!! Brian Hart