int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CBCGPMDIFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; HICON m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); SetIcon(m_hIcon, TRUE); // Set big icon // Menu will not take the focus on activation: CBCGPPopupMenu::SetForceMenuFocus (FALSE); EnableDocking(CBRS_ALIGN_TOP); if (!m_wndMenuBar.Create (this)) { TRACE0("Failed to create menubar\n"); return -1; // fail to create } m_wndMenuBar.SetBarStyle(m_wndMenuBar.GetBarStyle() | CBRS_SIZE_DYNAMIC); m_wndMenuBar.SetRecentlyUsedMenus(FALSE); //不加这句话,菜单初始时,只显示一个下拉键头,不显示全部菜单项. // Detect color depth. 256 color toolbars can be used in the // high or true color modes only (bits per pixel is > 8): CClientDC dc (this); BOOL bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 8; UINT uiToolbarHotID = bIsHighColor ? IDB_TOOLBAR256 : 0; if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } // TODO: Delete these three lines if you don't want the toolbar to be dockable m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); EnableAutoHideBars(CBRS_ALIGN_ANY); DockControlBar(&m_wndMenuBar); CreateMineToolBar(); // 创建工具栏 m_MineToolbar.EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_MineToolbar); // Allow user-defined toolbars operations: InitUserToobars (NULL, uiFirstUserToolBarId, uiLastUserToolBarId); AdjustClientArea(); // Enable windows manager: EnableWindowsDialog (ID_WINDOW_MANAGER, IDS_WINDOWS_MANAGER, TRUE); OnAppLook (m_nAppLook); SetWindowText("综合设计环境"); SetTitle( "综合设计环境" ); // VISUAL_MANAGER return 0; }
void CMainFrame::OnFullScreen() { ShowFullScreen(); if (!IsFullScreen ()) { AdjustClientArea (); } }
//**************************************************************************************** void CBCGPFrameWnd::ActiveItemRecalcLayout () { COleClientItem* pActiveItem = GetInPlaceActiveItem (); if (pActiveItem != NULL && pActiveItem->m_pInPlaceFrame != NULL) { CRect rectBounds = m_dockManager.GetClientAreaBounds (); pActiveItem->m_pInPlaceFrame->OnRecalcLayout (); } AdjustClientArea (); }
//***************************************************************************** void CBCGPFrameWnd::AdjustDockingLayout (HDWP hdwp) { ASSERT_VALID (this); if (m_dockManager.IsInAdjustLayout ()) { return; } m_dockManager.AdjustDockingLayout (hdwp); AdjustClientArea (); if (m_dockManager.IsOLEContainerMode ()) { RecalcLayout (); } }
//************************************************************************************* void CBCGPOleCntrFrameWnd::RecalcLayout (BOOL bNotify) { AdjustClientArea(); m_dockManager.AdjustDockingLayout (); m_dockManager.RecalcLayout (bNotify); CView* pView = GetActiveView (); if (pView != NULL && pView->IsKindOf (RUNTIME_CLASS (CBCGPPrintPreviewView)) && m_dockManager.IsPrintPreviewValid ()) { CRect rectClient = m_dockManager.GetClientAreaBounds (); pView->SetWindowPos (NULL, rectClient.left, rectClient.top, rectClient.Width (), rectClient.Height (), SWP_NOZORDER | SWP_NOACTIVATE); } m_pInPlaceFrame->RecalcLayout (bNotify); }
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) { BOOL isFullScreen = IsFullScreen(); if (!isFullScreen) { if (pMsg->message == WM_SYSKEYUP) { BOOL isCtrlPressed = (0x8000 & GetKeyState(VK_CONTROL)) != 0; BOOL isShiftPressed = (0x8000 & GetKeyState(VK_SHIFT)) != 0; if (pMsg->wParam == VK_MENU || (pMsg->wParam == VK_F10 && !isCtrlPressed && !isShiftPressed)) { if (m_wndMenuBar.IsTempVisible ()) { OnViewMenuBar(); } else if (!m_wndMenuBar.IsWindowVisible ()) { OnViewMenuBar(); m_wndMenuBar.SetFocus (); m_wndMenuBar.SetTempVisible (TRUE); return TRUE; } } } } BOOL bRes = CMDIFrameWnd::PreTranslateMessage(pMsg); if (isFullScreen) { if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE && !IsFullScreen()) { AdjustClientArea (); } } return bRes; }
//************************************************************************************* void CBCGPFrameWnd::RecalcLayout (BOOL bNotify) { if (m_bInRecalcLayout) return; m_bInRecalcLayout = TRUE; BOOL bWasOleInPlaceActive = m_Impl.m_bIsOleInPlaceActive; m_Impl.m_bIsOleInPlaceActive = FALSE; COleClientItem* pActiveItem = GetInPlaceActiveItem (); if (pActiveItem != NULL && pActiveItem->m_pInPlaceFrame != NULL && pActiveItem->GetItemState () == COleClientItem::activeUIState) { m_Impl.m_bIsOleInPlaceActive = TRUE; m_Impl.m_bHadCaption = (GetStyle () & WS_CAPTION) != 0; } if (!m_bIsMinimized) { CView* pView = GetActiveView (); if (m_dockManager.IsPrintPreviewValid () || m_pNotifyHook != NULL) { if (pView != NULL && pView->IsKindOf (RUNTIME_CLASS (CBCGPPrintPreviewView))) { m_dockManager.RecalcLayout (bNotify); CRect rectClient = m_dockManager.GetClientAreaBounds (); pView->SetWindowPos (NULL, rectClient.left, rectClient.top, rectClient.Width (), rectClient.Height (), SWP_NOZORDER | SWP_NOACTIVATE); } else { if (bNotify && m_pNotifyHook != NULL) { ActiveItemRecalcLayout (); } else { m_bInRecalcLayout = FALSE; CFrameWnd::RecalcLayout (bNotify); AdjustClientArea (); } } } else { m_dockManager.RecalcLayout (bNotify); AdjustClientArea (); } } m_bInRecalcLayout = FALSE; if (bWasOleInPlaceActive != m_Impl.m_bIsOleInPlaceActive) { if (!m_Impl.m_bHadCaption) { if (m_Impl.m_bIsOleInPlaceActive) { ModifyStyle (0, WS_CAPTION); } else { ModifyStyle (WS_CAPTION, 0); } } m_Impl.OnChangeVisualManager (); SetWindowPos (NULL, -1, -1, -1, -1, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_FRAMECHANGED); } }
//***************************************************************************** void CBCGPOleCntrFrameWnd::AdjustDockingLayout (HDWP /*hdwp*/) { ASSERT_VALID (this); AdjustClientArea(); }