case 1 : I have a MFC dialog box having a LisBox.
I have added two items in listbox.
Whenever i am double clicking on empty area of list box i.e. not double clicking
on either of two item.
Double click is detecting on empty area of listbox.
case 2: When i created a small MFC test application with listbox. it iis detecting double click only on item, not on empty area.
I compared all properties of both cases but couldn't figure out what is the problem.
Anyone has idea what is going wrong in case 1.
1
A
回答
2
我認爲這是不正常的過程。我已經在VS2010中測試了您的情況。在我的MFC測試應用程序發送LBN_DBLCLK
時,我雙擊空白區域。如果你真的不想知道這種情況的原因,你可以檢查空白區域是否發生雙擊事件。我認爲這是節省時間的好方法。
void CMfcDlgTestDlg::OnLbnDblclkList2()
{
// TODO: Add your control notification handler code here
CListBox* list = (CListBox*)(GetDlgItem(IDC_LIST2));
int cur_sel = list->GetCurSel();
if (cur_sel == -1)
{
return;
}
}
編輯:另一個案例 當已選中列表框中的項目之一,怎麼能處理上ON_LBN_DBLCLK
處理? 我認爲會有一些可用的方法來解決這個問題,但是我使用下面的代碼,它也可以是有用的方法。
void CMfcDlgTestDlg::OnLbnDblclkList2()
{
// TODO: Add your control notification handler code here
CListBox* list = (CListBox*)(GetDlgItem(IDC_LIST2));
CPoint cursor;
cursor.x = GetCurrentMessage()->pt.x;
cursor.y = GetCurrentMessage()->pt.y;
list->ScreenToClient(&cursor);
BOOL is_outside = FALSE;
UINT item_index = list->ItemFromPoint(cursor, is_outside);
if(is_outside)
{
//mouse clicked on empty area
return ;
}
else
{
// do something with 'item_index'
}
}
我希望這會對你有所幫助。
相關問題
- 1. 檢測空白區域的圖像
- 2. 單擊TreeView空白區域中的事件
- 3. 單擊空白區域
- 4. ListBox導致程序在空白區域單擊時崩潰
- 5. 雙擊選擇PhpStorm中的空白區域
- 6. 雙擊CListBox的空白區域不會調用我的雙擊功能
- 7. jQuery單擊空白區域上的事件
- 8. 我想檢測一個項目雙擊WinForms列表框控件。 [如何處理點擊空白區域?]
- 9. 爲什麼Drupal中的區域是空白的?
- 10. 爲什麼我的空白區域被從HTML中刪除?
- 11. 空白區域
- 12. 爲什麼我的表格區域上方有額外的空白區域?
- 13. UIWebView中的空白區域
- 14. XML中的空白區域
- 15. 爲什麼在我的css左邊有一個空白區域
- 16. 爲什麼我的主頁下面有空白區域?
- 17. 爲什麼Ul上面的空白區域
- 18. Text Watcher在android中檢測退格和空白區域?
- 19. TreeView - 在空白區域點擊
- 20. Bootstrap空白區域
- 21. preg_match空白區域
- 22. 如何在FabricJS上檢測畫布上的空白區域?
- 23. 區分Qt中的單擊事件和雙擊事件
- 24. 檢測ListBox的滾動事件?
- 25. 測試雙擊事件
- 26. 點擊空白區域返回到選定區域
- 27. 用python pyglet檢測雙擊事件的正確方法是什麼?
- 28. 爲什麼在listBox上單擊鼠標右鍵時它在listBox區域中的任何地方工作?
- 29. iPhone中的雙擊檢測
- 30. kineticjs如何在圖層的空白區域捕獲單擊事件
當我點擊空白區域時,我從未收到Dbl點擊事件。你確定你在談論一個ListBox而不是一個List View? – xMRi
是的,它只是列表框 – Suri