From b8e3f1cfb7892a1144385bbbd94e9d4f02d887d5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 21 Apr 2007 21:14:59 +0000 Subject: [PATCH] don't let def window proc start another drag operation if we just started one ourselves for a multiselection tree (replaces patch 1702133) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45568 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/treectrl.cpp | 59 ++++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 23143017f3..416f0c5c42 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -2061,6 +2061,14 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara ::SetFocus(GetHwnd(), htItem); processed = true; } + else // click on a single selected item + { + // don't interfere with the default processing in + // WM_MOUSEMOVE handler below as the default window + // proc will start the drag itself if we let have + // WM_LBUTTONDOWN + m_htClickedItem.Unset(); + } // reset on any click without Shift m_htSelStart.Unset(); @@ -2075,35 +2083,44 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara int cx = abs(m_ptClick.x - x); int cy = abs(m_ptClick.y - y); - if ( cx > GetSystemMetrics( SM_CXDRAG ) || cy > GetSystemMetrics( SM_CYDRAG ) ) + if ( cx > ::GetSystemMetrics(SM_CXDRAG) || + cy > ::GetSystemMetrics(SM_CYDRAG) ) { - HWND pWnd = ::GetParent( GetHwnd() ); - if ( pWnd ) - { - NM_TREEVIEW tv; + NM_TREEVIEW tv; + wxZeroMemory(tv); - tv.hdr.hwndFrom = GetHwnd(); - tv.hdr.idFrom = ::GetWindowLong( GetHwnd(), GWL_ID ); - tv.hdr.code = TVN_BEGINDRAG; + tv.hdr.hwndFrom = GetHwnd(); + tv.hdr.idFrom = ::GetWindowLong(GetHwnd(), GWL_ID); + tv.hdr.code = TVN_BEGINDRAG; - tv.itemNew.hItem = HITEM(m_htClickedItem); + tv.itemNew.hItem = HITEM(m_htClickedItem); - TVITEM tviAux; - ZeroMemory(&tviAux, sizeof(tviAux)); - tviAux.hItem = HITEM(m_htClickedItem); - tviAux.mask = TVIF_STATE | TVIF_PARAM; - tviAux.stateMask = 0xffffffff; - TreeView_GetItem( GetHwnd(), &tviAux ); - tv.itemNew.state = tviAux.state; - tv.itemNew.lParam = tviAux.lParam; + TVITEM tviAux; + wxZeroMemory(tviAux); - tv.ptDrag.x = x; - tv.ptDrag.y = y; + tviAux.hItem = HITEM(m_htClickedItem); + tviAux.mask = TVIF_STATE | TVIF_PARAM; + tviAux.stateMask = 0xffffffff; + TreeView_GetItem(GetHwnd(), &tviAux); - ::SendMessage( pWnd, WM_NOTIFY, tv.hdr.idFrom, (LPARAM)&tv ); - } + tv.itemNew.state = tviAux.state; + tv.itemNew.lParam = tviAux.lParam; + + tv.ptDrag.x = x; + tv.ptDrag.y = y; + + // do it before SendMessage() call below to avoid + // reentrancies here if there is another WM_MOUSEMOVE + // in the queue already m_htClickedItem.Unset(); + + ::SendMessage(GetHwndOf(GetParent()), WM_NOTIFY, + tv.hdr.idFrom, (LPARAM)&tv ); + + // don't pass it to the default window proc, it would + // start dragging again + processed = true; } } #endif // __WXWINCE__ -- 2.45.2