读书人

SDI程序运行最大化,该如何解决

发布时间: 2012-02-17 17:50:42 作者: rapoo

SDI程序运行,最大化
有什么办法让SDI程序一运行就最大化,布满整个桌面?
看了一些网上的资料,代码设置如下:
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.style|=WS_MAXIMIZE;
return TRUE;
}

void CMainFrame::ActivateFrame(int nCmdShow)
{
// TODO: Add your specialized code here and/or call the base class

CFrameWnd::ActivateFrame(nCmdShow);
nCmdShow=SW_SHOWMAXIMIZED;
}

BOOL CMy002App::InitInstance()
{
// The one and only window has been initialized, so show and update it.
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();
return TRUE;
}

程序运行后,并没有最大化。
如果把 m_pMainWnd->ShowWindow(SW_SHOW) 改为 m_pMainWnd->ShowWindow(SW_SHOWMAXMIZED)
程序运行后,先是默认的大小,然后瞬间最大化。
这样虽然达到了最大化的效果,但是明显屏幕有个闪烁的过程。

请问有什么办法能够让SDI程序一运行就是最大化的?


[解决办法]

C/C++ code
void CMainFrame::ActivateFrame(int nCmdShow)    {// TODO: Add your specialized code here and/or call the base classnCmdShow=SW_SHOWMAXIMIZED;  //这句加在这里CFrameWnd::ActivateFrame(nCmdShow);  } 

读书人网 >VC/MFC

热点推荐