有两种方式可以让子窗口最大化,一种是在动态创建CChildFrame的时候,一种是在创建CChildFrame以后,显示CChildFrame的时候:
1、动态创建CChildFrame窗口,代码如下:
CCreateContext context;
context.m_pCurrentDoc=pDocument;
context.m_pNewDocTemplate=theApp.m_pDocTemplate;
CChildFrame * m_pFrame=new CChildFrame();
context.m_pNewViewClass=RUNTIME_CLASS(CView);
if(!m_pFrame->LoadFrame(IDR_MAINFRAME,WS_SYSMENU | WS_MAXIMIZE|WS_OVERLAPPEDWINDOW,this,&context))
return FALSE;
m_pFrame->ShowWindow(SW_SHOWMAXIMIZED);
m_pFrame->InitialUpdateFrame(pDocument,true);
2、在CChildFrame添加消息映射函数,代码如下:
void CChildFrame::ActivateFrame(int nCmdShow)
{
// TODO: Add your specialized code here and/or call the base class
nCmdShow=SW_SHOWMAXIMIZED;
CMDIChildWnd::ActivateFrame(nCmdShow);
}