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();
	}
}
Пример #2
0
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::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);
	}
}