From 0570fa86490e9c6f30bba75d4dbed4c4455b608d Mon Sep 17 00:00:00 2001 From: hell-racer Date: Thu, 18 Jan 2018 16:02:53 +0300 Subject: [PATCH 1/2] Fix for #53 Double-clicking the tooltip makes it flicker --- Source/ExcelDna.IntelliSense/ToolTipForm.cs | 78 +++++++++++---------- 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/Source/ExcelDna.IntelliSense/ToolTipForm.cs b/Source/ExcelDna.IntelliSense/ToolTipForm.cs index 23bb4ca..117c06d 100644 --- a/Source/ExcelDna.IntelliSense/ToolTipForm.cs +++ b/Source/ExcelDna.IntelliSense/ToolTipForm.cs @@ -65,44 +65,46 @@ public ToolTipForm(IntPtr hwndOwner) _borderLightPen = new Pen(Color.FromArgb(225, 225, 225)); SetStyle(ControlStyles.UserMouse | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); Debug.Print($"Created ToolTipForm with owner {hwndOwner}"); - } - - protected override void WndProc(ref Message m) - { - const int WM_MOUSEACTIVATE = 0x21; - const int WM_MOUSEMOVE = 0x0200; - const int WM_LBUTTONDOWN = 0x0201; - const int WM_LBUTTONUP = 0x0202; - const int WM_SETCURSOR = 0x20; - const int MA_NOACTIVATE = 0x0003; - - switch (m.Msg) - { - // Prevent activation by mouse interaction - case WM_MOUSEACTIVATE: - m.Result = (IntPtr)MA_NOACTIVATE; - return; - // We're never active, so we need to do our own mouse handling - case WM_LBUTTONDOWN: - MouseButtonDown(GetMouseLocation(m.LParam)); - return; - case WM_MOUSEMOVE: - MouseMoved(GetMouseLocation(m.LParam)); - return; - case WM_LBUTTONUP: - MouseButtonUp(GetMouseLocation(m.LParam)); - return; - case WM_SETCURSOR: - // We need to handle this message to prevent flicker (possibly because we're not 'active'). - m.Result = new IntPtr(1); //Signify that we dealt with the message. - return; - default: - base.WndProc(ref m); - return; - } - } - - void ShowToolTip() + } + + protected override void WndProc(ref Message m) + { + const int WM_MOUSEACTIVATE = 0x21; + const int WM_MOUSEMOVE = 0x0200; + const int WM_LBUTTONDOWN = 0x0201; + const int WM_LBUTTONUP = 0x0202; + const int WM_LBUTTONDBLCLK = 0x203; + const int WM_SETCURSOR = 0x20; + const int MA_NOACTIVATE = 0x0003; + + switch (m.Msg) + { + // Prevent activation by mouse interaction + case WM_MOUSEACTIVATE: + m.Result = (IntPtr)MA_NOACTIVATE; + return; + // We're never active, so we need to do our own mouse handling + case WM_LBUTTONDOWN: + MouseButtonDown(GetMouseLocation(m.LParam)); + return; + case WM_MOUSEMOVE: + MouseMoved(GetMouseLocation(m.LParam)); + return; + case WM_LBUTTONUP: + MouseButtonUp(GetMouseLocation(m.LParam)); + return; + case WM_SETCURSOR: + case WM_LBUTTONDBLCLK: + // We need to handle this message to prevent flicker (possibly because we're not 'active'). + m.Result = new IntPtr(1); //Signify that we dealt with the message. + return; + default: + base.WndProc(ref m); + return; + } + } + + void ShowToolTip() { try { From d5d45bed670799606bb4769d816c11053e9c5279 Mon Sep 17 00:00:00 2001 From: hell-racer Date: Thu, 18 Jan 2018 16:37:54 +0300 Subject: [PATCH 2/2] Fix for #53 Double-clicking the tooltip makes it flicker --- Source/ExcelDna.IntelliSense/ToolTipForm.cs | 80 ++++++++++----------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/Source/ExcelDna.IntelliSense/ToolTipForm.cs b/Source/ExcelDna.IntelliSense/ToolTipForm.cs index 117c06d..4bd7bdb 100644 --- a/Source/ExcelDna.IntelliSense/ToolTipForm.cs +++ b/Source/ExcelDna.IntelliSense/ToolTipForm.cs @@ -65,46 +65,46 @@ public ToolTipForm(IntPtr hwndOwner) _borderLightPen = new Pen(Color.FromArgb(225, 225, 225)); SetStyle(ControlStyles.UserMouse | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); Debug.Print($"Created ToolTipForm with owner {hwndOwner}"); - } - - protected override void WndProc(ref Message m) - { - const int WM_MOUSEACTIVATE = 0x21; - const int WM_MOUSEMOVE = 0x0200; - const int WM_LBUTTONDOWN = 0x0201; - const int WM_LBUTTONUP = 0x0202; - const int WM_LBUTTONDBLCLK = 0x203; - const int WM_SETCURSOR = 0x20; - const int MA_NOACTIVATE = 0x0003; - - switch (m.Msg) - { - // Prevent activation by mouse interaction - case WM_MOUSEACTIVATE: - m.Result = (IntPtr)MA_NOACTIVATE; - return; - // We're never active, so we need to do our own mouse handling - case WM_LBUTTONDOWN: - MouseButtonDown(GetMouseLocation(m.LParam)); - return; - case WM_MOUSEMOVE: - MouseMoved(GetMouseLocation(m.LParam)); - return; - case WM_LBUTTONUP: - MouseButtonUp(GetMouseLocation(m.LParam)); - return; - case WM_SETCURSOR: - case WM_LBUTTONDBLCLK: - // We need to handle this message to prevent flicker (possibly because we're not 'active'). - m.Result = new IntPtr(1); //Signify that we dealt with the message. - return; - default: - base.WndProc(ref m); - return; - } - } - - void ShowToolTip() + } + + protected override void WndProc(ref Message m) + { + const int WM_MOUSEACTIVATE = 0x21; + const int WM_MOUSEMOVE = 0x0200; + const int WM_LBUTTONDOWN = 0x0201; + const int WM_LBUTTONUP = 0x0202; + const int WM_LBUTTONDBLCLK = 0x203; + const int WM_SETCURSOR = 0x20; + const int MA_NOACTIVATE = 0x0003; + + switch (m.Msg) + { + // Prevent activation by mouse interaction + case WM_MOUSEACTIVATE: + m.Result = (IntPtr)MA_NOACTIVATE; + return; + // We're never active, so we need to do our own mouse handling + case WM_LBUTTONDOWN: + MouseButtonDown(GetMouseLocation(m.LParam)); + return; + case WM_MOUSEMOVE: + MouseMoved(GetMouseLocation(m.LParam)); + return; + case WM_LBUTTONUP: + MouseButtonUp(GetMouseLocation(m.LParam)); + return; + case WM_SETCURSOR: + case WM_LBUTTONDBLCLK: + // We need to handle this message to prevent flicker (possibly because we're not 'active'). + m.Result = new IntPtr(1); //Signify that we dealt with the message. + return; + default: + base.WndProc(ref m); + return; + } + } + + void ShowToolTip() { try {