1.MultiDoc 程序的初始最大化和防止启动打开一个View的方法
(1) 防止启动打开一个View的方法,在App类的InitInstance方法加入以下代码:
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
//防止启动打开一个View的方法
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
// The main window has been initialized, so show and update it.
//程序运行,最大化显示
m_nCmdShow = SW_MAXIMIZE;
pMainFrame->ShowWindow(m_nCmdShow);
pMainFrame->UpdateWindow();
(2)改变View的大小
在CChildFrame的PreCreateWindow方法中改变cs属性;
BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.cx = 300;
cs.cy = 300;
if( !CMDIChildWnd::PreCreateWindow(cs) )
return FALSE;
return TRUE;
}
2.Single Doc文件程序的初始最大化
为CMainFrame添加ActivateFrame虚函数,加入代码:nCmdShow = SW_MAXIMIZE;即可
void CMainFrame::ActivateFrame(int nCmdShow)
{
// TODO: Add your specialized code here and/or call the base class
nCmdShow = SW_MAXIMIZE;
CFrameWnd::ActivateFrame(nCmdShow);
}