From d73d6b209353dbb2f6e2e2880c18f6eaf4a137f5 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 25 Jul 2016 23:03:19 +0300 Subject: [PATCH] comctl32/treeview: Set hot item when hovering over item, not entire row. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/comctl32/treeview.c | 43 +++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/dlls/comctl32/treeview.c b/dlls/comctl32/treeview.c index ae174138a97..a703ae76cc9 100644 --- a/dlls/comctl32/treeview.c +++ b/dlls/comctl32/treeview.c @@ -3635,7 +3635,7 @@ TREEVIEW_HitTestPoint(const TREEVIEW_INFO *infoPtr, POINT pt) return item; } -static LRESULT +static TREEVIEW_ITEM * TREEVIEW_HitTest(const TREEVIEW_INFO *infoPtr, LPTVHITTESTINFO lpht) { TREEVIEW_ITEM *item; @@ -3670,14 +3670,14 @@ TREEVIEW_HitTest(const TREEVIEW_INFO *infoPtr, LPTVHITTESTINFO lpht) if (status) { lpht->flags = status; - return 0; + return NULL; } item = TREEVIEW_HitTestPoint(infoPtr, lpht->pt); if (!item) { lpht->flags = TVHT_NOWHERE; - return 0; + return NULL; } if (x >= item->textOffset + item->textWidth) @@ -3708,7 +3708,7 @@ TREEVIEW_HitTest(const TREEVIEW_INFO *infoPtr, LPTVHITTESTINFO lpht) lpht->hItem = item; TRACE("(%d,%d):result 0x%x\n", lpht->pt.x, lpht->pt.y, lpht->flags); - return (LRESULT)item; + return item; } /* Item Label Editing ***************************************************/ @@ -4131,7 +4131,7 @@ TREEVIEW_LButtonDoubleClick(TREEVIEW_INFO *infoPtr, LPARAM lParam) hit.pt.x = (short)LOWORD(lParam); hit.pt.y = (short)HIWORD(lParam); - item = (TREEVIEW_ITEM *)TREEVIEW_HitTest(infoPtr, &hit); + item = TREEVIEW_HitTest(infoPtr, &hit); if (!item) return 0; TRACE("item %d\n", TREEVIEW_GetItemIndex(infoPtr, item)); @@ -5331,9 +5331,9 @@ TREEVIEW_MouseLeave (TREEVIEW_INFO * infoPtr) static LRESULT TREEVIEW_MouseMove (TREEVIEW_INFO * infoPtr, LPARAM lParam) { - POINT pt; TRACKMOUSEEVENT trackinfo; TREEVIEW_ITEM * item; + TVHITTESTINFO ht; if (!(infoPtr->dwStyle & TVS_TRACKSELECT)) return 0; @@ -5358,18 +5358,21 @@ TREEVIEW_MouseMove (TREEVIEW_INFO * infoPtr, LPARAM lParam) _TrackMouseEvent(&trackinfo); } - pt.x = (short)LOWORD(lParam); - pt.y = (short)HIWORD(lParam); + ht.pt.x = (short)LOWORD(lParam); + ht.pt.y = (short)HIWORD(lParam); - item = TREEVIEW_HitTestPoint(infoPtr, pt); - - if (item != infoPtr->hotItem) + item = TREEVIEW_HitTest(infoPtr, &ht); + if ((item != infoPtr->hotItem) || !(ht.flags & TVHT_ONITEM)) { /* redraw old hot item */ TREEVIEW_InvalidateItem(infoPtr, infoPtr->hotItem); - infoPtr->hotItem = item; - /* redraw new hot item */ - TREEVIEW_InvalidateItem(infoPtr, infoPtr->hotItem); + infoPtr->hotItem = NULL; + if (item && (ht.flags & TVHT_ONITEM)) + { + infoPtr->hotItem = item; + /* redraw new hot item */ + TREEVIEW_InvalidateItem(infoPtr, infoPtr->hotItem); + } } return 0; @@ -5508,14 +5511,14 @@ TREEVIEW_StyleChanged(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam) static LRESULT TREEVIEW_SetCursor(const TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam) { - POINT pt; TREEVIEW_ITEM * item; + TVHITTESTINFO ht; NMMOUSE nmmouse; - GetCursorPos(&pt); - ScreenToClient(infoPtr->hwnd, &pt); + GetCursorPos(&ht.pt); + ScreenToClient(infoPtr->hwnd, &ht.pt); - item = TREEVIEW_HitTestPoint(infoPtr, pt); + item = TREEVIEW_HitTest(infoPtr, &ht); memset(&nmmouse, 0, sizeof(nmmouse)); if (item) @@ -5529,7 +5532,7 @@ TREEVIEW_SetCursor(const TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam) if (TREEVIEW_SendRealNotify(infoPtr, NM_SETCURSOR, &nmmouse.hdr)) return 0; - if (item && (infoPtr->dwStyle & TVS_TRACKSELECT)) + if (item && (infoPtr->dwStyle & TVS_TRACKSELECT) && (ht.flags & TVHT_ONITEM)) { SetCursor(infoPtr->hcurHand); return 0; @@ -5673,7 +5676,7 @@ TREEVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return TREEVIEW_GetVisibleCount(infoPtr); case TVM_HITTEST: - return TREEVIEW_HitTest(infoPtr, (LPTVHITTESTINFO)lParam); + return (LRESULT)TREEVIEW_HitTest(infoPtr, (TVHITTESTINFO*)lParam); case TVM_INSERTITEMA: case TVM_INSERTITEMW: