1.窗口的最大化
在一个基于文档视图的工程中,如果要让窗口在启动时最大话,我们可以在CXXXAPP的InitInstance()函数的
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
以上代码中红色部分里的SW_SHOW修改为SW_SHOWMAXIMIZED
2.以上窗口在最大化时有一个由小到大的过程比较明显,如果想在窗口出现时直接最大化则只需要在原基础上加一行代码即可
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
m_nCmdShow = SW_SHOWMAXIMIZED;
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
在原基础上加上紫色那行代码即可实现启动时直接窗口的最大化。