int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; // enable Windows XP look (in other OS Office XP look will be used): CBCGPVisualManager::SetDefaultManager (RUNTIME_CLASS (CVisualManager)); CBCGPDockManager::SetDockMode (BCGP_DT_STANDARD); CBCGPToolBar::m_dblLargeImageRatio = 1.2; CBCGPToolBar::SetSizes (CSize (22, 22), CSize (16, 16)); CBCGPToolBar::SetMenuSizes (CBCGPToolBar::GetMenuButtonSize (), CSize (16, 16)); // 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); theApp.m_nColorMode = (WORD)dc.GetDeviceCaps (BITSPIXEL); //----------------------- // Create the addressbar: //----------------------- CBCGPToolbarComboBoxButton::SetFlatMode (FALSE); CBCGPToolbarEditBoxButton::SetFlatMode (FALSE); m_wndAddressBar.EnableNavigationButtons (ID_GOTO_BACK, ID_GOTO_FORWARD, ID_GOTO_HISTORY, ID_VIEW_HISTORY, 0); if (!m_wndAddressBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndAddressBar.LoadToolBar (IDR_ADDRESS_BAR, theApp.m_nColorMode >= 16 ? IDB_ADDRESS_BAR : 0, 0, 0, theApp.m_nColorMode >= 16 ? IDB_ADDRESS_BAR_120 : 0)) { TRACE0("Failed to create addressbar\n"); return -1; // fail to create } m_wndAddressBar.ReplaceButton (IDC_ADDRESS, CBCGPToolbarComboBoxButton (IDC_ADDRESS, -1, CBS_DROPDOWN)); m_wndAddressBar.SetStretchID (IDC_ADDRESS); m_wndAddressBar.ReplaceButton (IDC_SEARCH, CBCGPToolbarEditBoxButton (IDC_SEARCH, -1)); CMenu menu; VERIFY (menu.LoadMenu (IDR_SEARCH_POPUP)); CMenu* pMenuSearch = menu.GetSubMenu (0); VERIFY (pMenuSearch != NULL); m_wndAddressBar.ReplaceButton (ID_GOTO_SEARCH, CBCGPToolbarMenuButton (ID_GOTO_SEARCH, pMenuSearch->GetSafeHmenu (), 4)); //-------------------- // Create the menubar: //-------------------- if (!m_wndMenuBar.CreateEx (this, TBSTYLE_TRANSPARENT)) { TRACE0("Failed to create menubar\n"); return -1; // fail to create } m_wndMenuBar.SetBarStyle ((m_wndMenuBar.GetBarStyle() & ~(CBRS_GRIPPER | CBRS_BORDER_ANY)) | CBRS_SIZE_DYNAMIC); m_wndMenuBar.EnableCustomizeButton (TRUE, (UINT)-1, _T("")); //------------------ // Create links bar: //------------------ if (!m_wndLinksBar.CreateEx (this, TBSTYLE_TRANSPARENT, dwDefaultToolbarStyle, CRect(0, 0, 0, 0), AFX_IDW_DIALOGBAR + 1)) { TRACE0("Failed to create linksbar\n"); } CString strLinksLabel; strLinksLabel.LoadString (IDS_LINKSBAR_NAME); m_wndLinksBar.SetWindowText (strLinksLabel); m_wndLinksBar.SetBarStyle (m_wndLinksBar.GetBarStyle() & ~(CBRS_GRIPPER | CBRS_BORDER_ANY)); m_wndLinksBar.EnableCustomizeButton (TRUE, (UINT)-1, _T("")); //-------------- // Create rebar: //-------------- m_wndReBar.LockBars (); if (!m_wndReBar.Create(this) || !m_wndReBar.AddBar(&m_wndMenuBar, NULL, NULL, RBBS_GRIPPERALWAYS | RBBS_FIXEDBMP | RBBS_BREAK | RBBS_HIDDEN) || !m_wndReBar.AddBar(&m_wndLinksBar, strLinksLabel, NULL, RBBS_GRIPPERALWAYS | RBBS_FIXEDBMP | RBBS_BREAK)) { TRACE0("Failed to create rebar\n"); return -1; // fail to create } m_wndMenuBar.AdjustLayout (); m_wndLinksBar.AdjustLayout (); //--------------- // Create tabbar: //--------------- if (!m_wndTabBar.Create (_T(""), this, FALSE, MAKEINTRESOURCE(IDD_TAB_BAR), CBRS_SIZE_DYNAMIC | CBRS_ALIGN_TOP | CBRS_TOOLTIPS | CBRS_FLYBY, AFX_IDW_DIALOGBAR + 2, CBRS_BCGP_REGULAR_TABS, 0)) { TRACE0("Failed to create addressbar\n"); return -1; // fail to create } EnableDocking(CBRS_ALIGN_ANY); m_wndReBar.EnableDocking (CBRS_TOP); m_wndTabBar.EnableDocking (CBRS_TOP); DockControlBar (&m_wndReBar); DockControlBar (&m_wndTabBar); ShowControlBar (&m_wndMenuBar, FALSE, FALSE, FALSE); ShowControlBar (&m_wndTabBar, TRUE, FALSE, FALSE); //------------------- // Create status bar: //------------------- if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create statusbar\n"); return -1; // fail to create } //------------------------------ // First pane - image/animation: //------------------------------ m_wndStatusBar.SetPaneStyle (nStatusInfo, SBPS_STRETCH | SBPS_NOBORDERS); m_wndStatusBar.SetPaneWidth (nStatusProgress, 80); m_wndMenuBar.SetBarStyle(m_wndMenuBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); m_wndLinksBar.SetBarStyle(m_wndLinksBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); //----------------------- // Set up Favorites menu: //----------------------- VERIFY (theApp.m_Favorites.CreateMenu (m_menuFavotites)); // Load control bar icons: CBCGPToolBarImages imagesExplorer; imagesExplorer.SetImageSize (CSize (16, 16)); if (theApp.m_nColorMode >= 16) { imagesExplorer.SetTransparentColor (RGB (255, 0, 255)); } imagesExplorer.Load ( theApp.m_nColorMode >= 16 ? IDB_EXPLORER_32 : theApp.m_nColorMode >= 8 ? IDB_EXPLORER_256 : IDB_EXPLORER ); if (!m_wndExplorer.Create (_T("Favorites Center"), this, CRect (0, 0, 200, 200), TRUE, ID_VIEW_FAVORITES_CENTER, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI)) { TRACE0("Failed to create Workspace bar\n"); return -1; // fail to create } m_wndExplorer.SetIcon (imagesExplorer.ExtractIcon (0), FALSE); m_wndExplorer.EnableDocking(CBRS_ALIGN_LEFT); EnableDocking(CBRS_ALIGN_ANY); EnableAutoHideBars(CBRS_ALIGN_ANY); DockControlBar (&m_wndExplorer); // Enable windows manager: EnableWindowsDialog (ID_WINDOW_MANAGER, IDS_WINDOWS_MANAGER, TRUE); UINT nTicID = 0; if (theApp.m_nColorMode >= 16) { nTicID = IDR_TOOLBAR_IC_32; } else if (theApp.m_nColorMode >= 8) { nTicID = IDR_TOOLBAR_IC_256; } CBCGPToolBar::AddToolBarForImageCollection ( IDR_TOOLBAR_IC, // Toolbar (need for map "Command - Image") nTicID, // "Hot" images nTicID, // "Cold" images nTicID); // Menu images EnableFullScreenMode(ID_VIEW_FULLSCREEN); return 0; }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerOfficeXP)); CMFCToolBarComboBoxButton::SetFlatMode (); CMFCToolBarComboBoxButton::SetCenterVert (); CMFCFontComboBox::m_bDrawUsingFont = TRUE; if (CFrameWndEx::OnCreate(lpCreateStruct) == -1) return -1; if (!CreateMenuBar()) return -1; if (!CreateToolBar()) return -1; if (!CreateFormatBar()) return -1; if (!CreateStatusBar()) return -1; EnableDocking(CBRS_ALIGN_ANY); if (!CreateTaskPane()) return -1; if (!CreateRulerBar()) return -1; CMFCToolBar::AddToolBarForImageCollection (IDR_TOOLBAR_IMAGES); CMFCToolBar::AddToolBarForImageCollection (IDR_BORDER_TYPE); CMFCToolBar::EnableQuickCustomization (); m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); m_wndFormatBar.EnableDocking(CBRS_ALIGN_ANY); m_wndTaskPane.EnableDocking(CBRS_ALIGN_RIGHT | CBRS_ALIGN_LEFT); DockPane(&m_wndMenuBar); DockPane(&m_wndToolBar); DockPane(&m_wndFormatBar); DockPane(&m_wndTaskPane); CWnd* pView = GetDlgItem(AFX_IDW_PANE_FIRST); if (pView != NULL) { pView->SetWindowPos(&wndBottom, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE); } //---------------------------------------- // Allow user-defined toolbars operations: //---------------------------------------- InitUserToolbars (NULL, uiFirstUserToolBarId, uiLastUserToolBarId); //-------------------- // Set basic commands: //-------------------- CList<UINT, UINT> lstBasicCommands; lstBasicCommands.AddTail (ID_FILE_NEW); lstBasicCommands.AddTail (ID_FILE_OPEN); lstBasicCommands.AddTail (ID_FILE_SAVE); lstBasicCommands.AddTail (ID_FILE_PRINT); lstBasicCommands.AddTail (ID_APP_EXIT); lstBasicCommands.AddTail (ID_EDIT_UNDO); lstBasicCommands.AddTail (ID_EDIT_CUT); lstBasicCommands.AddTail (ID_EDIT_COPY); lstBasicCommands.AddTail (ID_EDIT_PASTE); lstBasicCommands.AddTail (ID_EDIT_SELECT_ALL); lstBasicCommands.AddTail (ID_EDIT_FIND); lstBasicCommands.AddTail (ID_EDIT_REPEAT); lstBasicCommands.AddTail (ID_EDIT_REPLACE); lstBasicCommands.AddTail (ID_OLE_EDIT_PROPERTIES); lstBasicCommands.AddTail (ID_VIEW_OPTIONS); lstBasicCommands.AddTail (ID_VIEW_CUSTOMIZE); lstBasicCommands.AddTail (ID_VIEW_APP_LOOK); lstBasicCommands.AddTail (ID_VIEW_FULL_SCREEN); lstBasicCommands.AddTail (ID_OLE_INSERT_NEW); lstBasicCommands.AddTail (ID_FORMAT_FONT); lstBasicCommands.AddTail (ID_INSERT_BULLET); lstBasicCommands.AddTail (ID_CHAR_COLOR); lstBasicCommands.AddTail (ID_HELP_INDEX); lstBasicCommands.AddTail (ID_APP_ABOUT); lstBasicCommands.AddTail (ID_PARA_LEFT); lstBasicCommands.AddTail (ID_VIEW_TOOLBARS); CMFCToolBar::SetBasicCommands (lstBasicCommands); //-------------------------------------------------------------------- // Enable conttol bar context menu (list of bars + customize command): //-------------------------------------------------------------------- EnablePaneMenu ( TRUE, ID_VIEW_CUSTOMIZE, _T("Customize..."), ID_VIEW_TOOLBARS, FALSE, TRUE); EnableFullScreenMode (ID_VIEW_FULL_SCREEN); EnableFullScreenMainMenu (FALSE); return 0; }