我的代码在单文档界面比较好用,但是在多文档的情况下,全屏不彻底,下面有一个窄条没有添满。我看到有人回答过这个问题,说和WS_POPUPWINDOW有关,但是我打不开那个网页,只好来这里问高手了。我的代码如下:
首先在MainFrm.h中
BOOL             m_FullScreen;
WINDOWPLACEMENT  m_WPPrev;
         CRect         m_FullScreenWindowRect;
CToolBar         *m_pWndFullScreenBar;
然后
void CMainFrame::OnFullScreen()
{
RECT DesktopRect;
    WINDOWPLACEMENT WPNew;

m_FullScreen = m_FullScreen ? TRUE : FALSE;

    if(!m_FullScreen)
{
        // need to hide all status bars
        m_wndStatusBar.ShowWindow(SW_HIDE);
       //隐藏工具条
m_wndToolBar.ShowWindow(SW_HIDE);
m_Layout.ShowWindow(SW_HIDE);
m_LayoutGL.ShowWindow(SW_HIDE);

// We'll need these to restore the original state.
GetWindowPlacement (&m_WPPrev);

m_WPPrev.length = sizeof m_WPPrev;

        //Adjust RECT to new size of window
::GetWindowRect(::GetDesktopWindow(), &DesktopRect);

DesktopRect.left -= 1;
DesktopRect.top -= 1;
DesktopRect.bottom += 2;
DesktopRect.right += 2;

      ::AdjustWindowRectEx(&DesktopRect, GetStyle(), TRUE, GetExStyle());

// Remember this for OnGetMinMaxInfo()
m_FullScreenWindowRect = DesktopRect;
        
        WPNew = m_WPPrev;
        WPNew.showCmd =  SW_SHOWNORMAL;
WPNew.rcNormalPosition = DesktopRect;

        m_pWndFullScreenBar=new CToolBar;

        
        if(!m_pWndFullScreenBar->Create(this,CBRS_SIZE_DYNAMIC|CBRS_FLOATING) ||
         !m_pWndFullScreenBar->LoadToolBar(IDR_FULLSCREEN_GLTOOL))
         {
         TRACE0("Failed to create toolbar\n");
         return; // fail to create
         }
        
        
        //don't allow the toolbar to dock
        m_pWndFullScreenBar->EnableDocking(0);
m_pWndFullScreenBar->SetWindowPos(0, 0,0, 0,0,SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_SHOWWINDOW);
m_pWndFullScreenBar->SetWindowText(_T("Hold Ctrl+F to switch between normal and a full screen"));
FloatControlBar(m_pWndFullScreenBar, CPoint(0,0));
m_pWndFullScreenBar->EnableToolTips(TRUE);
m_FullScreen=TRUE;
m_Workshop.ShowWindow(SW_HIDE);
}
    else
{
        m_pWndFullScreenBar->DestroyWindow();
delete m_pWndFullScreenBar;

        m_FullScreen=FALSE;

        m_wndStatusBar.ShowWindow(SW_SHOWNORMAL);
m_wndToolBar.ShowWindow(SW_SHOWNORMAL);
m_Layout.ShowWindow(SW_SHOWNORMAL);
m_LayoutGL.ShowWindow(SW_SHOWNORMAL);
m_Workshop.ShowWindow(SW_SHOWNORMAL);
        WPNew = m_WPPrev;
}
    
    SetWindowPlacement(&WPNew);
}void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) 
{
if(m_FullScreen)
{
lpMMI->ptMaxSize.y = m_FullScreenWindowRect.Height();
lpMMI->ptMaxTrackSize.y = lpMMI->ptMaxSize.y;
lpMMI->ptMaxSize.x = m_FullScreenWindowRect.Width();
lpMMI->ptMaxTrackSize.x = lpMMI->ptMaxSize.x;
}
// CCJFrameWnd::OnGetMinMaxInfo(lpMMI);//必须注销,否则不能编译通过
}

解决方案 »

  1.   

    不知道行不行?
    BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) 

        // Create a window without min/max buttons or sizable border 
        cs.style = WS_OVERLAPPED | /*WS_SYSMENU |*/ WS_BORDER;    // Size the window to 1/3 screen size and center it 
        cs.cy = ::GetSystemMetrics(SM_CYSCREEN) / 3; 
        cs.cx = ::GetSystemMetrics(SM_CXSCREEN) / 3; 
        cs.y = ((cs.cy * 3) - cs.cy) / 2; 
        cs.x = ((cs.cx * 3) - cs.cx) / 2;    // Call the base-class version
        return CFrameWnd::PreCreateWindow(cs); 
    }WS_POPUPWINDOW   Creates a pop-up window with the WS_BORDER, WS_POPUP, and WS_SYSMENU styles. The WS_CAPTION style must be combined with the WS_POPUPWINDOW style to make the Control menu visible
      

  2.   

    CCJFrameWnd::OnGetMinMaxInfo(lpMMI);//必须注销,否则不能编译通过
    改为
    CMainFrame::OnGetMinMaxInfo(lpMMI);//
      

  3.   

    huanyun(无妻徒刑),感谢你的回帖不过你的办法可以编译通过,不能运行。而且我在那个例子的源代码中这样改的时候也运行不出来,还要用任务管理器关掉
      

  4.   

    那个例子用到了自己的派生类不是CMainFrame
    所以不能更改
    看看下面的对你应该又帮助
    http://www.vckbase.com/code/listcode.asp?mclsid=5&sclsid=509