int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; InitMenu(IDR_MAINFRAME); InitToolBar(IDR_MAINFRAME); InitStatusBar(indicators,sizeof(indicators)/sizeof(UINT)); // TODO: Delete these three lines if you don't want the toolbar to // be dockable m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY); m_wndMenuBar.SetSaveHistory("MyHistory1",TRUE); m_wndMenuBar.CreateCombo(&m_combMenu,IDC_COMBOMENU,150); DockControlBar(&m_wndMenuBar,m_dockTop); DockControlBar(&m_wndToolBar,m_dockTop); m_wndStatusBar.SetStyle(CGuiStatusBar::OFFICE); DockControlBar(&m_wndToolBar); sProfile = _T("GuiTabbedDemo"); LoadBars(); InitMDITabbed(); m_MdiTabbed.SetTabsMenu(IDR_MENUTABS); SetTimer(1,150,0); return 0; }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { int cButtons; CRect rect; CDockState dockState; CImageList imageList; CBitmap bitmap; CDC *tempDC; m_iTimer = 0; // initialize with scene paused m_bScenePaused = true; PauseScene( true ); if (CGuiMDIFrame::OnCreate(lpCreateStruct) == -1) return -1; if (!m_wndProgStatusBar.Create(this) || !m_wndProgStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create progress status bar\n"); return -1; // fail to create } m_wndMenuBar.CreateEx(this, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_SIZE_DYNAMIC ); m_wndMenuBar.LoadMenuBar(IDR_MAINFRAME); m_NewMenu.SetMenuDrawMode(CNewMenu::STYLE_XP); m_NewMenu.LoadMenu(IDR_MAINFRAME); m_OptDialog = new COptionsDialog(); 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_LARGE)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } if (!m_TabbedToolBar.Create(this)) { TRACE0("Failed to create tabbed toolbar\n"); return -1; // fail to create } m_TabbedToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); CToolBarCtrl& tbCtrl = m_wndToolBar.GetToolBarCtrl(); // get the main screen's handle tempDC = GetDesktopWindow()->GetDC(); int nPlanes; int bpp; bpp = tempDC->GetDeviceCaps(BITSPIXEL); nPlanes = tempDC->GetDeviceCaps(PLANES); GetDesktopWindow()->ReleaseDC(tempDC); BOOL isHiColor; isHiColor = (bpp*nPlanes) > 8; int nCount = tbCtrl.GetImageList()->GetImageCount(); if (isHiColor) { IMAGEINFO ii; tbCtrl.GetImageList()->GetImageInfo(0, &ii); int cx = ii.rcImage.right - ii.rcImage.left; int cy = ii.rcImage.bottom - ii.rcImage.top; bitmap.LoadBitmap(IDB_TOOLBAR_LARGE); imageList.Create(cx, cy, ILC_COLORDDB|ILC_MASK, nCount, 0); imageList.Add(&bitmap, RGB(192,192,192)); // attach the image lists to the toolbar control tbCtrl.SetImageList (&imageList); imageList.Detach(); bitmap.Detach(); // now the disabled one bitmap.LoadBitmap(IDB_TOOLBAR_LARGE_DISABLED); imageList.Create(cx, cy, ILC_COLORDDB|ILC_MASK, nCount, 0); imageList.Add(&bitmap, RGB(192,192,192)); // attach the image lists to the toolbar control tbCtrl.SetDisabledImageList(&imageList); imageList.Detach(); bitmap.Detach(); } cButtons = sizeof(standardBarLabels) / sizeof(standardBarLabels[0]); for( int nButton = 0; nButton < cButtons; nButton++ ) { int nButtonIndex = m_wndToolBar.CommandToIndex( standardBarLabels[nButton].id ); if (!m_wndToolBar.SetButtonText( nButtonIndex, standardBarLabels[nButton].label )) TRACE("failed SetButtonText(%d, \"%s\").\n", nButtonIndex, standardBarLabels[nButton].label); } m_wndToolBar.SetWindowText(_T("Menu Toolbar")); // Get the first button size after adding the labels. // resize rectangle buttons to fit text m_wndToolBar.GetItemRect(0, rect); m_wndToolBar.SetSizes(rect.Size(), CSize(24, 24)); m_TabbedToolBar.AddBar(&m_wndToolBar, _T("Main")); DockControlBar(&m_TabbedToolBar); bitmap.LoadBitmap(IDB_TOOLBAR); imageList.Create(16, 15, ILC_COLORDDB|ILC_MASK, nCount, 0); imageList.Add(&bitmap, RGB(192,192,192)); m_wndCool.Install(this); // we want a hicolor bitmap for our menus CBitmap frameBMP; frameBMP.LoadBitmap(IDB_TOOLBAR); m_wndCool.LoadToolbar(IDR_MAINFRAME, &frameBMP); // m_NewMenu.LoadToolBar(tbCtrl, &imageList); // reset menu as plugins could have changed it. // SetMenu(m_hMenuDefault); m_GeneralOptPage = new CGeneralOptions; m_OptDialog->AddPage( m_GeneralOptPage ); // modeless options dialog, not visible if (!m_OptDialog->Create(this, WS_POPUP | WS_CAPTION | WS_SYSMENU)) { // no pages causes creation to fail delete m_OptDialog; m_OptDialog = NULL; } // preload menu and accelerators m_hMainMenu = LoadMenu(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME)); m_hMainAccel = LoadAccelerators(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME)); // this is bogus and should be at the top, but then tabs are above docked // elements. InitMDITabbed(); m_MdiTabbed.SetTabsMenu(IDR_MENUTABS); m_MdiTabbed.SetTabMenu(0,0); // send out message that main window has been created. static DWORD msgHash_WindowsMainCreate = CHashString(_T("WindowsMainCreate")).GetUniqueID(); theApp.GetToolBox()->SendMessage(msgHash_WindowsMainCreate, sizeof(CMDIFrameWnd *), this); m_wndMenuBar.StyleDispl(GUISTYLE_XP); m_NewMenu.StyleDispl(GUISTYLE_XP); m_wndToolBar.StyleDispl(GUISTYLE_XP); StyleDispl(GUISTYLE_XP); //// resource bar if (!m_ResourceBar.Create(_T("Resource"), WS_CHILD | WS_VISIBLE, this, IDD_OBJECTPANE)) { TRACE0("Failed to create resource dialog bar\n"); return -1; } CRect clientRect; GetClientRect(&clientRect); clientRect.top = 0; clientRect.bottom = 256; m_ResourceBar.MoveWindow(&clientRect); m_ResourceBar.SetBarStyle(m_ResourceBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); m_ResourceBar.EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_ResourceBar, AFX_IDW_DOCKBAR_BOTTOM); //// end resource bar return 0; }