From df63b2a48fe633850f62bb87bc87a395444b2d5a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 26 Sep 2006 00:58:49 +0000 Subject: [PATCH] let the control process WM_RBUTTONDOWN finally, trying to do it ourselves doesn't look right and results in some weird events (see bug 1541148), it's easier to generate WM_CONTEXTMENU manually instead git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41453 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/treectrl.cpp | 55 +++++++++++--------------------------------- 1 file changed, 14 insertions(+), 41 deletions(-) diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 5fa9112a5f..024af8d6eb 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -2050,21 +2050,6 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara switch ( nMsg ) { - case WM_RBUTTONDOWN: - // if the item we are about to right click on is not already - // selected or if we click outside of any item, remove the - // entire previous selection - if ( !htItem || !::IsItemSelected(GetHwnd(), htItem) ) - { - UnselectAll(); - } - - // select item and set the focus to the - // newly selected item - ::SelectItem(GetHwnd(), htItem); - ::SetFocus(GetHwnd(), htItem); - break; - case WM_LBUTTONDOWN: if ( htItem && isMultiple && (tvht.flags & TVHT_ONITEM) != 0 ) { @@ -2367,32 +2352,9 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara WXLRESULT wxTreeCtrl::MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { - // default WM_RBUTTONDOWN handler enters modal loop inside DefWindowProc() - // waiting for WM_RBUTTONUP and then sends the resulting WM_CONTEXTMENU to - // the parent window, not us, which completely breaks everything so simply - // don't let it see this message at all - if ( nMsg == WM_RBUTTONDOWN ) - return 0; - - // but because of the above we don't get NM_RCLICK which is normally - // generated by tree window proc when the modal loop mentioned above ends - // because the mouse is released -- synthesize it ourselves instead - if ( nMsg == WM_RBUTTONUP ) - { - NMHDR hdr; - hdr.hwndFrom = GetHwnd(); - hdr.idFrom = GetId(); - hdr.code = NM_RCLICK; - - WXLPARAM rc; - MSWOnNotify(GetId(), (LPARAM)&hdr, &rc); - - // continue as usual - } - if ( nMsg == WM_CHAR ) { - // also don't let the control process Space and Return keys because it + // don't let the control process Space and Return keys because it // doesn't do anything useful with them anyhow but always beeps // annoyingly when it receives them and there is no way to turn it off // simply if you just process TREEITEM_ACTIVATED event to which Space @@ -2503,8 +2465,8 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) break; } -#endif -#endif +#endif // TVN_GETINFOTIP +#endif // !__WXWINCE__ case TVN_GETDISPINFO: eventType = wxEVT_COMMAND_TREE_GET_INFO; @@ -2775,6 +2737,17 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) *result = false; break; + case NM_RCLICK: + // prevent tree control from sending WM_CONTEXTMENU to our parent + // (which it does if NM_RCLICK is not handled) because we want to + // send it to the control itself + *result = + processed = true; + + ::SendMessage(GetHwnd(), WM_CONTEXTMENU, + (WPARAM)GetHwnd(), ::GetMessagePos()); + break; + case TVN_BEGINDRAG: case TVN_BEGINRDRAG: if ( event.IsAllowed() )