int CChildView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CWnd ::OnCreate(lpCreateStruct) == -1) return -1; // // Load the bitmap. // m_bitmap.LoadBitmap (IDB_BITMAP); // // Create a palette for a gradient fill if this is a palettized device. // CClientDC dc (this); if (dc.GetDeviceCaps (RASTERCAPS) & RC_PALETTE) { struct { LOGPALETTE lp; PALETTEENTRY ape[63]; } pal; LOGPALETTE* pLP = (LOGPALETTE*) &pal; pLP->palVersion = 0x300; pLP->palNumEntries = 64; for (int i=0; i<64; i++) { pLP->palPalEntry[i].peRed = 0; pLP->palPalEntry[i].peGreen = 0; pLP->palPalEntry[i].peBlue = 255 - (i * 4); pLP->palPalEntry[i].peFlags = 0; } m_palette.CreatePalette (pLP); } return 0; }
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; }
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) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; // enable Office 2007 look: CBCGPVisualManager2007::SetStyle (CBCGPVisualManager2007::VS2007_LunaBlue); CBCGPVisualManager::SetDefaultManager (RUNTIME_CLASS (CBCGPVisualManager2007)); CBCGPToolBar::EnableQuickCustomization (); // TODO: Define your own basic commands. Be sure, that each pulldown // menu have at least one basic command. 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); CClientDC dc (this); BOOL bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 8; UINT uiToolbarHotID = bIsHighColor ? IDB_MAINFRAME_HC : 0; if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME, 0, 0, FALSE, 0, 0, uiToolbarHotID)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } uiToolbarHotID = bIsHighColor ? IDB_GANTT_HC : 0; if (!m_wndGanttToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, CRect(1, 1, 1, 1), AFX_IDW_DIALOGBAR) || !m_wndGanttToolBar.LoadToolBar(IDR_GANTT, 0, 0, FALSE, 0, 0, uiToolbarHotID)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } CBCGPToolBar::AddToolBarForImageCollection (IDR_GANTT_DUMMY, bIsHighColor ? IDB_GANTT_DUMMY_HC : 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 } OnAppLook (m_nAppLook); CString strMainToolbarTitle; strMainToolbarTitle.LoadString (IDS_MAIN_TOOLBAR); m_wndToolBar.SetWindowText (strMainToolbarTitle); m_wndGanttToolBar.SetWindowText (_T("Gantt")); m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); m_wndGanttToolBar.EnableDocking(CBRS_ALIGN_ANY); //------------------------------------------------------------------ // Outlook bar will be created at left, so temporary disable docking // at the left side: //------------------------------------------------------------------ EnableDocking (CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM | CBRS_ALIGN_RIGHT); //---------------------------------------------------- // Outlook bar is created and docking on the left side // should be allowed. //---------------------------------------------------- EnableDocking (CBRS_ALIGN_LEFT); DockControlBar(&m_wndMenuBar); DockControlBar(&m_wndToolBar); DockControlBar(&m_wndGanttToolBar); DockControlBarLeftOf (&m_wndToolBar, &m_wndGanttToolBar); m_wndToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); m_wndGanttToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); return 0; }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; ModifyStyle (WS_CAPTION | FWS_ADDTOTITLE, 0); ModifyStyleEx (WS_EX_CLIENTEDGE, 0); CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMSMVisualManager)); //--------------------------------- // Set toolbar and menu image size: //--------------------------------- CMFCToolBarButton::m_bWrapText = FALSE; CMFCToolBar::SetMenuSizes (CSize (22, 22), CSize (16, 16)); CMFCToolBarComboBoxButton::SetFlatMode (); CMFCToolBarComboBoxButton::SetCenterVert (); if (!m_wndCaptionBar.Create(this, IDR_MAINFRAME)) { TRACE0("Failed to create captionbar\n"); return -1; } if (afxGlobalData.fontRegular.GetSafeHandle () != NULL) { LOGFONT lf; ZeroMemory (&lf, sizeof (LOGFONT)); afxGlobalData.fontRegular.GetLogFont (&lf); m_wndCaptionBar.SetCaptionFont (lf); } if (!m_wndMenuBar.Create (this, AFX_DEFAULT_TOOLBAR_STYLE)) { TRACE0("Failed to create menubar\n"); return -1; // fail to create } EnableDocking(CBRS_ALIGN_ANY); DockPane(&m_wndMenuBar); CClientDC dc (this); m_bIsHighColor = dc.GetDeviceCaps (BITSPIXEL) > 16; UINT uiToolbarHotID = m_bIsHighColor ? IDB_HOTTOOLBAR : 0; UINT uiToolbarColdID = m_bIsHighColor ? IDB_COLDTOOLBAR : 0; UINT uiToolbarDisID = m_bIsHighColor ? IDB_DISABLEDTOOLBAR : 0; UINT uiToolbarPresID = m_bIsHighColor ? IDB_PRESSEDTOOLBAR : 0; UINT uiMenuID = m_bIsHighColor ? IDB_MENU_IMAGES : IDB_MENU_IMAGES_16; if (!m_wndToolBar.CreateEx (this, TBSTYLE_FLAT, CBRS_SIZE_FIXED | AFX_DEFAULT_TOOLBAR_STYLE) || !m_wndToolBar.LoadToolBar (IDR_MAINFRAME, uiToolbarColdID, uiMenuID, FALSE /* Not locked */, uiToolbarDisID, 0, uiToolbarHotID, uiToolbarPresID)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } m_wndToolBar.InsertButton (CMFCToolBarComboBoxButton (ID_GO_ADDRESS_EDIT, 0), 3); DockPane (&m_wndToolBar); if (!m_wndCategoryBar.CreateEx (this, TBSTYLE_FLAT, CBRS_SIZE_FIXED | AFX_DEFAULT_TOOLBAR_STYLE, CRect (1, 1, 1, 1), AFX_IDW_TOOLBAR + 3)) { TRACE0("Failed to create categoriebar\n"); return -1; // fail to create } DockPane (&m_wndCategoryBar); for (long i = 0; i < 8; i++) { if (!m_wndLinksBars[i].CreateEx (this, TBSTYLE_FLAT, CBRS_SIZE_FIXED | AFX_DEFAULT_TOOLBAR_STYLE, CRect (1, 1, 1, 1), AFX_IDW_TOOLBAR + 4 + i)) { TRACE0("Failed to create linksbar\n"); return -1; // fail to create } DockPane (&m_wndLinksBars[i]); ShowPane (&m_wndLinksBars[i], FALSE, FALSE, FALSE); } m_wndLinksBars[0].InsertButton (CMSMLinksBarButton (_T("My Money"), ID_LINKS_HOME_1)); m_wndLinksBars[0].InsertButton (CMSMLinksBarButton (_T("MSN Money News"), ID_LINKS_HOME_2)); m_wndLinksBars[0].SetCurrentCommand (ID_LINKS_HOME_1); m_wndLinksBars[1].InsertButton (CMSMLinksBarButton (_T("Account List"), ID_LINKS_BANKING_1)); m_wndLinksBars[1].InsertButton (CMSMLinksBarButton (_T("Account Tools"), ID_LINKS_BANKING_2)); m_wndLinksBars[1].InsertButton (CMSMLinksBarButton (_T("Mortgages && Loans"), ID_LINKS_BANKING_3)); m_wndLinksBars[1].InsertButton (CMSMLinksBarButton (_T("Bank Services"), ID_LINKS_BANKING_4)); m_wndLinksBars[1].InsertButton (CMSMLinksBarButton (_T("Credit Center"), ID_LINKS_BANKING_5)); m_wndLinksBars[1].SetCurrentCommand (ID_LINKS_BANKING_1); m_wndLinksBars[2].InsertButton (CMSMLinksBarButton (_T("Bills Summary"), ID_LINKS_BILLS_1)); m_wndLinksBars[2].InsertButton (CMSMLinksBarButton (_T("Bill Calendar"), ID_LINKS_BILLS_2)); m_wndLinksBars[2].InsertButton (CMSMLinksBarButton (_T("Transfer Money"), ID_LINKS_BILLS_3)); m_wndLinksBars[2].InsertButton (CMSMLinksBarButton (_T("MSN Bill Pay Online"), ID_LINKS_BILLS_4)); m_wndLinksBars[2].InsertButton (CMSMLinksBarButton (_T("History"), ID_LINKS_BILLS_5)); m_wndLinksBars[2].SetCurrentCommand (ID_LINKS_BILLS_1); m_wndLinksBars[3].InsertButton (CMSMLinksBarButton (_T("Reports Home"), ID_LINKS_REPORTS_1)); m_wndLinksBars[3].InsertButton (CMSMLinksBarButton (_T("Favorite Reports"), ID_LINKS_REPORTS_2)); m_wndLinksBars[3].InsertButton (CMSMLinksBarButton (_T("Monthly Reports"), ID_LINKS_REPORTS_3)); m_wndLinksBars[3].SetCurrentCommand (ID_LINKS_REPORTS_1); m_wndLinksBars[4].InsertButton (CMSMLinksBarButton (_T("Budget Summary"), ID_LINKS_BUDGET_1)); m_wndLinksBars[4].InsertButton (CMSMLinksBarButton (_T("Budget vs. Spending"), ID_LINKS_BUDGET_2)); m_wndLinksBars[4].SetCurrentCommand (ID_LINKS_BUDGET_1); m_wndLinksBars[5].InsertButton (CMSMLinksBarButton (_T("Investing Home"), ID_LINKS_INVESTING_1)); m_wndLinksBars[5].InsertButton (CMSMLinksBarButton (_T("Investing Tools"), ID_LINKS_INVESTING_2)); m_wndLinksBars[5].InsertButton (CMSMLinksBarButton (_T("Market News"), ID_LINKS_INVESTING_3)); m_wndLinksBars[5].InsertButton (CMSMLinksBarButton (_T("Stocks"), ID_LINKS_INVESTING_4)); m_wndLinksBars[5].InsertButton (CMSMLinksBarButton (_T("Funds"), ID_LINKS_INVESTING_5)); m_wndLinksBars[5].InsertButton (CMSMLinksBarButton (_T("Insight"), ID_LINKS_INVESTING_6)); m_wndLinksBars[5].InsertButton (CMSMLinksBarButton (_T("Brokers"), ID_LINKS_INVESTING_7)); m_wndLinksBars[5].SetCurrentCommand (ID_LINKS_INVESTING_1); m_wndLinksBars[6].InsertButton (CMSMLinksBarButton (_T("Planning Home"), ID_LINKS_PLANNING_1)); m_wndLinksBars[6].InsertButton (CMSMLinksBarButton (_T("Planning Tools"), ID_LINKS_PLANNING_2)); m_wndLinksBars[6].InsertButton (CMSMLinksBarButton (_T("Retirement"), ID_LINKS_PLANNING_3)); m_wndLinksBars[6].InsertButton (CMSMLinksBarButton (_T("Savings"), ID_LINKS_PLANNING_4)); m_wndLinksBars[6].InsertButton (CMSMLinksBarButton (_T("Insurance"), ID_LINKS_PLANNING_5)); m_wndLinksBars[6].InsertButton (CMSMLinksBarButton (_T("Family && College"), ID_LINKS_PLANNING_6)); m_wndLinksBars[6].SetCurrentCommand (ID_LINKS_PLANNING_1); m_wndLinksBars[7].InsertButton (CMSMLinksBarButton (_T("Taxes Home"), ID_LINKS_TAXES_1)); m_wndLinksBars[7].InsertButton (CMSMLinksBarButton (_T("Tax Tools"), ID_LINKS_TAXES_2)); m_wndLinksBars[7].InsertButton (CMSMLinksBarButton (_T("Prepare Online"), ID_LINKS_TAXES_3)); m_wndLinksBars[7].InsertButton (CMSMLinksBarButton (_T("Planning"), ID_LINKS_TAXES_4)); m_wndLinksBars[7].InsertButton (CMSMLinksBarButton (_T("Products && Services"), ID_LINKS_TAXES_5)); m_wndLinksBars[7].SetCurrentCommand (ID_LINKS_TAXES_1); //----------------------- // Set up Favorites menu: //----------------------- int nCategorie = theApp.GetProfileInt (_T(""), _T("Categorie"), 0); OnCategorie (ID_CATEGORIE_1 + nCategorie); m_wndTaskPane.Create (_T(""), this, CRect (0, 0, 140, 200), FALSE, IDR_MAINFRAME + 1, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT, 0, 0); DockPane(&m_wndTaskPane); return 0; }
void CDIPDemoDoc::Init() { // 初始化 // 如果图像无效,直接返回 if ( !m_Image.IsValidate() ) { return; } // 设置文档大小 m_sizeDoc = CSize ( m_Image.GetWidthPixel(), m_Image.GetHeight() ); // 判断调色板是否为空 if ( m_pPalette != NULL ) { // 删除调色板对象 delete m_pPalette; // 重置调色板为空 m_pPalette = NULL; } //不是调色板显示模式,则直接返回 CClientDC dc ( NULL ); if ( ( dc.GetDeviceCaps ( RASTERCAPS ) & RC_PALETTE ) == 0 ) { return; } // 创建新调色板 m_pPalette = new CPalette; int nEntries = m_Image.GetColorTableEntriesNum(); if ( nEntries == 0 ) { return; } LOGPALETTE* lpPal = ( LOGPALETTE* ) new BYTE[sizeof ( LOGPALETTE ) + ( sizeof ( PALETTEENTRY ) * ( nEntries - 1 ) )]; // 设置版本号 lpPal->palVersion = 0x300; // 设置颜色数目 lpPal->palNumEntries = ( WORD ) nEntries; RGBQUAD* pPal = ( RGBQUAD* ) ( m_Image.GetColorTable() ); int i; // 创建调色板 for ( i = 0; i < nEntries; i++ ) { // 读取红色分量 lpPal->palPalEntry[i].peRed = pPal[i].rgbRed; // 读取绿色分量 lpPal->palPalEntry[i].peGreen = pPal[i].rgbGreen; // 读取蓝色分量 lpPal->palPalEntry[i].peBlue = pPal[i].rgbBlue; // 保留位 lpPal->palPalEntry[i].peFlags = 0; } // 按照逻辑调色板创建调色板,并返回指针 m_pPalette->CreatePalette ( lpPal ); delete[] lpPal; }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { TRACE("CMainFrame::OnCreate"); if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; OnAppLook (m_nAppLook); CMFCToolBar::EnableQuickCustomization (); UpdateMDITabs (FALSE); if (!m_wndMenuBar.Create (this)) { TRACE0("Failed to create menubar\n"); return -1; // fail to create } m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC); // Prevent the menu bar from taking the focus on activation CMFCPopupMenu::SetForceMenuFocus(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_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME, 0, 0, FALSE, 0, 0, uiToolbarHotID)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } if (!m_wndToolBarTheme.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, ID_VIEW_THEME_TOOLBAR) || !m_wndToolBarTheme.LoadToolBar (IDR_THEME, 0, 0, TRUE /* Locked */)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } 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 } CImageList imagesWorkspace; imagesWorkspace.Create (IDB_WORKSPACE, 16, 0, RGB (255, 0, 255)); if (!m_wndWorkSpace.Create (_T("MDI Tabs Options"), this, CRect (0, 0, 300, 300), TRUE, ID_VIEW_WORKSPACE, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI)) { TRACE0("Failed to create Workspace bar\n"); return FALSE; // fail to create } m_wndWorkSpace.SetIcon (imagesWorkspace.ExtractIcon (0), FALSE); if (!m_wndWorkSpace2.Create (_T("My Second Tab Options"), this, CRect (0, 0, 300, 300), TRUE, ID_VIEW_WORKSPACE2, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT | CBRS_FLOAT_MULTI)) { TRACE0("Failed to create Workspace bar\n"); return FALSE; // fail to create } m_wndWorkSpace2.SetIcon (imagesWorkspace.ExtractIcon (0), FALSE); m_wndToolBar.SetWindowText (_T("Standard")); m_wndToolBarTheme.SetWindowText (_T("Visual Style")); // TODO: Delete these three lines if you don't want the toolbar to // be dockable m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); m_wndToolBarTheme.EnableDocking(CBRS_ALIGN_ANY); m_wndWorkSpace.EnableDocking(CBRS_ALIGN_ANY); m_wndWorkSpace2.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); EnableAutoHidePanes(CBRS_ALIGN_ANY); DockPane(&m_wndMenuBar); DockPane(&m_wndToolBar); DockPane(&m_wndToolBarTheme); DockPane (&m_wndWorkSpace); DockPane (&m_wndWorkSpace2); m_wndToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); m_wndToolBarTheme.EnableCustomizeButton (TRUE, -1, _T("")); // Enable windows manager: EnableWindowsDialog (ID_WINDOW_MANAGER, IDS_WINDOWS_MANAGER, TRUE); return 0; }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CBCGPMDIFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; if (CBCGPToolBar::GetUserImages () == NULL) { // Load toolbar user images: if (!m_UserImages.Load (_T(".\\UserImages.bmp"))) { TRACE(_T("Failed to load user images\n")); } else { CBCGPToolBar::SetUserImages (&m_UserImages); } } CBCGPToolBar::EnableQuickCustomization (); // TODO: Define your own basic commands. Be sure, that each pulldown // menu have at least one basic command. CList<UINT, UINT> lstBasicCommands; // lstBasicCommands.AddTail (ID_VIEW_TOOLBARS); // 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_CUT); // lstBasicCommands.AddTail (ID_EDIT_PASTE); // lstBasicCommands.AddTail (ID_EDIT_UNDO); // lstBasicCommands.AddTail (ID_RECORD_NEXT); // lstBasicCommands.AddTail (ID_RECORD_LAST); lstBasicCommands.AddTail (ID_APP_ABOUT); lstBasicCommands.AddTail (ID_VIEW_TOOLBAR); lstBasicCommands.AddTail (ID_VIEW_CUSTOMIZE); lstBasicCommands.AddTail (ID_WINDOW_TILE_HORZ); // lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2000); // lstBasicCommands.AddTail (ID_VIEW_APPLOOK_XP); // lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2003); // lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007); // lstBasicCommands.AddTail (ID_VIEW_APPLOOK_VS2005); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_WIN_XP); // lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_1); // lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_2); // lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_3); // lstBasicCommands.AddTail (ID_VIEW_APPLOOK_VS2008); CBCGPToolBar::SetBasicCommands (lstBasicCommands); 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); // 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 ; // if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP // | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || // !m_wndToolBar.LoadToolBar(IDR_MAINFRAME_256, 0, 0, FALSE, 0, 0, uiToolbarHotID)) // { // TRACE0("Failed to create toolbar\n"); // return -1; // fail to create // } if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME)) { TRACE0("未能创建工具栏\n"); return -1; // 未能创建 } CString strToolBarName; BOOL bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD); ASSERT(bNameValid); m_wndToolBar.SetWindowText(strToolBarName); 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 } // Load control bar icons: CBCGPToolBarImages imagesWorkspace; imagesWorkspace.SetImageSize (CSize (16, 16)); imagesWorkspace.SetTransparentColor (RGB (255, 0, 255)); imagesWorkspace.Load (IDB_WORKSPACE); if (!m_wndWorkSpace.Create (_T("方案管理器"), this, CRect (0, 0, 200, 200), TRUE, ID_VIEW_WORKSPACE, 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_wndWorkSpace.SetIcon (imagesWorkspace.ExtractIcon (0), FALSE); if (!m_wndOutput.Create (_T("输出"), this, CSize (150, 150), TRUE /* Has gripper */, ID_VIEW_OUTPUT, WS_CHILD | WS_VISIBLE | CBRS_BOTTOM)) { TRACE0("Failed to create output bar\n"); return -1; // fail to create } CString strMainToolbarTitle; strMainToolbarTitle.LoadString (IDS_MAIN_TOOLBAR); m_wndToolBar.SetWindowText (strMainToolbarTitle); // TODO: Delete these three lines if you don't want the toolbar to be dockable m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); m_wndWorkSpace.EnableDocking(CBRS_ALIGN_ANY); m_wndOutput.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); EnableAutoHideBars(CBRS_ALIGN_ANY); DockControlBar(&m_wndMenuBar); DockControlBar(&m_wndToolBar); DockControlBar(&m_wndWorkSpace); DockControlBar(&m_wndOutput); m_wndToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("自定义...")); // Allow user-defined toolbars operations: InitUserToobars (NULL, uiFirstUserToolBarId, uiLastUserToolBarId); // Enable windows manager: EnableWindowsDialog (ID_WINDOW_MANAGER, IDS_WINDOWS_MANAGER, TRUE); // Enable control bar context menu (list of bars + customize command): EnableControlBarMenu ( TRUE, // Enable ID_VIEW_CUSTOMIZE, // Customize command ID _T("自定义..."), // Customize command text ID_VIEW_TOOLBAR); // Menu items with this ID will be replaced by // toolbars menu OnApplicationLook (theApp.m_nAppLook); #if 0 BOOL bNameValid; // 基于持久值设置视觉管理器和样式 OnApplicationLook(theApp.m_nAppLook); CMDITabInfo mdiTabParams; mdiTabParams.m_style = CMFCTabCtrl::STYLE_3D_ONENOTE; // 其他可用样式... mdiTabParams.m_bActiveTabCloseButton = TRUE; // 设置为 FALSE 会将关闭按钮放置在选项卡区域的右侧 mdiTabParams.m_bTabIcons = FALSE; // 设置为 TRUE 将在 MDI 选项卡上启用文档图标 mdiTabParams.m_bAutoColor = TRUE; // 设置为 FALSE 将禁用 MDI 选项卡的自动着色 mdiTabParams.m_bDocumentMenu = TRUE; // 在选项卡区域的右边缘启用文档菜单 EnableMDITabbedGroups(TRUE, mdiTabParams); if (!m_wndMenuBar.Create(this)) { TRACE0("未能创建菜单栏\n"); return -1; // 未能创建 } m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY); // 防止菜单栏在激活时获得焦点 CMFCPopupMenu::SetForceMenuFocus(FALSE); if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME)) { TRACE0("未能创建工具栏\n"); return -1; // 未能创建 } CString strToolBarName; bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD); ASSERT(bNameValid); m_wndToolBar.SetWindowText(strToolBarName); CString strCustomize; bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE); ASSERT(bNameValid); m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize); // 允许用户定义的工具栏操作: InitUserToolbars(NULL, uiFirstUserToolBarId, uiLastUserToolBarId); if (!m_wndStatusBar.Create(this)) { TRACE0("未能创建状态栏\n"); return -1; // 未能创建 } m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)); // TODO: 如果您不希望工具栏和菜单栏可停靠,请删除这五行 m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockPane(&m_wndMenuBar); DockPane(&m_wndToolBar); // 启用 Visual Studio 2005 样式停靠窗口行为 CDockingManager::SetDockingMode(DT_SMART); // 启用 Visual Studio 2005 样式停靠窗口自动隐藏行为 EnableAutoHidePanes(CBRS_ALIGN_ANY); // 加载菜单项图像(不在任何标准工具栏上): CBCGPToolBar::AddToolBarForImageCollection(IDR_MENU_IMAGES, theApp.m_bHiColorIcons ? IDB_MENU_IMAGES_24 : 0); // 创建停靠窗口 if (!CreateDockingWindows()) { TRACE0("未能创建停靠窗口\n"); return -1; } m_wndFileView.EnableDocking(CBRS_ALIGN_ANY); m_wndClassView.EnableDocking(CBRS_ALIGN_ANY); DockPane(&m_wndFileView); CBCGPDockingControlBar* pTabbedBar = NULL; m_wndClassView.AttachToTabWnd(&m_wndFileView, DM_SHOW, TRUE, &pTabbedBar); m_wndOutput.EnableDocking(CBRS_ALIGN_ANY); DockPane(&m_wndOutput); // 启用增强的窗口管理对话框 EnableWindowsDialog(ID_WINDOW_MANAGER, IDS_WINDOWS_MANAGER, TRUE); // 启用工具栏和停靠窗口菜单替换 EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR); // 启用快速(按住 Alt 拖动)工具栏自定义 CBCGPToolBar::EnableQuickCustomization(); if (CBCGPToolBar::GetUserImages() == NULL) { // 加载用户定义的工具栏图像 if (m_UserImages.Load(_T(".\\UserImages.bmp"))) { m_UserImages.SetImageSize(CSize(16, 16), FALSE); CBCGPToolBar::SetUserImages(&m_UserImages); } } // 启用菜单个性化(最近使用的命令) // TODO: 定义您自己的基本命令,确保每个下拉菜单至少有一个基本命令。 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_CUT); lstBasicCommands.AddTail(ID_EDIT_PASTE); lstBasicCommands.AddTail(ID_EDIT_UNDO); lstBasicCommands.AddTail(ID_APP_ABOUT); lstBasicCommands.AddTail(ID_VIEW_STATUS_BAR); lstBasicCommands.AddTail(ID_VIEW_TOOLBAR); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2003); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_VS_2005); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLUE); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_SILVER); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_BLACK); lstBasicCommands.AddTail(ID_VIEW_APPLOOK_OFF_2007_AQUA); lstBasicCommands.AddTail(ID_SORTING_SORTALPHABETIC); lstBasicCommands.AddTail(ID_SORTING_SORTBYTYPE); lstBasicCommands.AddTail(ID_SORTING_SORTBYACCESS); lstBasicCommands.AddTail(ID_SORTING_GROUPBYTYPE); CBCGPToolBar::SetBasicCommands(lstBasicCommands); #endif return 0; }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; OnAppLook (m_nAppLook); CMFCToolBar::EnableQuickCustomization (); // TODO: Define your own basic commands. Be sure, that each pulldown // menu have at least one basic command. CList<UINT, UINT> lstBasicCommands; lstBasicCommands.AddTail (ID_VIEW_TOOLBARS); 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_CUT); lstBasicCommands.AddTail (ID_EDIT_PASTE); lstBasicCommands.AddTail (ID_EDIT_UNDO); lstBasicCommands.AddTail (ID_APP_ABOUT); lstBasicCommands.AddTail (ID_VIEW_TOOLBAR); lstBasicCommands.AddTail (ID_VIEW_CUSTOMIZE); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2000); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_XP); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2003); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_VS2005); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_WIN_XP); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_1); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_2); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_3); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_4); CMFCToolBar::SetBasicCommands (lstBasicCommands); if (!m_wndMenuBar.Create (this)) { TRACE0("Failed to create menubar\n"); return -1; // fail to create } m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC); // 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_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME, 0, 0, FALSE, 0, 0, uiToolbarHotID)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } 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 } m_wndToolBar.SetWindowText (_T("Standard")); // TODO: Delete these three lines if you don't want the toolbar to // be dockable m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); //------------------------------------------------------------------ // Outlook bar will be created at left, so temporary disable docking // at the left side: //------------------------------------------------------------------ EnableDocking (CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM | CBRS_ALIGN_RIGHT); if (!CreateShortcutsBar ()) { TRACE0("Failed to create shortcuts bar\n"); return -1; // fail to create } //---------------------------------------------------- // Outlook bar is created and docking on the left side // should be allowed. //---------------------------------------------------- EnableDocking (CBRS_ALIGN_LEFT); if (!m_wndCaptionBar.Create (WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS, this, ID_VIEW_CAPTIONBAR, -1)) { TRACE0("Failed to create caption bar\n"); return -1; // fail to create } m_wndCaptionBar.SetFlatBorder (); m_wndCaptionBar.SetText (_T("View 1")); m_bmpCaption.LoadBitmap (IDB_CAPTION); m_wndCaptionBar.SetBitmap (m_bmpCaption, RGB (255, 0, 255)); DockPane(&m_wndMenuBar); DockPane(&m_wndToolBar); m_wndToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); return 0; }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; OnAppLook (m_nAppLook); CMFCToolBar::EnableQuickCustomization (); // TODO: Define your own basic commands. Be sure, that each pulldown // menu have at least one basic command. CList<UINT, UINT> lstBasicCommands; lstBasicCommands.AddTail (ID_VIEW_TOOLBARS); 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_CUT); lstBasicCommands.AddTail (ID_EDIT_PASTE); lstBasicCommands.AddTail (ID_EDIT_UNDO); lstBasicCommands.AddTail (ID_APP_ABOUT); lstBasicCommands.AddTail (ID_VIEW_TOOLBAR); lstBasicCommands.AddTail (ID_VIEW_CUSTOMIZE); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2000); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_XP); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2003); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_VS2005); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_WIN_XP); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_1); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_2); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_3); lstBasicCommands.AddTail (ID_VIEW_APPLOOK_2007_4); CMFCToolBar::SetBasicCommands (lstBasicCommands); if (!m_wndMenuBar.Create (this)) { TRACE0("Failed to create menubar\n"); return -1; // fail to create } m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC); // 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_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME, 0, 0, FALSE, 0, 0, uiToolbarHotID)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } if (!m_wndToolBarTheme.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, ID_VIEW_THEME_TOOLBAR) || !m_wndToolBarTheme.LoadToolBar (IDR_THEME, 0, 0, TRUE /* Locked */)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } 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 } m_wndToolBar.SetWindowText (_T("Standard")); m_wndToolBarTheme.SetWindowText (_T("Visual Style")); // TODO: Delete these three lines if you don't want the toolbar to // be dockable m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); m_wndToolBarTheme.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockPane(&m_wndMenuBar); DockPane(&m_wndToolBar); DockPane(&m_wndToolBarTheme); m_wndToolBar.EnableCustomizeButton (TRUE, ID_VIEW_CUSTOMIZE, _T("Customize...")); m_wndToolBarTheme.EnableCustomizeButton (TRUE, -1, _T(""), FALSE); return 0; }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; // enable Windows XP look: CMFCVisualManager::SetDefaultManager (RUNTIME_CLASS (CMFCVisualManagerWindows)); CMFCToolBar::EnableQuickCustomization (); //--------------------------------- // Set toolbar and menu image size: //--------------------------------- CMFCToolBar::SetSizes (CSize (28, 28), CSize (22, 22)); CMFCToolBar::SetMenuSizes (CSize (22, 22), CSize (16, 16)); // TODO: Define your own basic commands. Be sure, that each pulldown // menu have at least one basic command. CList<UINT, UINT> lstBasicCommands; lstBasicCommands.AddTail (ID_VIEW_TOOLBARS); lstBasicCommands.AddTail (ID_APP_EXIT); lstBasicCommands.AddTail (ID_APP_ABOUT); lstBasicCommands.AddTail (ID_VIEW_TOOLBAR); lstBasicCommands.AddTail (ID_VIEW_CUSTOMIZE); lstBasicCommands.AddTail (ID_COMMAND_HISTORY); lstBasicCommands.AddTail (ID_VIEW_LARGEICON); lstBasicCommands.AddTail (ID_VIEW_SMALLICON); lstBasicCommands.AddTail (ID_VIEW_LIST); lstBasicCommands.AddTail (ID_VIEW_DETAILS); lstBasicCommands.AddTail (ID_EDIT_CUT); lstBasicCommands.AddTail (ID_EDIT_COPY); lstBasicCommands.AddTail (ID_EDIT_PASTE); CMFCToolBar::SetBasicCommands (lstBasicCommands); if (!m_wndMenuBar.Create (this)) { TRACE0("Failed to create menubar\n"); return -1; // fail to create } m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC); // Remove menubar gripper and borders: m_wndMenuBar.SetPaneStyle (m_wndMenuBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); // 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; UINT uiToolbarColdID = bIsHighColor ? IDB_TOOLBARCOLD256 : 0; UINT uiMenuID = bIsHighColor ? IDB_MENU256 : IDB_MENU16; if (!m_wndToolBar.CreateEx(this) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME, uiToolbarColdID, uiMenuID, FALSE, 0, 0, uiToolbarHotID)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } // Remove toolbar gripper and borders: m_wndToolBar.SetPaneStyle (m_wndToolBar.GetPaneStyle() & ~(CBRS_GRIPPER | CBRS_BORDER_TOP | CBRS_BORDER_BOTTOM | CBRS_BORDER_LEFT | CBRS_BORDER_RIGHT)); //---------------------------------------- // Create a combo box for the address bar: //---------------------------------------- if (!m_wndAddress.Create (CBS_DROPDOWN | WS_CHILD, CRect(0, 0, 200, 120), this, AFX_IDW_TOOLBAR + 1)) { TRACE0("Failed to create combobox\n"); return -1; // fail to create } // Each rebar pane will ocupy its own row: DWORD dwStyle = RBBS_GRIPPERALWAYS | RBBS_FIXEDBMP | RBBS_BREAK; if (!m_wndReBar.Create(this) || !m_wndReBar.AddBar (&m_wndMenuBar) || !m_wndReBar.AddBar (&m_wndToolBar, NULL, NULL, dwStyle) || !m_wndReBar.AddBar(&m_wndAddress, _T("Address"), NULL, dwStyle)) { TRACE0("Failed to create rebar\n"); return -1; // fail to create } m_wndMenuBar.AdjustLayout (); m_wndToolBar.AdjustLayout (); //-------------------------------------------------------------- // Set up min/max sizes and ideal sizes for pieces of the rebar: //-------------------------------------------------------------- REBARBANDINFO rbbi; CRect rectToolBar; m_wndToolBar.GetItemRect(0, &rectToolBar); rbbi.cbSize = sizeof(rbbi); rbbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE | RBBIM_SIZE; rbbi.cxMinChild = rectToolBar.Width(); rbbi.cyMinChild = rectToolBar.Height(); rbbi.cx = rbbi.cxIdeal = rectToolBar.Width() * m_wndToolBar.GetCount (); m_wndReBar.GetReBarCtrl().SetBandInfo (1, &rbbi); rbbi.cxMinChild = 0; CRect rectAddress; m_wndAddress.GetEditCtrl()->GetWindowRect(&rectAddress); rbbi.fMask = RBBIM_CHILDSIZE | RBBIM_IDEALSIZE; rbbi.cyMinChild = rectAddress.Height() + 10; rbbi.cxIdeal = 200; m_wndReBar.GetReBarCtrl().SetBandInfo (3, &rbbi); // TODO: Remove this if you don't want chevrons: m_wndMenuBar.EnableCustomizeButton (TRUE, (UINT)-1, _T("")); m_wndToolBar.EnableCustomizeButton (TRUE, (UINT)-1, _T("")); 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 } if (!m_wndFoldersBar.Create (_T("Folders"), this, CRect (0, 0, 200, 200), TRUE, ID_VIEW_FOLDERS, WS_CHILD | WS_VISIBLE | CBRS_LEFT | CBRS_HIDE_INPLACE | WS_CAPTION)) { TRACE0("Failed to create folders bar\n"); return -1; // fail to create } EnableDocking (CBRS_ALIGN_ANY); m_wndReBar.EnableDocking (CBRS_TOP); DockPane (&m_wndReBar); m_wndFoldersBar.EnableDocking (CBRS_LEFT | CBRS_RIGHT); DockPane (&m_wndFoldersBar); CString strMainToolbarTitle; strMainToolbarTitle.LoadString (IDS_MAIN_TOOLBAR); m_wndToolBar.SetWindowText (strMainToolbarTitle); // TODO: Remove this if you don't want tool tips m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); m_wndToolBar.SetPaneStyle(m_wndToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY); return 0; }