| 我们可以在WINAPP类的初始函数InitInstance内设置框架窗口的初始状态 具体函数如下
 
 我们可以看到,将WinApp类的成员变量m_nCmdShow 赋值为 SW_SHOWMAXIMIZED;复制代码BOOL CDemoApp::InitInstance()
{
        AfxEnableControlContainer();
        // Standard initialization
        // If you are not using these features and wish to reduce the size
        //  of your final executable, you should remove from the following
        //  the specific initialization routines you do not need.
#ifdef _AFXDLL
        Enable3dControls();                        // Call this when using MFC in a shared DLL
#else
        Enable3dControlsStatic();        // Call this when linking to MFC statically
#endif
        // Change the registry key under which our settings are stored.
        // TODO: You should modify this string to be something appropriate
        // such as the name of your company or organization.
        SetRegistryKey(_T("Local AppWizard-Generated Applications"));
        LoadStdProfileSettings();  // Load standard INI file options (including MRU)
        // Register the application's document templates.  Document templates
        //  serve as the connection between documents, frame windows and views.
        CMultiDocTemplate* pDocTemplate;
        pDocTemplate = new CMultiDocTemplate(
                IDR_DEMOTYPE,
                RUNTIME_CLASS(CDemoDoc),
                RUNTIME_CLASS(CChildFrame), // custom MDI child frame
                RUNTIME_CLASS(CDemoView));
        AddDocTemplate(pDocTemplate);
        // create main MDI Frame window
        CMainFrame* pMainFrame = new CMainFrame;
        if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
                return FALSE;
        m_pMainWnd = pMainFrame;
        // 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;
        //最大化
        m_nCmdShow = SW_SHOWMAXIMIZED;
//        //最小化
//        m_nCmdShow = SW_SHOWMINIMIZED;   
        pMainFrame->ShowWindow(m_nCmdShow);
        pMainFrame->UpdateWindow();
        return TRUE;
}
再将主框架窗口以这种形式显示出来就实现了。pMainFrame->ShowWindow(m_nCmdShow);但执行程序后,会发现子框架并没有最大化,
 这就有点不对称了。
 我们也可以将子框架在初始化最大化显示。
 只在要子框架窗口类的ActivateFrame函数内设置显示模式就好了。
 
 复制代码void CChildFrame::ActivateFrame(int nCmdShow) 
{
        //最大化
        nCmdShow = SW_SHOWMAXIMIZED;
//        //最小化
//        nCmdShow = SW_SHOWMINIMIZED
        CMDIChildWnd::ActivateFrame(nCmdShow);
}
 
   上位机VC MFC程序开发精典实例大全源码与视频讲解配套下载408例 经历1年的编程与录制点击进入查看 
   如果您认可,可联系功能定制! 如果您着急,充值会员可直接联系发您资料!    
 
 
 |