コード例 #1
0
void CManageTagsDlg::OnBnClickedManageTagsEditBtn()
{
	int lCount = m_ManageTagsList.GetSelCount() ;
	if(lCount != 1 )
		return;

	CString lTagName;
	CIntArray lSelItems;
	lSelItems.SetSize(lCount);
	m_ManageTagsList.GetSelItems(lCount, lSelItems.GetData()); 
	int lSelTagIdx = lSelItems.GetAt(0);
	m_ManageTagsList.GetText(lSelTagIdx, lTagName);
	CTagsEditTagDlg lEditTagsDlg(lTagName);
	if(lEditTagsDlg.DoModal() == IDOK)
	{
		DWORD_PTR lTagID = m_ManageTagsList.GetItemData(lSelTagIdx);
		m_ManageTagsList.DeleteString(lSelTagIdx);
		lSelTagIdx = m_ManageTagsList.AddString(lTagName);
		m_ManageTagsList.SetItemData(lSelTagIdx, lTagID);
	}
	UpdateUI();
}
コード例 #2
0
// Szabi, case 195
void CManageTagsDlg::OnBnClickedManageTagsDeleteBtn()
{
	CTTags lTags(m_pParamCDB->pDB);
	if (AfxMessageBox(_T("Are you sure you want to delete this tag?"), MB_YESNO|MB_ICONQUESTION) == IDYES)
	{
		int lCount = m_ManageTagsList.GetSelCount();
		if(lCount <= 0)
			return;

		CIntArray lListBoxSelArray;
		lListBoxSelArray.SetSize(lCount);
		m_ManageTagsList.GetSelItems(lCount, lListBoxSelArray.GetData()); 

		int lIndex;
		CString lTagStr;
		int lTagStrLen;
		int lLastIndex = -1;

		for(int i = lCount - 1; i >= 0; i--)
		{
			lIndex = lListBoxSelArray.GetAt(i);
			lTagStrLen = m_ManageTagsList.GetTextLen(lIndex);
			m_ManageTagsList.GetText(lIndex, lTagStr.GetBuffer(lTagStrLen));
			lTagStr.ReleaseBuffer();

			if(	lTags.DeleteByName(lTagStr))
				m_ManageTagsList.DeleteString(lIndex);

			if (lLastIndex == -1) lLastIndex = lIndex;
		}
		lLastIndex = (lLastIndex + 1) - lCount;
		if (lLastIndex > m_ManageTagsList.GetCount() - 1) lLastIndex = m_ManageTagsList.GetCount() - 1;
		m_ManageTagsList.SetSel(lLastIndex, TRUE);
	}
	UpdateUI();
}