当 LButtonDown 从 MFC 中的树控件时,我已经实现了多选
但是当我反复快速单击鼠标 LButtonDown 时,就会出现问题。
我认为这个问题是由我快速单击时双击事件引起的
反复。
我只想获取点击事件,除了双击事件。
重要的是必须在仅 LBUTTONDOWN 事件和 LButtonClick 事件中解决此问题。
请帮我。〜
我的英文写作是如此糟糕。对不起。
以下是我的来源部分。
void CFileTreeCtrl::OnLButtonDown(UINT nFlags , CPoint point)
{
//LRESULT *pResult = 0;
GetCursorPos(&point);
::ScreenToClient(this->m_hWnd, &point);
HTREEITEM hItem = this->HitTest(point, &nFlags);
// if items is exist and event is occured
if (hItem != NULL && (nFlags & TVHT_ONITEMSTATEICON) != 0)
{
// if items is checked
if (this->GetCheck(hItem))
{
UnCheckChildItems(hItem);
}
// items is not checked
else
{
CheckChildItems(hItem);
}
}
CDragDropTreeCtrl::OnLButtonDown(nFlags, point);
}
//=========================================================
// checked all child items
//=========================================================
void CFileTreeCtrl::CheckChildItems(HTREEITEM hItem)
{
HTREEITEM hChildItem = this->GetChildItem(hItem);
while (hChildItem != NULL)
{
this->SetCheck(hChildItem, TRUE);
if (this->ItemHasChildren(hChildItem))
{
CheckChildItems(hChildItem);
}
hChildItem = this->GetNextItem(hChildItem, TVGN_NEXT);
}
}
//=========================================================
// Uncheck all child items.
//=========================================================
void CFileTreeCtrl::UnCheckChildItems(HTREEITEM hItem)
{
HTREEITEM hChildItem = this->GetChildItem(hItem);
while (hChildItem != NULL)
{
this->SetCheck(hChildItem, FALSE);
if (this->ItemHasChildren(hChildItem))
{
UnCheckChildItems(hChildItem);
}
hChildItem = this->GetNextItem(hChildItem, TVGN_NEXT);
}
}