////////////////// // Load array of toolbar IDs. // BOOL CCoolMenuManager::LoadToolbars(const UINT* arID, int n) { ASSERT(arID); BOOL bRet = TRUE; for (int i=0; i<n; i++) bRet |= LoadToolbar(arID[i]); return bRet; }
////////////////// // Refresh all colors, fonts, etc. For WM_SETTINGCHANGE, WM_SYSCOLORCHANGE. // void CCoolMenuManager::Refresh() { // first copy list (array) of toolbar IDs now loaded. CUIntArray arToolbarID; arToolbarID.Copy(m_arToolbarID); // destroy everything Destroy(); // re-load toolbars. int nToolbars = arToolbarID.GetSize(); for (int i = 0; i < nToolbars; i++) LoadToolbar(arToolbarID[i]); }
void CMainFrame::OnCreate(WPARAM wParam, LPARAM lParam) { // Create MDI client window CLIENTCREATESTRUCT ccs; ccs.hWindowMenu = GetSubMenu(GetMenu(m_hWnd), 5); ccs.idFirstChild = 3; m_hClient = CreateWindow("MDICLIENT", NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VSCROLL | WS_HSCROLL, 0, 0, 0, 0, m_hWnd, (HMENU)IDR_CLIENT, NULL, &ccs); // Create status bar m_hStatus = CreateStatusWindow(WS_VISIBLE | WS_CHILD | SBARS_SIZEGRIP, "Stopped", m_hWnd, IDR_STATUS); // Create rebar m_hRebar = CreateWindowEx(WS_EX_TOOLWINDOW, REBARCLASSNAME, NULL, WS_CHILD | WS_VISIBLE |WS_BORDER| WS_CLIPSIBLINGS | WS_CLIPCHILDREN | RBS_VARHEIGHT | CCS_NODIVIDER | RBS_AUTOSIZE | RBS_VARHEIGHT | RBS_BANDBORDERS, 0, 0, 0, 0, m_hWnd, (HMENU)IDR_REBAR, NULL, NULL); // Initialize rebar REBARINFO rbi; rbi.cbSize = sizeof(REBARINFO); ZeroMemory(&rbi, sizeof(REBARINFO)); SendMessage(m_hRebar, RB_SETBARINFO, 0, (LPARAM)&rbi); // Load toolbar from resource m_hToolbar = LoadToolbar(NULL, TBSTYLE_FLAT | TBSTYLE_WRAPABLE | CCS_NODIVIDER |CCS_NOPARENTALIGN | CCS_NORESIZE , IDR_TOOLBAR, m_hRebar); // Insert toolbar into rebar SIZE size; REBARBANDINFO rbbi; SendMessage(m_hToolbar, TB_GETMAXSIZE, 0, (LPARAM)&size); ZeroMemory(&rbbi, sizeof(REBARBANDINFO)); rbbi.cbSize = sizeof(REBARBANDINFO); rbbi.fMask = RBBIM_CHILD| RBBIM_CHILDSIZE | RBBIM_STYLE; rbbi.fStyle = RBBS_GRIPPERALWAYS; rbbi.hwndChild = m_hToolbar; rbbi.cxMinChild = size.cx; rbbi.cyMinChild = size.cy; SendMessage(m_hRebar, RB_INSERTBAND, (WPARAM)-1, (LPARAM)&rbbi); // TODO: Load and set window icon m_hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_APP)); SendMessage(m_hWnd, WM_SETICON, ICON_SMALL, (LPARAM)m_hIcon); SendMessage(m_hWnd, WM_SETICON, ICON_BIG, (LPARAM)m_hIcon); // Open command argument file if exists and valid if (__argc == 2) { // Create default model window m_pMainWnd = new CModelView(this, new CModelDoc); // Assign file name m_sFileName = __argv[1]; // Open target file fstream file; file.open(__argv[1], ios::in|ios::binary); // Load data from file if (m_pMainWnd->m_pDocument->Load(&file) == FALSE) { // If error, clean file name m_sFileName.clear(); // Create the window m_pMainWnd->Create("Root Document", m_hClient); // Release error data m_pMainWnd->OnDestroy(0, 0); m_pMainWnd = NULL; } else { // Create the window m_pMainWnd->Create("Root Document", m_hClient); // Compile blocks m_pMainWnd->m_pDocument->Compile(); // Update document m_pMainWnd->m_pDocument->Update(); m_pMainWnd->m_pDocument->Check(); // Update window InvalidateRect(m_pMainWnd->m_hWnd, NULL, TRUE); } // End of file operating file.close(); } }