void CXTPCustomizeToolbarsPage::OnChkChange() { int nIndex = m_checkList.GetCurSel(); if (nIndex == LB_ERR) return; CXTPCommandBars* pCommandBars = m_pSheet->GetCommandBars(); int i = (int)m_checkList.GetItemData(nIndex); if (i >= 0 && i < pCommandBars->GetCount()) { CXTPToolBar* pToolBar = pCommandBars->GetAt(i); if (!pToolBar->IsCloseable()) { m_checkList.SetCheck(nIndex, 1); MessageBeep(0); } else { BOOL bVisible = m_checkList.GetCheck(nIndex); pToolBar->SetVisible(bVisible); } } RefreshToolbarsList(); }
void CXTPControlCustom::DoPropExchange(CXTPPropExchange* pPX) { CXTPControlButton::DoPropExchange(pPX); PX_Rect(pPX, _T("Borders"), m_rcBorders, CRect(0, 0, 0, 0)); PX_Size(pPX, _T("ControlSize"), m_szControl, CSize(0, 0)); PX_Enum(pPX, _T("VerticalOptions"), m_verticalOptions, xtpVerticalHide); if (pPX->GetSchema() > _XTP_SCHEMA_861) { PX_Int(pPX, _T("ControlId"), m_nControlID, 0); } if (pPX->IsLoading() && m_nControlID != 0) { CXTPCommandBars* pCommandBars = ((XTP_COMMANDBARS_PROPEXCHANGE_PARAM*)pPX->m_dwData)->pCommandBars; ASSERT(pCommandBars->IsKindOf(RUNTIME_CLASS(CXTPCommandBars))); ASSERT(pCommandBars && pCommandBars->GetSite()); CWnd* pWnd = FindChildWindow(pCommandBars, m_nControlID); if (pWnd) { m_hwndControl = pWnd->GetSafeHwnd(); } } }
void CXTPCustomizeToolbarsPage::OnResetToolbar() { int nIndex = m_checkList.GetCurSel(); if (nIndex == LB_ERR) return; CXTPCommandBars* pCommandBars = m_pSheet->GetCommandBars(); int i = (int)m_checkList.GetItemData(nIndex); if (i < 0 || i >= pCommandBars->GetCount()) return; CXTPToolBar* pToolBar = pCommandBars->GetAt(i); if (!pToolBar->IsBuiltIn()) return; CString strMessage, strTitle = pToolBar->GetTitle(), strReset; CXTPResourceManager::AssertValid(XTPResourceManager()->LoadString(&strReset, XTP_IDS_CONFIRM_RESET)); strMessage.Format(strReset, (LPCTSTR)strTitle); if (m_pSheet->MessageBox(strMessage, MB_ICONWARNING | MB_OKCANCEL) != IDOK) return; pToolBar->Reset(FALSE); RefreshToolbarsList(); }
void CXTPCustomizeToolbarsPage::OnRenameToolbar() { int nIndex = m_checkList.GetCurSel(); if (nIndex == LB_ERR) return; CXTPCommandBars* pCommandBars = m_pSheet->GetCommandBars(); int i = (int)m_checkList.GetItemData(nIndex); if (i < 0 || i >= pCommandBars->GetCount()) return; CXTPToolBar* pToolBar = pCommandBars->GetAt(i); if (pToolBar->IsBuiltIn()) return; CXTPNewToolbarDlg dlg(m_pSheet, pCommandBars, pToolBar); if (dlg.DoModal() == IDOK) { pToolBar->SetTitle(dlg.m_strToolbar); m_checkList.DeleteString(nIndex); nIndex = m_checkList.InsertString(nIndex, pToolBar->GetTitle()); m_checkList.SetCheck(nIndex, pToolBar->IsVisible()); m_checkList.SetItemData(nIndex, i); m_checkList.SetCurSel(nIndex); } }
void CXTPCustomizeToolbarsPage::OnSelectionChanged() { int nIndex = m_checkList.GetCurSel(); if (nIndex != LB_ERR) { CXTPCommandBars* pCommandBars = m_pSheet->GetCommandBars(); int i = (int)m_checkList.GetItemData(nIndex); if (i >= 0 && i < pCommandBars->GetCount()) { CXTPToolBar* pToolBar = pCommandBars->GetAt(i); BOOL bBuiltIn = pToolBar->IsBuiltIn(); m_btnReset.EnableWindow(bBuiltIn); m_btnRename.EnableWindow(!bBuiltIn); m_btnDelete.EnableWindow(!bBuiltIn); } } else { m_btnReset.EnableWindow(FALSE); m_btnRename.EnableWindow(FALSE); m_btnDelete.EnableWindow(FALSE); } }
void CXTPRibbonGroup::OnGroupAdded() { CXTPControl* pGroupOption = GetControlGroupOption(); m_pParent->GetControls()->Add(pGroupOption); pGroupOption->InternalAddRef(); pGroupOption->SetHideFlag(xtpHideRibbonTab, !IsVisible()); pGroupOption->SetID(GetID()); CXTPControl* pGroupPopup = (CXTPControl*)GetControlGroupPopup(); m_pParent->GetControls()->Add(pGroupPopup); pGroupPopup->SetCaption(GetCaption()); pGroupPopup->SetDescription(NULL); pGroupPopup->InternalAddRef(); pGroupPopup->SetHideFlag(xtpHideRibbonTab, !IsVisible()); CXTPCommandBars* pCommandBars = m_pRibbonBar->GetCommandBars(); ASSERT(pCommandBars); if (pCommandBars && pCommandBars->IsActionsEnabled()) { CXTPControlAction* pAction = pCommandBars->CreateAction(GetID()); if (pAction->GetCaption().IsEmpty()) pAction->SetCaption(GetCaption()); pGroupPopup->SetAction(pAction); pGroupOption->SetAction(pAction); } }
void CXTPCustomizeToolbarsPage::OnDeleteToolbar() { int nIndex = m_checkList.GetCurSel(); if (nIndex == LB_ERR) return; CXTPCommandBars* pCommandBars = m_pSheet->GetCommandBars(); int i = (int)m_checkList.GetItemData(nIndex); if (i < 0 || i >= pCommandBars->GetCount()) return; CXTPToolBar* pToolBar = pCommandBars->GetAt(i); if (pToolBar->IsBuiltIn()) return; CString strMessage; CString strDelete; CXTPResourceManager::AssertValid(XTPResourceManager()->LoadString(&strDelete, XTP_IDS_CONFIRM_DELETE)); strMessage.Format(strDelete, (LPCTSTR)pToolBar->GetTitle()); if (m_pSheet->MessageBox(strMessage, MB_ICONWARNING | MB_OKCANCEL) == IDOK) { pCommandBars->GetSite()->SendMessage(WM_XTP_CUSTOMIZATION_DELETETOOLBAR, 0, (LPARAM)pToolBar); pCommandBars->Remove(pToolBar); RefreshToolbarsList(); } }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CXTPFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; if (!m_wndStatusBar.Create(this)) return -1; if (!m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) return -1; if (!InitCommandBars()) return -1; CXTPCommandBars* pCommandBars = GetCommandBars(); if (pCommandBars == NULL) return -1; CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(CTinyString(IDS_MENUBAR), IDR_MAINFRAME); if(pMenuBar == NULL) return -1; m_pToolbar = (CXTPToolBar*) pCommandBars->Add(CTinyString(IDS_STANDARD), xtpBarTop); if (!m_pToolbar || !m_pToolbar->LoadToolBar(IDR_MAINFRAME)) return -1; m_pToolbar->ShowTextBelowIcons(); m_pToolbar->EnableCustomization(FALSE); //m_pMapToolbar = (CXTPToolBar*) pCommandBars->Add(CTinyString(IDS_MAP), xtpBarTop); //if (!m_pMapToolbar || !m_pMapToolbar->LoadToolBar(IDR_MAP)) // return -1; //m_pMapToolbar->ShowTextBelowIcons(); pCommandBars->GetCommandBarsOptions()->bAlwaysShowFullMenus = FALSE; pCommandBars->GetShortcutManager()->SetAccelerators(IDR_MAINFRAME); LoadCommandBars(_T("CommandBars")); m_paneManager.InstallDockingPanes(this); CXTPPaintManager::SetTheme(xtpThemeRibbon); m_wndNavigatorBar.SetTheme(xtpShortcutThemeOffice2007); // EnableOffice2007Frame(GetCommandBars()); m_wndNavigatorBar.SetBindWnd(&m_pView->GetMapWnd(),&m_pView->GetListDlg(), &m_pView->GetBkgndDlg(),&m_pView->GetPicCtrl()); return 0; }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CXTPFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; // Enable/Disable XP GUI Mode // xtAfxData.bXPMode = TRUE; // Enable/Disable Menu Shadows // xtAfxData.bMenuShadows = TRUE; if (!InitCommandBars()) return -1; CXTPPaintManager::SetTheme(xtpThemeOffice2003); //xtpThemeVisualStudio2008 CXTPCommandBars* pCommandBars = GetCommandBars(); CXTPCommandBar* pMenuBar; pMenuBar = pCommandBars->SetMenu(_T("Menu Bar"), IDR_MAINFRAME); pMenuBar->SetFlags(xtpFlagIgnoreSetMenuMessage | xtpFlagHideMDIButtons); //main IDR_MAINFRAME /* if (!m_wndMenuBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndMenuBar.LoadMenuBar(IDR_MAINFRAME)) { TRACE0("Failed to create menubar\n"); return -1; // fail to create m_wndMenuBar }*/ 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_wndMenuBar.EnableDockingEx(CBRS_ALIGN_ANY, CBRS_XT_SEMIFLAT); // m_wndToolBar.EnableDockingEx(CBRS_ALIGN_ANY, CBRS_XT_SEMIFLAT); // EnableDockingEx(CBRS_ALIGN_ANY, CBRS_XT_SEMIFLAT); // DockControlBar(&m_wndMenuBar); // DockControlBar(&m_wndToolBar); // InstallCoolMenus(IDR_MAINFRAME); ///////////////装入数据库信息//////////////// // m_sql.Init(); // if(m_sql.Connect(_T("masterdefine"),_T("kj86"),_T("kj86"))) { // AfxMessageBox("NetThread:无法连接用户参数数据库,请确定SQL SERVER服务是否运行!"); // return 0; } // LoadPointInfo(); return 0; }
void CXTPCustomizeMenusPage::OnSelectionChangedContextmenus() { CXTPCommandBars* pCommandBars = m_pSheet->GetCommandBars(); CommitContextMenu(); int nSel = m_cmbContextMenus.GetCurSel(); if (nSel < 1) { GetDlgItem(XTP_IDC_BUTTON_RESETCONTEXT)->EnableWindow(FALSE); return; } GetDlgItem(XTP_IDC_BUTTON_RESETCONTEXT)->EnableWindow(TRUE); CXTPPopupBar* pPopupBar = (CXTPPopupBar*)m_cmbContextMenus.GetItemData(nSel); CXTPToolBar* pContextMenu = (CXTPToolBar*)pCommandBars->Add(_T("Standard"), xtpBarTop, RUNTIME_CLASS(CXTPFloatingPopupBar)); if (!pContextMenu) { TRACE0("Failed to create toolbar\n"); return; } CXTPControls* pControls = pPopupBar->GetControls()->Duplicate(); pContextMenu->SetControls(pControls); pContextMenu->SetBarID(pPopupBar->GetBarID()); pContextMenu->SetTitle(pPopupBar->GetTitle()); pContextMenu->SetCustomizeDialogPresent(FALSE); pContextMenu->SetPosition(xtpBarFloating); pContextMenu->EnableDocking(xtpFlagFloating); pContextMenu->OnRecalcLayout(); CXTPWindowRect rcContext(pContextMenu); CXTPWindowRect rcParent(GetParent()); CPoint pt = m_ptContextMenu; if (pt == CPoint(0, 0)) pt = CPoint(rcParent.left - rcContext.Width(), rcParent.top); pContextMenu->MoveWindow(pt.x, pt.y, rcContext.Width(), rcContext.Height()); m_pContextMenu = pContextMenu; pContextMenu->SetCommandBarData((DWORD_PTR)pPopupBar); pContextMenu->OnUpdateCmdUI(); }
///////////////////////////////////////////////////////////////////////////// // 创建工程接口对象 ///////////////////////////////////////////////////////////////////////////// IProject* CPlugIn::CreateProjectObject(CString strInstName) { IProject* pIProject = (IProject*)(CreateObject(strInstName)); if(pIProject) { // 加载扩展菜单 COWMMenuArray aOWMMenus; CXTPCommandBars* pCommandBars = ((CMainFrame*)AfxGetMainWnd())->GetCommandBars(); CXTPCommandBar* pMenuBar = pCommandBars->GetMenuBar(); pIProject->RegisterMenu((CMenu*)pMenuBar, aOWMMenus, 40000); } return pIProject; }
void CXTPCustomizeToolbarsPage::OnNewToolbar() { CXTPCommandBars* pCommandBars = m_pSheet->GetCommandBars(); CXTPNewToolbarDlg dlg(m_pSheet, pCommandBars); if (dlg.DoModal() == IDOK) { CXTPToolBar* pToolBar = pCommandBars->AddCustomBar(dlg.m_strToolbar, dlg.m_nNewID); RefreshToolbarsList(); pCommandBars->GetSite()->SendMessage(WM_XTP_CUSTOMIZATION_ADDTOOLBAR, 0, (LPARAM)pToolBar); } }
void CAlphaIconsPage::OnCheckLargeimages() { UpdateData(); CXTPFrameWnd* pFrame = (CXTPFrameWnd*)AfxGetMainWnd(); CXTPCommandBars* pCommandBars = pFrame->GetCommandBars(); ASSERT(pCommandBars); CXTPCommandBarsOptions* pOptions = pCommandBars->GetCommandBarsOptions(); // Set global icon's size pOptions->bLargeIcons = m_bLargeImages; RedrawCommandBars(); }
void CXTPCustomizeMenusPage::CommitContextMenu() { CXTPCommandBars* pCommandBars = m_pSheet->GetCommandBars(); if (m_pContextMenu) { CXTPPopupBar* pPopupBar = (CXTPPopupBar*)m_pContextMenu->GetCommandBarData(); CXTPControls* pControls = m_pContextMenu->GetControls()->Duplicate(); pPopupBar->SetControls(pControls); m_ptContextMenu = CXTPWindowRect(m_pContextMenu).TopLeft(); pCommandBars->Remove(m_pContextMenu); m_pContextMenu = NULL; } }
void CActionsSampleView::UpdateActionsState() { CHARFORMAT& cfm = GetCharFormatSelection(); CXTPCommandBars* pCommandBars = ((CXTPFrameWnd*)GetParentFrame())->GetCommandBars(); pCommandBars->GetActions()->FindAction(ID_CHAR_BOLD)->SetChecked( (cfm.dwMask & CFM_BOLD ? (cfm.dwEffects & CFE_BOLD ? 1 : 0) : 2)); pCommandBars->GetActions()->FindAction(ID_CHAR_ITALIC)->SetChecked( (cfm.dwMask & CFM_ITALIC ? (cfm.dwEffects & CFE_ITALIC ? 1 : 0) : 2)); pCommandBars->GetActions()->FindAction(ID_CHAR_UNDERLINE)->SetChecked( (cfm.dwMask & CFM_UNDERLINE ? (cfm.dwEffects & CFE_UNDERLINE ? 1 : 0) : 2)); }
void CAlphaIconsPage::UpdateContent() { XTP_COMMANDBARS_ICONSINFO* pIconsInfo = XTPPaintManager()->GetIconsInfo(); m_bFaded = pIconsInfo->bUseFadedIcons; m_bShadow = pIconsInfo->bIconsWithShadow; CXTPFrameWnd* pFrame = (CXTPFrameWnd*)AfxGetMainWnd(); CXTPCommandBars* pCommandBars = pFrame->GetCommandBars(); ASSERT(pCommandBars); CXTPCommandBarsOptions* pOptions = pCommandBars->GetCommandBarsOptions(); m_bLargeImages = pOptions->bLargeIcons; UpdateData(FALSE); }
///////////////////////////////////////////////////////////////////////////// // 释放工程接口对象 ///////////////////////////////////////////////////////////////////////////// BOOL CPlugIn::ReleaseProjectObject(LPVOID pVciObj, BOOL bForceDelete) { if(m_strType != "project") { return FALSE; } IProject* pIProject = (IProject*)pVciObj; if(pIProject) { COWMMenuArray aOWMMenus; aOWMMenus.Add(OWMMENUITEM()); CXTPCommandBars* pCommandBars = ((CMainFrame*)AfxGetMainWnd())->GetCommandBars(); CXTPCommandBar* pMenuBar = pCommandBars->GetMenuBar(); aOWMMenus[0].pProc = (TYPEOF_ClientMenu*)pMenuBar; pIProject->UnregisterMenu(aOWMMenus); } return ReleaseObject(pVciObj, bForceDelete); }
void gkToolBarPaneBase::InitToolBar( const TCHAR* toolbarname, DWORD nId ) { ////////////////////////////////////////////////////////////////////////// // ToolBar Initilizing VERIFY(InitCommandBars()); CXTPCommandBars* pCommandBars = GetCommandBars(); pCommandBars->GetImageManager()->SetIcons(nId); pCommandBars->SetTheme(xtpThemeWhidbey); //pCommandBars->SetQuickCustomizeMode(FALSE); //TCHAR toolbarname = CXTPToolBar* pToolBar = pCommandBars->Add(toolbarname, xtpBarTop); pToolBar->SetDefaultButtonStyle(xtpButtonIcon); pToolBar->LoadToolBar(nId); pToolBar->SetCloseable(FALSE); pToolBar->EnableCustomization(); pToolBar->GetControls()->CreateOriginalControls(); pCommandBars->GetCommandBarsOptions()->ShowKeyboardCues(xtpKeyboardCuesShowWindowsDefault); pCommandBars->GetToolTipContext()->SetStyle(xtpToolTipOffice2007); RecalcLayout(); ////////////////////////////////////////////////////////////////////////// }
void CXTPRibbonGroupPopupToolBar::OnMouseMove(UINT nFlags, CPoint point) { CXTPCommandBars* pCommandBars = GetCommandBars (); CXTPMouseManager* pMouseManager = pCommandBars->GetMouseManager(); BOOL bMouseLocked = pMouseManager->IsMouseLocked() || !pMouseManager->IsTopParentActive(m_hWnd) || pMouseManager->IsTrackedLock(this) || m_nPopuped != -1; CXTPRibbonGroup* pHighlightedGroup = bMouseLocked || !m_pRibbonBar->GetRibbonPaintManager()->m_bHotTrackingGroups ? NULL : m_pRibbonGroup; if (pHighlightedGroup != m_pHighlightedGroup) { HighlightGroup(pHighlightedGroup); if (m_pHighlightedGroup) { pMouseManager->TrackMouseLeave(*this); } } CXTPPopupToolBar::OnMouseMove(nFlags, point); }
void CXTPCustomizeToolbarsPage::RefreshToolbarsList() { int nIndexSel = 0; int nIndex = m_checkList.GetCurSel(); if (nIndex != LB_ERR) { nIndexSel = (int)m_checkList.GetItemData(nIndex); } int nTopIndex = m_checkList.GetTopIndex(); m_checkList.ResetContent(); CXTPCommandBars* pCommandBars = m_pSheet->GetCommandBars(); int nCount = pCommandBars->GetCount(); for (int i = 0; i < nCount; i++) { CXTPToolBar* pToolBar = pCommandBars->GetAt(i); if (!pToolBar->IsCustomizeDialogPresent()) continue; if (!pToolBar->IsCloseable() && !pToolBar->IsVisible()) continue; nIndex = m_checkList.AddString(pToolBar->GetTitle()); m_checkList.SetCheck(nIndex, pToolBar->IsVisible()); m_checkList.SetItemData(nIndex, i); if (i == nIndexSel) m_checkList.SetCurSel(nIndex); } if (m_checkList.GetTopIndex() != nTopIndex) m_checkList.SetTopIndex(nTopIndex); OnSelectionChanged(); }
void CAlphaIconsPage::OnActivate() { CXTPFrameWnd* pFrame = (CXTPFrameWnd*)AfxGetMainWnd(); CXTPCommandBars* pCommandBars = pFrame->GetCommandBars(); ASSERT(pCommandBars); CXTPToolBar* pToolBar = pCommandBars->GetAt(1); ASSERT(pToolBar->GetTitle() == _T("Standard")); XTPImageManager()->RemoveAll(); pToolBar->LoadToolBar(IDR_ICONS_MENU_32); XTP_COMMANDBARS_ICONSINFO* pIconsInfo = XTPPaintManager()->GetIconsInfo(); pIconsInfo->bUseDisabledIcons = TRUE; CXTPCommandBarsOptions* pOptions = pCommandBars->GetCommandBarsOptions(); pOptions->szIcons = CSize(16, 16); pOptions->szLargeIcons = CSize (42, 35); pOptions->bLargeIcons = FALSE; XTPImageManager()->SetIcons(IDR_ICONS_TOOLBAR_32); if (!XTPImageManager()->IsAlphaIconsSupported()) { m_bResample = TRUE; GetDlgItem(IDC_CHECK_RESAMPLE)->EnableWindow(FALSE); UpdateData(FALSE); } ResampleImages(); UpdateContent(); }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { AfxGetApp()->m_nCmdShow = SW_HIDE; if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; //界面居中显示 this ->CenterWindow(CWnd::GetDesktopWindow()); 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_wndStatusBar.SetPaneInfo(0, m_wndStatusBar.GetItemID(0), SBPS_STRETCH, NULL); m_wndStatusBar.SetPaneInfo(1, m_wndStatusBar.GetItemID(1), SBPS_NORMAL, 180); m_wndStatusBar.SetPaneInfo(2, m_wndStatusBar.GetItemID(2), SBPS_NORMAL, 100); m_wndStatusBar.SetPaneInfo(3, m_wndStatusBar.GetItemID(3), SBPS_NORMAL, 100); m_wndStatusBar.SetPaneInfo(4, m_wndStatusBar.GetItemID(4), SBPS_NORMAL, NULL); m_wndStatusBar.SetPaneInfo(5, m_wndStatusBar.GetItemID(5), SBPS_NORMAL, NULL); m_wndStatusBar.SetPaneInfo(6, m_wndStatusBar.GetItemID(6), SBPS_NORMAL, NULL); /////////////////////////////////////////////////////////////////////////////////////// m_wndStatusBar.EnableCustomization(); if (!m_TrayIcon.Create(_T(""), // Toolktip text this, // Parent window IDR_MAINFRAME, // Icon resource ID IDR_MINIMIZE, // Resource ID of popup menu IDM_SHOW, // Default menu item for popup menu false)) // True if default menu item is located by position { TRACE0("Failed to create tray icon\n"); return -1; } if (!InitCommandBars()) { return -1; } CXTPCommandBars* pCommandBars = GetCommandBars(); CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(_T("Menu Bar"), IDR_MAINFRAME); pMenuBar->SetFlags(xtpFlagAddMDISysPopup); CXTPToolBar* pCommandBar = (CXTPToolBar*)pCommandBars->Add(_T("Standard"), xtpBarTop); if (!pCommandBar || !pCommandBar->LoadToolBar(IDR_TOOLBAR3)) { TRACE0("Failed to create toolbar\n"); return -1; }; pCommandBars->GetCommandBarsOptions()->bShowTextBelowIcons = TRUE; pCommandBars->GetCommandBarsOptions()->ShowKeyboardCues(xtpKeyboardCuesShowWindowsDefault); m_paneManager.InstallDockingPanes(this); m_paneManager.SetTheme(xtpPaneThemeWinExplorer); CXTPDockingPane* pwndPaneLog = CreatePane(300, 141, RUNTIME_CLASS(CLogView), _T("日志信息"), xtpPaneDockBottom); CXTPDockingPane* pwndPaneShortcuts = CreatePane(200, 145, RUNTIME_CLASS(CShortcuts), _T("快捷功能"), xtpPaneDockRight,pwndPaneLog); CXTPDockingPane* pwndPaneIPUP = CreatePane(200, 145, RUNTIME_CLASS(CIPUpdate), _T("域名更新"), xtpPaneDockRight,pwndPaneLog); pwndPaneIPUP->Select(); m_paneManager.AttachPane( pwndPaneIPUP ,pwndPaneShortcuts ); pwndPaneShortcuts->SetOptions(xtpPaneNoCaption); pwndPaneIPUP->SetOptions(xtpPaneNoCaption); XTPColorManager()->DisableLunaColors(TRUE); CXTPPaintManager::SetTheme(xtpThemeOffice2003); LoadCommandBars(_T("CommandBars")); SetTimer(1,1000,NULL); return 0; }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; 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 (!InitCommandBars()) return -1; CXTPPaintManager::SetTheme(xtpThemeOffice2003); CXTPCommandBars* pCommandBars = GetCommandBars(); pCommandBars->SetMenu(_T("Menu Bar"), IDR_MAINFRAME); CXTPToolBar* pCommandBar = (CXTPToolBar*)pCommandBars->Add(_T("Standard"), xtpBarTop); if (!pCommandBar || !pCommandBar->LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); return -1; } pCommandBars->GetImageManager()->SetIcons(IDR_MAINFRAME, IDR_TOOLBAR_ALPHA); pCommandBars->GetShortcutManager()->SetAccelerators(IDR_MAINFRAME); // Load the previous state for command bars. LoadCommandBars(_T("CommandBars")); EnableDocking(CBRS_ALIGN_ANY); SetOfficeTheme(xtpCalendarThemeOffice2007); // Initialize dialog bar if (!m_dlgDatePicker.Create(this, IDD_DATEPICKER, CBRS_LEFT|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_HIDE_INPLACE, ID_VIEW_DATEPICKER)) return -1; // fail to create // Initialize dialog bar if (!m_dlgOptions.Create(this, IDD_CALENDAR_DEMO_VIEW, CBRS_ALIGN_TOP|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_HIDE_INPLACE, ID_VIEW_PROPERTIES)) return -1; // fail to create //m_dlgOptions.EnableDocking(CBRS_ALIGN_ANY); m_dlgOptions.EnableDocking(0); m_dlgOptions.SetWindowText(_T("Options")); ShowControlBar(&m_dlgOptions, FALSE, FALSE); FloatControlBar(&m_dlgOptions, CPoint(100, 200)); // docking for DatePicker m_dlgDatePicker.EnableDocking(CBRS_ALIGN_LEFT); m_dlgDatePicker.SetWindowText(_T("Date Picker")); ShowControlBar(&m_dlgDatePicker, TRUE, FALSE); //FloatControlBar(&m_dlgDatePicker, CPoint(100, GetSystemMetrics(SM_CYSCREEN) / 3)); return 0; }
///////////////////////////////////////////////////////////////////////////// // 加载扩展菜单 ///////////////////////////////////////////////////////////////////////////// BOOL CPlugIn::AddOwmSubMenu(CString strMainMenu, CString strSubMenu, CString strAction) { CMainFrame* pMainFrame = (CMainFrame*)(theApp.GetMainWnd()); CXTPCommandBars* pCommandBars = pMainFrame->GetCommandBars(); if(!pCommandBars) { return FALSE; } CXTPCommandBar* pMenuBar = pCommandBars->GetMenuBar(); if(!pMenuBar) { return FALSE; } CXTPControls* pControls = pMenuBar->GetControls(); CXTPControl* pControl = pControls->GetFirst(); CXTPCommandBar* pMenuBarSub = NULL; CXTPControl* pControlExtSub = NULL; while(pControl) { if(pControl->GetCaption() == strMainMenu) { pMenuBarSub = pControl->GetCommandBar(); CXTPControls* pControlsSub = pMenuBarSub->GetControls(); pControl = pControlsSub->GetFirst(); while(pControl) { if(pControl->GetCaption() == strSubMenu) { pControlExtSub = pControl; break; } pControlsSub->GetNext(pControl); } break; } pControls->GetNext(pControl); } if(pMenuBarSub && !pControlExtSub) { CExtMenuInfo extMenuInfo; extMenuInfo.m_strVciId = m_strId; extMenuInfo.m_strMainMenu = strMainMenu; extMenuInfo.m_strSubMenu = strSubMenu; extMenuInfo.pProc = (TYPEOF_ClientMenu*)OnOwmExtMenuProc; extMenuInfo.pUpdateProc = NULL; extMenuInfo.nProcType = MENU_PROC_TYPE_PARAM_ID; int nExMenuId = IDM_OWMCMD+g_nIdOwmExMenu; extMenuInfo.m_strAction = strAction; extMenuInfo.nId = nExMenuId-IDM_OWMCMD; pMainFrame->m_arExtMenuInfo.Add(extMenuInfo); CXTPControls* pControlsSub = pMenuBarSub->GetControls(); CMenu* pMenu = new CMenu(); pMenu->CreatePopupMenu(); pMenu->AppendMenu(MF_STRING, nExMenuId, strSubMenu); pControlsSub->AddMenuItem(pMenu, 0); delete pMenu; g_nIdOwmExMenu++; } return TRUE; }
bool CMainFrame::_OnCreateRibbon() { // Initialize the command bars if (!InitCommandBars()) return false; // Get a pointer to the command bars object. CXTPCommandBars* pCommandBars = GetCommandBars(); if(pCommandBars == NULL) return false; CXTPPaintManager::SetTheme(xtpThemeRibbon); //关闭默认菜单 ::SetMenu(m_hWnd, nullptr); m_hMenuDefault = nullptr; m_dwMenuBarState = AFX_MBS_HIDDEN; //初始化图标 _LoadIcon(); ///Ribbon CXTPRibbonBar* pRibbonBar = (CXTPRibbonBar*)pCommandBars->Add(_T("Ribbon"), xtpBarTop, RUNTIME_CLASS(CXTPRibbonBar)); if (!pRibbonBar) return false; pRibbonBar->EnableDocking(0); //pRibbonBar->GetTabPaintManager()->m_bSelectOnButtonDown = FALSE; ///创建系统按钮 CXTPControlPopup* pControlFile = (CXTPControlPopup*)pRibbonBar->AddSystemButton(); pControlFile->SetIconId(IDB_GEAR); CMenu sysMenu; sysMenu.LoadMenu(IDR_MAINFRAME); CXTPPopupBar* pCommandBar = new CXTPRibbonSystemPopupBar(); pCommandBar->SetCommandBars(pCommandBars); pControlFile->SetCommandBar(pCommandBar); pCommandBar->InternalRelease(); pCommandBar->LoadMenu(sysMenu.GetSubMenu(0)); pCommandBar->SetIconSize(CSize(32, 32)); ///RibbonHome CXTPRibbonTab* pTab = pRibbonBar->AddTab(L"Home"); //RibbonHome - GroupObject CXTPRibbonGroup* pGroup = pTab->AddGroup(L"Object"); //RibbonHome - GroupObject - Select pGroup->Add(xtpControlButton, IDC_Object_Select); //RibbonHome - GroupObject - Move pGroup->Add(xtpControlButton, IDC_Object_Move); //RibbonHome - GroupObject - Rotate pGroup->Add(xtpControlButton, IDC_Object_Rotate); //RibbonHome - GroupObject - Scale pGroup->Add(xtpControlButton, IDC_Object_Scale); //RibbonHome - GroupObject - Rmove pGroup->Add(xtpControlButton, IDC_Object_Remove); ///RibbonEffect pTab = pRibbonBar->AddTab(L"Effect"); //RibbonEffect - GroupSwitch pGroup = pTab->AddGroup(L"Switch"); //RibbonEffect - GroupSwitch - Shadow pGroup->Add(xtpControlButton, IDC_Effect_Shadow); //RibbonEffect - GroupSwitch - SSAO pGroup->Add(xtpControlButton, IDC_Effect_SSAO); //RibbonEffect - GroupSwitch - Sharpen pGroup->Add(xtpControlButton, IDC_Effect_Sharpen); //RibbonEffect - GroupSwitch - FXAA pGroup->Add(xtpControlButton, IDC_Effect_FXAA); return true; }
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { AfxGetApp()->m_nCmdShow = SW_HIDE; if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; this->CenterWindow(CWnd::GetDesktopWindow()); 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 (!InitCommandBars()) return -1; CXTPCommandBars* pCommandBars = GetCommandBars(); if(pCommandBars == NULL) { TRACE0("Failed to create command bars object.\n"); return -1; // fail to create } //设置下面状态栏 m_wndStatusBar.SetPaneInfo(0, m_wndStatusBar.GetItemID(0), SBPS_STRETCH, NULL); m_wndStatusBar.SetPaneInfo(1, m_wndStatusBar.GetItemID(1), SBPS_NORMAL, 250); m_wndStatusBar.SetPaneInfo(2, m_wndStatusBar.GetItemID(2), SBPS_NORMAL, 120); m_wndStatusBar.SetPaneInfo(3, m_wndStatusBar.GetItemID(3), SBPS_NORMAL, 120); /* m_wndStatusBar.EnableCustomization(); if (!m_TrayIcon.Create(_T(""), // Toolktip text this, // Parent window IDR_MAINFRAME, // Icon resource ID IDR_MINIMIZE, // Resource ID of popup menu IDM_SHOW, // Default menu item for popup menu false)) // True if default menu item is located by position { TRACE0("Failed to create tray icon\n"); return -1; } */ if (!InitCommandBars()) { return -1; } // CXTPCommandBars* pCommandBars = GetCommandBars(); CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(_T("Menu Bar"), IDR_MAINFRAME); pMenuBar->SetFlags(xtpFlagAddMDISysPopup); /* CXTPToolBar* pCommandBar = (CXTPToolBar*)pCommandBars->Add(_T("Standard"), xtpBarTop); if (!pCommandBar || !pCommandBar->LoadToolBar(IDR_TOOLBAR3)) { TRACE0("Failed to create toolbar\n"); return -1; }; */ CXTPToolBar* pCommandBar = (CXTPToolBar*)pCommandBars->Add(_T("工具栏(T)"), xtpBarTop); if (!pCommandBar || !pCommandBar->LoadToolBar(IDR_TOOLBAR3)) // { TRACE0("Failed to create toolbar\n"); return -1; } pCommandBars->GetCommandBarsOptions()->bShowTextBelowIcons = TRUE; pCommandBars->GetCommandBarsOptions()->ShowKeyboardCues(xtpKeyboardCuesShowWindowsDefault); /* // Create ToolBar CXTPToolBar* pCommandBar = (CXTPToolBar*)pCommandBars->Add(_T("工具栏(T)"), xtpBarTop); if (!pCommandBar || !pCommandBar->LoadToolBar(IDR_TOOLBAR3)) // { TRACE0("Failed to create toolbar\n"); return -1; } // LoadIcons(); CXTPCommandBarsOptions* pOptions = pCommandBars->GetCommandBarsOptions(); pOptions->bShowExpandButtonAlways= FALSE; pOptions->bShowTextBelowIcons = true; pOptions->bLargeIcons = TRUE; pCommandBar->GetImageManager()->SetIcons(IDR_TOOLBAR3,IDB_BITMAP1); RedrawWindow(0, 0, RDW_INVALIDATE|RDW_UPDATENOW|RDW_ERASE|RDW_ALLCHILDREN); GetCommandBars()->GetPaintManager()->RefreshMetrics(); ModifyStyle(WS_THICKFRAME, 0); ModifyStyle(0, WS_THICKFRAME); pCommandBars->GetCommandBarsOptions()->ShowKeyboardCues(xtpKeyboardCuesShowNever); */ m_paneManager.InstallDockingPanes(this); m_paneManager.SetTheme(xtpPaneThemeVisualStudio2010); // 设置主题 CXTPDockingPane* pwndPaneLog = CreatePane(235, 150, RUNTIME_CLASS(CLogView), _T("日志信息"), xtpPaneDockBottom); CXTPDockingPane* pwndPaneNum = CreatePane(58, 150, RUNTIME_CLASS(CShowNum), _T("主机统计"), xtpPaneDockRight, pwndPaneLog); // CXTPDockingPane* pwndPaneChoose = CreatePane(235, 150, RUNTIME_CLASS(CMoreChoose), _T("筛选主机"), xtpPaneDockBottom); CXTPDockingPane* pwndPaneUPDATEIP = CreatePane(235, 150, RUNTIME_CLASS(CUPDATEIP), _T("域名更新"), xtpPaneDockBottom); // CXTPDockingPane* pwndPaneBatch = CreatePane(235, 150, RUNTIME_CLASS(CBatch), _T("批量命令"), xtpPaneDockBottom); // CXTPDockingPane* pwndPaneplay = CreatePane(260, 145, RUNTIME_CLASS(CBuildServer), _T("整蛊娱乐"), xtpPaneDockBottom); CXTPDockingPane* pwndPaneproxy = CreatePane(235, 150, RUNTIME_CLASS(CProxy), _T("远程连接"), xtpPaneDockBottom); // m_paneManager.AttachPane( pwndPaneChoose, pwndPaneLog ); m_paneManager.AttachPane( pwndPaneUPDATEIP, pwndPaneLog); // m_paneManager.AttachPane( pwndPaneBatch, pwndPaneChoose); m_paneManager.AttachPane( pwndPaneproxy, pwndPaneUPDATEIP ); pwndPaneLog->Select(); pwndPaneLog->SetOptions(xtpPaneNoCaption); pwndPaneNum->SetOptions(xtpPaneNoCaption); // pwndPaneChoose->SetOptions(xtpPaneNoCaption); pwndPaneUPDATEIP->SetOptions(xtpPaneNoCaption); // pwndPaneBatch->SetOptions(xtpPaneNoCaption); // pwndPaneplay->SetOptions(xtpPaneNoCaption); pwndPaneproxy->SetOptions(xtpPaneNoCaption); /* XTPColorManager()->DisableLunaColors(TRUE); CXTPPaintManager::SetTheme(xtpThemeOffice2003); LoadCommandBars(_T("CommandBars")); SetTimer(1,1000,NULL); */ m_hDrawIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); m_hEmptyIcon = AfxGetApp()->LoadIcon(IDI_SYSTRAY1); m_NotifyIcon.cbSize = sizeof(NOTIFYICONDATA); m_NotifyIcon.hWnd = this->GetSafeHwnd(); CString Lineips = Onlinetips(); CString Lineips1 = OnVoicepromptsm(); wsprintf(m_NotifyIcon.szTip,"主机数量: %d台\n语音: %s\n消息提示: %s",Zjshulian,Lineips1,Lineips); m_NotifyIcon.uCallbackMessage = WM_ICONMESSAGE; m_NotifyIcon.uFlags = NIF_MESSAGE|NIF_TIP|NIF_ICON; m_NotifyIcon.hIcon = m_hDrawIcon; m_NotifyIcon.uID = IDR_MAINFRAME; Shell_NotifyIcon(NIM_ADD, &m_NotifyIcon); //初始化记录值 // m_nCurrent = 0; // SetTimer(1, 500, NULL); //开启定时器 1 return 0; }
bool CMainFrame::_OnCreateRibbon() { // Initialize the command bars if (!InitCommandBars()) return false; // Get a pointer to the command bars object. CXTPCommandBars* pCommandBars = GetCommandBars(); if(pCommandBars == NULL) return false; CXTPPaintManager::SetTheme(xtpThemeRibbon); //关闭默认菜单 ::SetMenu(m_hWnd, nullptr); m_hMenuDefault = nullptr; m_dwMenuBarState = AFX_MBS_HIDDEN; //初始化图标 _LoadIcon(); ///Ribbon CXTPRibbonBar* pRibbonBar = (CXTPRibbonBar*)pCommandBars->Add(_T("Ribbon"), xtpBarTop, RUNTIME_CLASS(CXTPRibbonBar)); if (!pRibbonBar) return false; pRibbonBar->EnableDocking(0); //pRibbonBar->GetTabPaintManager()->m_bSelectOnButtonDown = FALSE; ///创建系统按钮 CXTPControlPopup* pControlFile = (CXTPControlPopup*)pRibbonBar->AddSystemButton(); pControlFile->SetIconId(IDB_GEAR); CMenu sysMenu; sysMenu.LoadMenu(IDR_MAINFRAME); CXTPPopupBar* pCommandBar = new CXTPRibbonSystemPopupBar(); pCommandBar->SetCommandBars(pCommandBars); pControlFile->SetCommandBar(pCommandBar); pCommandBar->InternalRelease(); pCommandBar->LoadMenu(sysMenu.GetSubMenu(0)); pCommandBar->SetIconSize(CSize(32, 32)); ///RibbonHome CXTPRibbonTab* pTab = pRibbonBar->AddTab(L"Home"); //RibbonHome - GroupObject CXTPRibbonGroup* pGroup = pTab->AddGroup(L"Object"); //RibbonHome - GroupObject - Select pGroup->Add(xtpControlButton, IDC_Object_Select); //RibbonHome - GroupObject - Move pGroup->Add(xtpControlButton, IDC_Object_Move); //RibbonHome - GroupObject - Rotate pGroup->Add(xtpControlButton, IDC_Object_Rotate); //RibbonHome - GroupObject - Scale pGroup->Add(xtpControlButton, IDC_Object_Scale); //RibbonHome - GroupObject - Rmove pGroup->Add(xtpControlButton, IDC_Object_Remove); ///RibbonHome - GroupTerrainModify pGroup = pTab->AddGroup(L"Terrain Modify"); //RibbonHome - GroupTerrainModify - Deform pGroup->Add(xtpControlButton, IDC_Terrain_Deform); //RibbonHome - GroupTerrainModify - Splat CXTPControlPopup* pBtn = dynamic_cast<CXTPControlPopup*>(pGroup->Add(xtpControlSplitButtonPopup, IDC_Terrain_Splat)); pBtn->GetCommandBar()->GetControls()->Add(xtpControlButton, IDC_Terrain_Splat_Layer0); pBtn->GetCommandBar()->GetControls()->Add(xtpControlButton, IDC_Terrain_Splat_Layer1); pBtn->GetCommandBar()->GetControls()->Add(xtpControlButton, IDC_Terrain_Splat_Layer2); pBtn->GetCommandBar()->GetControls()->Add(xtpControlButton, IDC_Terrain_Splat_Layer3); pBtn->GetCommandBar()->GetControls()->Add(xtpControlButton, IDC_Terrain_Splat_Layer4); //RibbonHome - GroupTerrainBrush pGroup = pTab->AddGroup(L"Terrain Brush"); //RibbonHome - GroupTerrainBrush - EditBrushSize CXTPControlEdit* pControl = (CXTPControlEdit*)pGroup->Add(xtpControlEdit, ID_Terrain_BrushSize1); pControl->ShowSpinButtons(TRUE); pControl = (CXTPControlEdit*)pGroup->Add(xtpControlEdit, ID_Terrain_BrushSize2); pControl->ShowSpinButtons(TRUE); //RibbonHome - GroupTerrainTexture pGroup = pTab->AddGroup(L"Layer Texture"); pGroup->SetControlsCentering(TRUE); m_terrainTexGallery = CXTPControlGalleryItems::CreateItems(pCommandBars, IDC_Terrain_LayerTexture); CXTPControlGallery* pControlGallery = (CXTPControlGallery*)pGroup->Add(new CXTPControlGallery(), IDC_Terrain_LayerTexture); pControlGallery->SetControlSize(CSize(250, 60)); //pControlGallery->SetResizable(); pControlGallery->SetItemsMargin(0, 1, 0, 1); pControlGallery->ShowLabels(FALSE); pControlGallery->ShowBorders(TRUE); pControlGallery->SetItems(m_terrainTexGallery); _CreateLayerTexIcon(); //RibbonHome - GroupVegetation pGroup = pTab->AddGroup(L"Vegetation"); //RibbonHome - GroupVegetation - Grass pGroup->Add(xtpControlButton, IDC_Vegetation_Grass); ///RibbonEffect pTab = pRibbonBar->AddTab(L"Effect"); //RibbonEffect - GroupSwitch pGroup = pTab->AddGroup(L"Switch"); //RibbonEffect - GroupSwitch - Shadow pGroup->Add(xtpControlButton, IDC_Effect_Shadow); //RibbonEffect - GroupSwitch - SSAO pGroup->Add(xtpControlButton, IDC_Effect_SSAO); //RibbonEffect - GroupSwitch - Sharpen pGroup->Add(xtpControlButton, IDC_Effect_Sharpen); //RibbonEffect - GroupSwitch - FXAA pGroup->Add(xtpControlButton, IDC_Effect_FXAA); ///RibbonAnimation m_animTab = pRibbonBar->InsertTab(-1, L"Animation"); m_animTab->SetContextTab(xtpRibbonTabContextColorRed, L"Animation"); //选中了带动画物体才显示 m_animTab->SetVisible(FALSE); //RibbonAnimation - GroupAnim pGroup = m_animTab->AddGroup(L"Anim"); //RibbonAnimation - GroupAnim - AnimList m_animList = dynamic_cast<CXTPControlComboBox*>(pGroup->Add(xtpControlComboBox, IDC_Animation_Names)); m_animList->SetDropDownListStyle(); m_animList->SetWidth(150); //RibbonAnimation - GroupAnim - Play pGroup->Add(xtpControlButton, IDC_Animation_Play); //RibbonAnimation - GroupAnim - Stop pGroup->Add(xtpControlButton, IDC_Animation_Stop); //RibbonAnimation - GroupEffect pGroup = m_animTab->AddGroup(L"Effect"); //RibbonAnimation - GroupEffect - EffectList m_effectList = dynamic_cast<CXTPControlComboBox*>(pGroup->Add(xtpControlComboBox, IDC_Animation_EffectList)); m_effectList->SetDropDownListStyle(); m_effectList->SetWidth(150); //RibbonAnimation - GroupEffect - AddEffect CXTPControlPopup* pAddBtn = dynamic_cast<CXTPControlPopup*>(pGroup->Add(xtpControlSplitButtonPopup, IDC_Effect_Add)); pAddBtn->GetCommandBar()->GetControls()->Add(xtpControlButton, IDC_Effect_AddParticle); pAddBtn->GetCommandBar()->GetControls()->Add(xtpControlButton, IDC_Effect_AddEntityEffect); pAddBtn->GetCommandBar()->GetControls()->Add(xtpControlButton, IDC_Effect_AddDLight); //RibbonAnimation - GroupEffect - EffectRemove pGroup->Add(xtpControlButton, IDC_Animation_EffectRemove); return true; }
///////////////////////////////////////////////////////////////////////////// // 关闭一个VCI组件 ///////////////////////////////////////////////////////////////////////////// BOOL CPlugIn::CloseOwm() { if(m_pVciObj == NULL) { return TRUE; } IVciOwm* pIVciOwm = (IVciOwm*)m_pVciObj; //CMultiDocTemplate* pDocTemplate = NULL; //pIVciOwm->GetDocTemplate(&pDocTemplate); // 执行Done操作 if(m_pIVciControl == NULL) { return FALSE; } ((IVciControl*)m_pIVciControl)->Done(m_strDoneParam); // 关闭ControlBar if((m_nType & OWM_CONTROLBAR) || (m_nType & OWM_TABCTRLBAR)) CloseOwmControlBar(); // 卸载ToolBar if(m_nType & OWM_TOOLBAR) { CMainFrame* pMainFrame = (CMainFrame*)(AfxGetMainWnd()); //CXTToolBar* pToolBar = &(pMainFrame->m_wndToolBar); //pIVciOwm->UnregisterClientToolBar(pToolBar, m_aOWMMenus, IDM_OWMCMD); //pMainFrame->ShowControlBar(pToolBar, TRUE, FALSE); } // 重置TCL扩展命令(没有必要在此处注销,因为TCL只在创建解释器时有效) if(m_nType & OWM_TCL) { // 注销TCL扩展命令 //if(owminfo.ol.UnregisterTclCmd) // owminfo.ol.UnregisterTclCmd(); } // 卸载扩展菜单命令 if(m_nType & OWM_MENU) { COWMMenuArray aOWMMenus; aOWMMenus.Add(OWMMENUITEM()); CXTPCommandBars* pCommandBars = ((CMainFrame*)AfxGetMainWnd())->GetCommandBars(); CXTPCommandBar* pMenuBar = pCommandBars->GetMenuBar(); aOWMMenus[0].pProc = (TYPEOF_ClientMenu*)pMenuBar; pIVciOwm->UnregisterClientMenu(aOWMMenus); } // 释放OWM文档模板 if((m_nType & OWM_DOC) && m_pDocTemplate) { // 关闭所有OWM文档和窗口 POSITION pos = m_pDocTemplate->GetFirstDocPosition(); if(pos != 0) { m_pDocTemplate->CloseAllDocuments(FALSE); } // 删除OWM文档模板 delete m_pDocTemplate; m_pDocTemplate = NULL; } pIVciOwm->Release(); m_pIVciControl = NULL; m_pVciObj = NULL; return TRUE; }
// 加载OWM类型插件 BOOL CPlugIn::LoadOwmPlugIn() { // 检查进程标识,判断是否可以在本进程加载 if((m_strProcess != "") && (theApp.m_strProcessId != "") && (m_strProcess != theApp.m_strProcessId)) { return NULL; } OpenVciLib(IID_IVciOwm); m_pVciObj = CreateObject(); if(m_pVciObj == NULL) { return FALSE; } IVciOwm* pIVciOwm = (IVciOwm*)m_pVciObj; OWM_INFO owminfo; memset(&owminfo, 0, sizeof(OWM_INFO)); owminfo.bEnable = TRUE; pIVciOwm->SetIPlatUI(theApp.GetIPlatUI()); // 创建文档模板 if(m_nType & OWM_DOC) { CRuntimeClass* pDocClass = NULL; CRuntimeClass* pFrameClass = NULL; CRuntimeClass* pViewClass = NULL; pIVciOwm->GetRuntimeClass(1, &pDocClass); pIVciOwm->GetRuntimeClass(2, &pFrameClass); pIVciOwm->GetRuntimeClass(3, &pViewClass); m_pDocTemplate = new CMultiDocTemplate( IDR_BLUEUITYPE, pDocClass, pFrameClass, pViewClass); pIVciOwm->SetDocTemplate(m_pDocTemplate); // 兼容以前的数据结构 owminfo.ol.pDocClass = pDocClass; owminfo.ol.pFrameClass = pFrameClass; owminfo.ol.pViewClass = pViewClass; owminfo.ol.pDocTemplate = m_pDocTemplate; } owminfo.ol.nOWMType = m_nType; owminfo.ol.CommandPlat = gCommandPlat; // owminfo.ol.TraceFmt = PF_TRACE_FMT; // owminfo.ol.CreateOutput = PF_CREATE_OUTPUT; // owminfo.ol.CloseOutput = PF_CLOSE_OUTPUT; // owminfo.ol.OutputSet = PF_TRACE_SET_ID; // owminfo.ol.Output = PF_TRACE_EX_ID; // 设置OWM链接 pIVciOwm->Command(OC_SETOWMLINK, (WPARAM)(&owminfo.ol), NULL); // 加载菜单 // 注册OWM菜单,添加到弹出菜单上 // 注:在Xtreme中需要通过MenuBar的GetMenu函数来获取主 // 菜单的资源,而CJLib中直接通过MainFrame的GetMenu就可以了 //ol.RegisterClientMenu(m_pMainWnd->GetMenu(), m_aOWMMenus, IDM_OWMCMD, pDoc); // 加载扩展菜单 if(AfxGetMainWnd()->GetSafeHwnd() != NULL) { COWMMenuArray aOWMMenus; CXTPCommandBars* pCommandBars = ((CMainFrame*)AfxGetMainWnd())->GetCommandBars(); CXTPCommandBar* pMenuBar = pCommandBars->GetMenuBar(); pIVciOwm->RegisterClientMenu((CMenu*)pMenuBar, aOWMMenus, 40000, NULL); } // 加载ToolBar if(m_nType & OWM_TOOLBAR) {/* CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd(); CXTToolBar* pToolBar = &(pMainFrame->m_wndToolBar); int nStart = pToolBar->CommandToIndex(ID_VIEW_OUTPUT); pIVciOwm->RegisterClientToolBar(pToolBar, m_aOWMMenus, IDM_OWMCMD, nStart); pMainFrame->ShowControlBar(pToolBar, TRUE, FALSE);*/ } // 执行OWM的初始化操作 if(m_pIVciControl == NULL) { return FALSE; } ((IVciControl*)m_pIVciControl)->Init(m_strInitParam); // 创建第一个OWM窗口 if((m_nType & OWM_DOC) && (m_nType & OWM_AUTOCREATE)) { if((m_nType & OWM_CONTROLBAR) || (m_nType & OWM_TABCTRLBAR)) //&& owminfo.ol.pCtrlBarClass) NewOwmControlBar(); else NewOwmFrame(m_strInitParam); } return TRUE; }
BOOL CXTPCustomizeMenusPage::OnInitDialog() { CXTPPropertyPage::OnInitDialog(); CXTPCommandBars* pCommandBars = m_pSheet->GetCommandBars(); CString strDefaultMenu; GetDlgItemText(XTP_IDC_STATIC_DESCRIPTION, strDefaultMenu); if (_tcschr(strDefaultMenu, _T('\n')) != NULL) { AfxExtractSubString(m_strDefaultMenuDesc, strDefaultMenu, 1); AfxExtractSubString(m_strDefaultMenu, strDefaultMenu, 0); } else { m_strDefaultMenu = m_strDefaultMenuDesc = strDefaultMenu; } int nIndex = m_cmbAppMenus.AddString(m_strDefaultMenu); m_cmbAppMenus.SetItemData(nIndex, 0); int nCurSel = 0; if (pCommandBars->GetMenuBar() && ((pCommandBars->GetMenuBar()->GetFlags() & xtpFlagIgnoreSetMenuMessage) == 0)) { CXTPMenuBar* pMenuBar = pCommandBars->GetMenuBar(); CXTPMenuBarMDIMenus* pMDIControls = pMenuBar->GetMDIMenus(); POSITION pos = pMDIControls->GetStartPosition(); CXTPMenuBarMDIMenuInfo* pInfo; while (pos) { pMDIControls->GetNextMenu(pos, pInfo); if (pInfo->m_nIDResource == pMenuBar->GetDefaultMenuResource()) continue; if (!pInfo->m_strTitle.IsEmpty()) { nIndex = m_cmbAppMenus.AddString(pInfo->m_strTitle); m_cmbAppMenus.SetItemData(nIndex, (DWORD_PTR)pInfo); if (pInfo->m_nIDResource == pMenuBar->GetCurrentMenuResource()) { nCurSel = nIndex; } } } } m_cmbAppMenus.SetCurSel(nCurSel); OnSelectionChangedAppmenus(); nIndex = m_cmbContextMenus.AddString(_T("")); m_cmbContextMenus.SetItemData(nIndex, 0); for (int i = 0; i < pCommandBars->GetContextMenus()->GetCount(); i++) { CXTPPopupBar* pPopupBar = (CXTPPopupBar*)pCommandBars->GetContextMenus()->GetAt(i); nIndex = m_cmbContextMenus.AddString(pPopupBar->GetTitle()); m_cmbContextMenus.SetItemData(nIndex, (DWORD_PTR)pPopupBar); } m_cmbContextMenus.SetCurSel(0); OnSelectionChangedContextmenus(); SetResize(XTP_IDC_STATIC_APPLICATIONMENUS, XTP_ANCHOR_TOPLEFT, XTP_ANCHOR_TOPRIGHT); SetResize(XTP_IDC_STATIC_CONTEXTMENUS, XTP_ANCHOR_TOPLEFT, XTP_ANCHOR_TOPRIGHT); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }