前言
在启动MFC应用程序时,希望初始状态是最大化充满屏幕显示,并且不能闪烁,即由小变大。参考网上的资料,并经过试验,共有如下三处代码需要修改。
1、窗口风格
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style |= WS_VISIBLE | WS_MAXIMIZE;
if (!CMDIFrameWndEx::PreCreateWindow(cs))
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return TRUE;
}
2、最大化显示
BOOL CMFCApp::InitInstance()
{
m_nCmdShow = SW_SHOWMAXIMIZED;
// The main window has been initialized, so show and update it
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
return TRUE;
}
3、不读取配置
BOOL CMFCApp::LoadState(LPCTSTR lpszSectionName /*= NULL*/, CFrameImpl *pFrameImpl /*= NULL*/)
{
return true;
}
结论
经过上述三处设置,程序启动时为初始最大化,且不会闪烁。