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 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(); }