From f9d43598a8f2abef923af704d18ff396542c7c7d Mon Sep 17 00:00:00 2001
From: serhio <serhio@etersoft.ru>
Date: Mon, 30 Jan 2012 17:36:56 +0400
Subject: [PATCH] eterbug #7978 comctl32: Flickering tooltip's fix for sbis

---
 dlls/comctl32/tooltips.c |   35 +++++++++++++++++++++++++++++++----
 1 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/dlls/comctl32/tooltips.c b/dlls/comctl32/tooltips.c
index 977debd..6285ed1 100644
--- a/dlls/comctl32/tooltips.c
+++ b/dlls/comctl32/tooltips.c
@@ -32,7 +32,7 @@
  *   - Animation.
  *   - Links.
  *   - Messages:
- *     o TTM_ADJUSTRECT
+ *     o TTM_ADJUSTRECT (Simple implementation exists)
  *     o TTM_GETTITLEA
  *     o TTM_GETTTILEW
  *     o TTM_POPUP
@@ -849,8 +849,9 @@ TOOLTIPS_Hide (TOOLTIPS_INFO *infoPtr)
 
     infoPtr->nCurrentTool = -1;
 
-    SetWindowPos (infoPtr->hwndSelf, HWND_TOP, 0, 0, 0, 0,
-		    SWP_NOZORDER | SWP_HIDEWINDOW | SWP_NOACTIVATE);
+    SetWindowPos (infoPtr->hwndSelf, NULL, 0, 0, 0, 0,
+		    SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER |
+			SWP_NOACTIVATE | SWP_HIDEWINDOW );
 }
 
 
@@ -1089,6 +1090,29 @@ TOOLTIPS_AddToolT (TOOLTIPS_INFO *infoPtr, const TTTOOLINFOW *ti, BOOL isW)
 
 
 static LRESULT
+TOOLTIPS_AdjustRect (TOOLTIPS_INFO *infoPtr, WPARAM fLarger, LPRECT prc)
+{
+    LONG mrg = (GetWindowLongW (infoPtr->hwndSelf, GWL_STYLE) & TTS_BALLOON) ?
+				  BALLOON_TEXT_MARGIN : NORMAL_TEXT_MARGIN;
+
+    if (!prc)
+	return FALSE;
+    if (fLarger) {
+    prc->left -= mrg;
+    prc->top -= mrg;
+    prc->right += mrg;
+    prc->bottom += mrg;
+    } else {
+    prc->left += mrg;
+    prc->top += mrg;
+    prc->right -= mrg;
+    prc->bottom -= mrg;
+    }
+    return TRUE;
+}
+
+
+static LRESULT
 TOOLTIPS_DelToolT (TOOLTIPS_INFO *infoPtr, const TTTOOLINFOW *ti, BOOL isW)
 {
     TTTOOL_INFO *toolPtr;
@@ -2135,7 +2159,7 @@ TOOLTIPS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_
 	msg.message = uMsg;
 	msg.wParam = wParam;
 	msg.lParam = lParam;
-	TOOLTIPS_RelayEvent(infoPtr, &msg);
+	SendMessageW (infoPtr->hwndSelf, TTM_RELAYEVENT, 0, (LPARAM)&msg);
 	break;
 
     default:
@@ -2162,6 +2186,9 @@ TOOLTIPS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 	case TTM_ADDTOOLW:
 	    return TOOLTIPS_AddToolT (infoPtr, (LPTTTOOLINFOW)lParam, uMsg == TTM_ADDTOOLW);
 
+	case TTM_ADJUSTRECT:
+	    return TOOLTIPS_AdjustRect (infoPtr, wParam, (LPRECT)lParam);
+
 	case TTM_DELTOOLA:
 	case TTM_DELTOOLW:
 	    return TOOLTIPS_DelToolT (infoPtr, (LPTOOLINFOW)lParam,
-- 
1.7.6
