From: Roman Pišl Subject: [PATCH v2 1/2] comctl32: Preserve tooltip size and position after TTN_SHOW correctly. Message-Id: <20180224110109.20700-1-rpisl@seznam.cz> Date: Sat, 24 Feb 2018 12:01:08 +0100 Fixes: https://bugs.winehq.org/show_bug.cgi?id=14336 https://bugs.winehq.org/show_bug.cgi?id=29864 https://bugs.winehq.org/show_bug.cgi?id=38298 Signed-off-by: Roman Pišl --- dlls/comctl32/tooltips.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/dlls/comctl32/tooltips.c b/dlls/comctl32/tooltips.c index 12f2d4b81c..f84b203f2b 100644 --- a/dlls/comctl32/tooltips.c +++ b/dlls/comctl32/tooltips.c @@ -589,6 +589,7 @@ TOOLTIPS_Show (TOOLTIPS_INFO *infoPtr, BOOL track_activate) int ptfx = 0; DWORD style = GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE); INT nTool, current; + LRESULT res; if (track_activate) { @@ -627,11 +628,6 @@ TOOLTIPS_Show (TOOLTIPS_INFO *infoPtr, BOOL track_activate) TRACE("Show tooltip %d\n", nTool); - hdr.hwndFrom = infoPtr->hwndSelf; - hdr.idFrom = toolPtr->uId; - hdr.code = TTN_SHOW; - SendMessageW (toolPtr->hwnd, WM_NOTIFY, toolPtr->uId, (LPARAM)&hdr); - TRACE("%s\n", debugstr_w(infoPtr->szTipText)); TOOLTIPS_CalcTipSize (infoPtr, &size); @@ -824,9 +820,30 @@ TOOLTIPS_Show (TOOLTIPS_INFO *infoPtr, BOOL track_activate) * it is no longer needed */ } - SetWindowPos (infoPtr->hwndSelf, HWND_TOPMOST, rect.left, rect.top, - rect.right - rect.left, rect.bottom - rect.top, - SWP_SHOWWINDOW | SWP_NOACTIVATE); + /* set calculated windows size and position */ + SetWindowPos (infoPtr->hwndSelf, NULL, rect.left, rect.top, + rect.right - rect.left, rect.bottom - rect.top, + SWP_NOZORDER | SWP_NOACTIVATE); + + /* call TTN_SHOW, an application may adjust size and/or position */ + hdr.hwndFrom = infoPtr->hwndSelf; + hdr.idFrom = toolPtr->uId; + hdr.code = TTN_SHOW; + res = SendMessageW (toolPtr->hwnd, WM_NOTIFY, toolPtr->uId, (LPARAM)&hdr); + + if (res) + { + /* TRUE returned if position was changed */ + SetWindowPos (infoPtr->hwndSelf, HWND_TOPMOST, -1, -1, -1, -1, + SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW | SWP_NOACTIVATE); + } + else + { + /* FALSE returned, still the size could have been modified and we have + * to preserve it */ + SetWindowPos (infoPtr->hwndSelf, HWND_TOPMOST, rect.left, rect.top, -1, -1, + SWP_NOSIZE | SWP_SHOWWINDOW | SWP_NOACTIVATE); + } /* repaint the tooltip */ InvalidateRect(infoPtr->hwndSelf, NULL, TRUE); -- 2.16.1