m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
    m_pMainWnd->UpdateWindow();vc2010中,在initinstance函数中使用如上的语句,起始窗口并没有全屏最大化;需要点击最大化按钮两次后才全屏最大化。哪位大哥知道为什么哈?

解决方案 »

  1.   

    我用VS2008SP1建了一个SDI工程,试了一下没有问题~
      

  2.   

    我在网上搜索了一下,和下面msdn论坛中的问题一样,可是都没有答案。http://social.msdn.microsoft.com/Forums/zh-CN/vcgeneral/thread/7ec2424f-e787-420e-8861-7c24db051562
      

  3.   

    我试了一下
    没问题啊
    我是在创建工程是选择了最大化窗口
    不过代码就是这样了
    win7旗舰版+2010旗舰版
      

  4.   

    楼主是使用了CFormView了吧,好像有最大化显示的问题, 在MainFrame里删掉注册表中的一项 AfxGetApp()->DelRegTree(hKey, "WindowPlacement");
    或者最大化前 m_pMainWnd->ShowWindow(SW_NORMAL);// SW_SHOWDEFAULT
    m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);前者可能会造成最大化按钮或标题栏双击时界面展现的问题,需处理相应的消息后者会造成窗口闪屏及跳动的问题
      

  5.   

    1,在*****App::InitInstance()里
    CCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo);
    后加 m_nCmdShow=SW_SHOWMAXMIZED //最大化  2,在*****App::InitInstance()里
    m_pMainWnd-> ShowWindow(SW_SHOW);
    改为m_pMainWnd-> ShowWindow(SW_SHOWMAXMIZED);3,在CMainFrame::PreCreateWindow(CREATESTRUCT& cs)中
    cs.style |= WS_MAXIMIZE  4,mainframe的oncreate中加入 ShowWindow(SW_MAXIMIZE);5void CMainFrame::ActivateFrame(int nCmdShow)   
    {  nCmdShow = SW_MAXIMIZE;  CFrameWnd::ActivateFrame(nCmdShow);  
    }
    试试这些方法行不?
      

  6.   


    就是CFormView,不知道为什么会出现问题。
    不过您给的方法还是比较管用的,就是先出现一个窗口,接着闪屏最大化。
      

  7.   

    可以试试这句。加在APP里面的IntInstance函数里面。BOOL CfffApp::InitInstance()
    {
    /***********省略一点*******************/
    // Register the application's document templates.  Document templates
    //  serve as the connection between documents, frame windows and views
    CSingleDocTemplate* pDocTemplate;
    pDocTemplate = new CSingleDocTemplate(
    IDR_MAINFRAME,
    RUNTIME_CLASS(CfffDoc),
    RUNTIME_CLASS(CMainFrame),       // main SDI frame window
    RUNTIME_CLASS(CfffView));
    if (!pDocTemplate)
    return FALSE;
    AddDocTemplate(pDocTemplate);

    CleanState(_T("WorkSpace")); // Parse command line for standard shell commands, DDE, file open
    CCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo);
    // Dispatch commands specified on the command line.  Will return FALSE if
    // app was launched with /RegServer, /Register, /Unregserver or /Unregister.
    if (!ProcessShellCommand(cmdInfo))
    return FALSE; // The one and only window has been initialized, so show and update it
    m_pMainWnd->ShowWindow(SW_SHOW);
    /*************这里可以设置最大化,方法上面都说过了。
    m_pMainWnd-> ShowWindow(SW_SHOWMAXMIZED);
    ***********************************/
    m_pMainWnd->UpdateWindow();
    // call DragAcceptFiles only if there's a suffix
    //  In an SDI app, this should occur after ProcessShellCommand
    return TRUE;
    }
      

  8.   

    晕,竟然改不了颜色。BOOL CfffApp::InitInstance()
    {
    /***********省略一点*******************/
        // Register the application's document templates.  Document templates
        //  serve as the connection between documents, frame windows and views
        CSingleDocTemplate* pDocTemplate;
        pDocTemplate = new CSingleDocTemplate(
            IDR_MAINFRAME,
            RUNTIME_CLASS(CfffDoc),
            RUNTIME_CLASS(CMainFrame),       // main SDI frame window
            RUNTIME_CLASS(CfffView));
        if (!pDocTemplate)
            return FALSE;
        AddDocTemplate(pDocTemplate);
    /****************这里****************************/
        
        CleanState(_T("WorkSpace"));/****************上面***************************/    // Parse command line for standard shell commands, DDE, file open
        CCommandLineInfo cmdInfo;
        ParseCommandLine(cmdInfo);
        // Dispatch commands specified on the command line.  Will return FALSE if
        // app was launched with /RegServer, /Register, /Unregserver or /Unregister.
        if (!ProcessShellCommand(cmdInfo))
            return FALSE;        // The one and only window has been initialized, so show and update it
        m_pMainWnd->ShowWindow(SW_SHOW);
    /*************这里可以设置最大化,方法上面都说过了。
    m_pMainWnd-> ShowWindow(SW_SHOWMAXMIZED);
    ***********************************/
        m_pMainWnd->UpdateWindow();
        // call DragAcceptFiles only if there's a suffix
        //  In an SDI app, this should occur after ProcessShellCommand
        return TRUE;
    }