From 3995f8eb97f3fa807fb7d805bb8b86425f490b06 Mon Sep 17 00:00:00 2001 From: "Unknown (CR)" Date: Wed, 13 Oct 1999 17:04:34 +0000 Subject: [PATCH] Added support for item clicks git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3963 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/listctrl.cpp | 54 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 145eca12b4..f8b52a99cf 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -1197,9 +1197,9 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) switch ( hdr1->code ) { case LVN_BEGINRDRAG: - eventType = wxEVT_COMMAND_LIST_BEGIN_RDRAG; + eventType = wxEVT_COMMAND_LIST_BEGIN_RDRAG; // fall through - + case LVN_BEGINDRAG: if ( eventType == wxEVT_NULL ) { @@ -1343,7 +1343,55 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) // else translate it into wxEVT_COMMAND_LIST_ITEM_ACTIVATED event eventType = wxEVT_COMMAND_LIST_ITEM_ACTIVATED; break; - + + case NM_RCLICK: + /* TECH NOTE: NM_RCLICK isn't really good enough here. We want to + subclass and check for the actual WM_RBUTTONDOWN message, because + NM_RCLICK waits for the WM_RBUTTONUP message as well before firing off. + We want to have notify events for both down -and- up. */ + { + // if the user processes it in wxEVT_COMMAND_RIGHT_CLICK(), don't do + // anything else + if ( wxControl::MSWOnNotify(idCtrl, lParam, result) ) { + return TRUE; + } + + // else translate it into wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK event + LVHITTESTINFO lvhti; +#ifdef __GNUWIN32__ + memset(&lvhti,0,sizeof(LVHITTESTINFO)); +#else + ZeroMemory(&lvhti, sizeof(LVHITTESTINFO)); // must set all fields to 0 +#endif + ::GetCursorPos(&(lvhti.pt)); + ::ScreenToClient(GetHwnd(),&(lvhti.pt)); + if(ListView_HitTest(GetHwnd(),&lvhti)!=-1) { + if(lvhti.flags & LVHT_ONITEM) { + eventType = wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK; + event.m_itemIndex = lvhti.iItem; + } + } + } + break; + + /* + case NM_MCLICK: // ***** THERE IS NO NM_MCLICK. Subclass anyone? ****** + { + // if the user processes it in wxEVT_COMMAND_MIDDLE_CLICK(), don't do + // anything else + if ( wxControl::MSWOnNotify(idCtrl, lParam, result) ) + { + return TRUE; + } + + // else translate it into wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK event + eventType = wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK; + NMITEMACTIVATE* hdr = (NMITEMACTIVATE*)lParam; + event.m_itemIndex = hdr->iItem; + } + break; + */ + case LVN_SETDISPINFO: { eventType = wxEVT_COMMAND_LIST_SET_INFO; -- 2.45.2