在CMainFrame類下添加變量:
public: 
    BOOL m_bFullScreenMode;        //全屏顯示標志
private: 
    WINDOWPLACEMENT m_OldWndPlacement;         //用來保存原窗口位置 
    CRect m_FullScreenRect;        //表示全屏顯示時的窗口位置
添加函數:
public: 
    void FullScreenModeOn(); 
    void FullScreenModeOff();
重載函數(自己也不算太明白): 
    void OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI);
內容為:
void CMainFrame::FullScreenModeOn() 
{ 
    GetWindowPlacement( &m_OldWndPlacement); 
    CRect WindowRect; 
    GetWindowRect(&WindowRect); 
    CRect ClientRect; 
    RepositionBars(0, 0xffff, AFX_IDW_PANE_FIRST, reposQuery, &ClientRect); 
    ClientToScreen(&ClientRect);
// 獲取屏幕的分辨率
    int nFullWidth=GetSystemMetrics(SM_CXSCREEN); 
    int nFullHeight=GetSystemMetrics(SM_CYSCREEN); 
    
    //將除控制條外的客戶區全屏顯示到從(0,0)到(nFullWidth, nFullHeight)區域, 
    //將(0,0)和(nFullWidth, nFullHeight)兩個點外擴充原窗口和除控制條之外的 客戶區位置間的差值, 就得到全屏顯示的窗口位置 
    m_FullScreenRect.left = WindowRect.left - ClientRect.left; 
    m_FullScreenRect.top = WindowRect.top - ClientRect.top; 
    m_FullScreenRect.right = WindowRect.right - ClientRect.right + nFullWidth; 
    m_FullScreenRect.bottom = WindowRect.bottom - ClientRect.bottom + nFullHeight; 
    m_bFullScreenMode = TRUE; 
    
    //設置全屏顯示標志為 TRUE 
    //進入全屏顯示狀態 
    WINDOWPLACEMENT wndpl; 
    wndpl.length=sizeof(WINDOWPLACEMENT); 
    wndpl.flags=0; 
    wndpl.showCmd=SW_SHOWNORMAL; 
    wndpl.rcNormalPosition=m_FullScreenRect; 
    SetWindowPlacement(&wndpl);
    m_bFullScreenMode=true; 
}
void CMainFrame::FullScreenModeOff() 
{ 
    ShowWindow(SW_HIDE); 
    SetWindowPlacement(&m_OldWndPlacement); 
    m_bFullScreenMode=false; 
}
void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) 
{ 
    if(m_bFullScreenMode) 
    { 
        lpMMI -> ptMaxSize.x = m_FullScreenRect.Width(); 
        lpMMI -> ptMaxSize.y = m_FullScreenRect.Height(); 
        lpMMI -> ptMaxPosition.x=m_FullScreenRect.Width(); 
        lpMMI -> ptMaxPosition.y=m_FullScreenRect.Height(); 
        // 最大的Track尺寸也要改變 
        lpMMI -> ptMaxTrackSize.x=m_FullScreenRect.Width(); 
        lpMMI -> ptMaxTrackSize.y=m_FullScreenRect.Height(); 
    } 
    CFrameWnd::OnGetMinMaxInfo(lpMMI) ; 
}
對CMainFrame類改動到此為止。
只需要在view中添加消息,獲取CMainFrame的指針pWnd,調用FullScreenModeOn/Off()即可。
