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(); } }
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 CXTPNewToolbarDlg::OnOK() { UpdateData(); // If no text was entered, alert user. if (m_strToolbar.IsEmpty()) { XTPResourceManager()->ShowMessageBox(XTP_IDS_ERROR_BLANKNAME, MB_ICONSTOP); return; } m_nNewID = AFX_IDW_CONTROLBAR_FIRST; // Loop through all of the existing control bars to find // an available ID to use. int nCount = m_pCommandBars->GetCount(); int nIndex = 0; while (nIndex < nCount) { CXTPToolBar* pBar = m_pCommandBars->GetAt(nIndex); ASSERT(pBar != NULL); // We found a control bar with the same ID as m_nNewID, increment // m_nNewID and reset the position back to the head. if (pBar && m_pCommandBar == NULL && pBar->GetBarID() == m_nNewID) { m_nNewID++; // If m_nNewID is greater than the maximum number of allowed // custom commands, alert the user and abort. if ((int)m_nNewID >= AFX_IDW_CONTROLBAR_LAST) { XTPResourceManager()->ShowMessageBox(XTP_IDS_ERROR_LIMIT, MB_ICONSTOP); CDialog::OnCancel(); return; } nIndex = 0; continue; } // Now check to see if the title for the toolbar has already // been used, if so, alert the user and return. if (pBar && m_pCommandBar != pBar && m_strToolbar.Compare(pBar->GetTitle()) == 0) { CString strName, strError; CXTPResourceManager::AssertValid(XTPResourceManager()->LoadString(&strError, XTP_IDS_ERROR_EXISTS)); strName.Format(strError, (LPCTSTR)m_strToolbar); XTPResourceManager()->ShowMessageBox(strName, MB_ICONSTOP); return; } nIndex++; } CDialog::OnOK(); // success! }
void CXTPNewToolbarDlg::SetSuggestedName() { CString szMsg; XTPResourceManager()->LoadString(&szMsg, XTP_IDS_CUSTOM_BAR); int iNewID = 1; CString strCustom; strCustom.Format(szMsg, iNewID); int nCount = m_pCommandBars->GetCount(); int nIndex = 0; while (nIndex < nCount) { CXTPToolBar* pBar = m_pCommandBars->GetAt(nIndex); ASSERT(pBar != NULL); if (pBar && strCustom.Compare(pBar->GetTitle()) == 0) { strCustom.Format(szMsg, iNewID++); nIndex = 0; continue; } nIndex++; } m_strToolbar = strCustom; UpdateData(FALSE); }
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(); }