From: Ilya Shpigor Date: Tue, 5 May 2009 14:01:18 +0000 (+0400) Subject: comctl32: Implementation of tooltips for the treeview controls without TVS_NOTOOLTIPS... X-Git-Tag: 1.0.10-eter21~7 X-Git-Url: http://git.etersoft.ru/projects/?a=commitdiff_plain;h=864292c8798cc1fd3ade9271eeca0ea05fce0c17;p=wine%2Feterwine.git comctl32: Implementation of tooltips for the treeview controls without TVS_NOTOOLTIPS style (eterbug #2617) --- diff --git a/dlls/comctl32/treeview.c b/dlls/comctl32/treeview.c index fcb6ae4daf..9769867541 100644 --- a/dlls/comctl32/treeview.c +++ b/dlls/comctl32/treeview.c @@ -5007,10 +5007,20 @@ TREEVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs) TREEVIEW_NotifyFormat(infoPtr, infoPtr->hwndNotify, NF_REQUERY); if (!(infoPtr->dwStyle & TVS_NOTOOLTIPS)) + { + TTTOOLINFOW ti = { 0 }; + infoPtr->hwndToolTip = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL, WS_POPUP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, 0, 0, 0); + ti.cbSize = sizeof(TTTOOLINFOW); + ti.uFlags = TTF_SUBCLASS; + ti.hwnd = infoPtr->hwnd; + GetClientRect(infoPtr->hwnd, &ti.rect); + SendMessageW(infoPtr->hwndToolTip, TTM_ADDTOOLW, 0, (LPARAM)(LPTOOLINFOW)&ti); + } + if (infoPtr->dwStyle & TVS_CHECKBOXES) initialize_checkboxes(infoPtr); @@ -5233,6 +5243,60 @@ TREEVIEW_MouseLeave (TREEVIEW_INFO * infoPtr) return 0; } +static LRESULT +TREEVIEW_ShowTip (TREEVIEW_INFO * infoPtr, LPARAM lParam) +{ + POINT pt; + TRACKMOUSEEVENT trackinfo; + TREEVIEW_ITEM * item; + TTTOOLINFOW ti = { 0 }; + RECT itemrc; + + /* fill in the TRACKMOUSEEVENT struct */ + trackinfo.cbSize = sizeof(TRACKMOUSEEVENT); + trackinfo.dwFlags = TME_QUERY; + trackinfo.hwndTrack = infoPtr->hwnd; + trackinfo.dwHoverTime = HOVER_DEFAULT; + + /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */ + _TrackMouseEvent(&trackinfo); + + /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */ + if(!(trackinfo.dwFlags & TME_LEAVE)) + { + trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */ + + /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */ + /* and can properly deactivate the hot item */ + _TrackMouseEvent(&trackinfo); + } + + pt.x = (short)LOWORD(lParam); + pt.y = (short)HIWORD(lParam); + + item = TREEVIEW_HitTestPoint(infoPtr, pt); + + if (!item) return 0; + + *(HTREEITEM*)&itemrc = item; + + if (!TREEVIEW_GetItemRect(infoPtr, TRUE, &itemrc)) return 0; + if (itemrc.right < infoPtr->clientWidth) return 0; + if ((item->pszText == LPSTR_TEXTCALLBACKW) + || (item->pszText == NULL)) return 0; + + SendMessageW(infoPtr->hwndToolTip, TTM_GETTOOLINFOW, 0, (LPARAM)(LPTOOLINFOW)&ti); + ti.cbSize = sizeof(TTTOOLINFOW); + ti.uFlags = TTF_SUBCLASS | TTF_CENTERTIP; + ti.hwnd = infoPtr->hwnd; + ti.lpszText = item->pszText; + ti.uId = 0; + CopyRect(&ti.rect, &itemrc); + SendMessageW(infoPtr->hwndToolTip, TTM_SETTOOLINFOW, 0, (LPARAM)(LPTOOLINFOW) &ti); + + return 0; +} + static LRESULT TREEVIEW_MouseMove (TREEVIEW_INFO * infoPtr, LPARAM lParam) { @@ -5679,6 +5743,8 @@ TREEVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return TREEVIEW_MouseLeave(infoPtr); case WM_MOUSEMOVE: + if (!(infoPtr->dwStyle & TVS_NOTOOLTIPS)) + TREEVIEW_ShowTip(infoPtr, lParam); if (infoPtr->dwStyle & TVS_TRACKSELECT) return TREEVIEW_MouseMove(infoPtr, lParam); else