![]() 圖一 |
![]() 圖二 |
![]() 圖三 |
void CMainFrame::ViewMode(int nViewType) { CRect ClientRect; CRect WindowRect; CRect ToolbarRect; CRect StatusbarRect; //獲取窗體、客戶區及工具條大小 WindowRect = m_WindowRect; ClientRect = m_ClientRect; m_wndToolBar.GetWindowRect(&ToolbarRect); //獲取邊框及標題欄大小 int borderHeight = GetSystemMetrics(SM_CYBORDER); int captionHeight = GetSystemMetrics(SM_CYCAPTION); //獲取狀態條大小 CStatusBar* pStatus = (CStatusBar*) AfxGetApp()->m_pMainWnd->GetDescendantWindow(AFX_IDW_STATUS_BAR); pStatus->GetWindowRect(&StatusbarRect); //??抗ぞ邨l DockControlBar(&m_wndToolBar); int CompactCx; //新窗體寬 int CompactCy; //新窗體高 //以多種模式顯示 switch(nViewType) { case 0: //正常顯示模式 { //顯示菜單 if ( hMenu != NULL ) ::SetMenu( m_hWnd, hMenu ); //顯示狀態條 pStatus->ShowWindow(SW_SHOW); //新窗體寬、高 CompactCx=WindowRect.Width(); CompactCy=WindowRect.Height(); } break; case 1: //簡潔顯示模式 { //顯示菜單 if ( hMenu != NULL ) ::SetMenu( m_hWnd, hMenu ); //隱藏狀態條 pStatus->ShowWindow(SW_HIDE); //新窗體寬、高 CompactCx=WindowRect.Width(); CompactCy=WindowRect.Height() - ClientRect.Height() + ToolbarRect.Height() - borderHeight; } break; case 2: //精簡顯示模式 { //隱藏菜單 hMenu = ::GetMenu(m_hWnd); ::SetMenu( m_hWnd, NULL ); //隱藏狀態條 pStatus->ShowWindow(SW_HIDE); //新窗體寬、高 CompactCx=WindowRect.Width(); CompactCy=captionHeight + ToolbarRect.Height() + borderHeight*2; } break; } //設置新窗體顯示 SetWindowPos( &wndTop, WindowRect.left, WindowRect.top, CompactCx, CompactCy, SWP_SHOWWINDOW); } |
原文轉自:http://www.anti-gravitydesign.com