Skip to content

Commit 0570fa8

Browse files
committed
Fix for #53 Double-clicking the tooltip makes it flicker
1 parent b478de3 commit 0570fa8

File tree

1 file changed

+40
-38
lines changed

1 file changed

+40
-38
lines changed

Source/ExcelDna.IntelliSense/ToolTipForm.cs

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -65,44 +65,46 @@ public ToolTipForm(IntPtr hwndOwner)
6565
_borderLightPen = new Pen(Color.FromArgb(225, 225, 225));
6666
SetStyle(ControlStyles.UserMouse | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
6767
Debug.Print($"Created ToolTipForm with owner {hwndOwner}");
68-
}
69-
70-
protected override void WndProc(ref Message m)
71-
{
72-
const int WM_MOUSEACTIVATE = 0x21;
73-
const int WM_MOUSEMOVE = 0x0200;
74-
const int WM_LBUTTONDOWN = 0x0201;
75-
const int WM_LBUTTONUP = 0x0202;
76-
const int WM_SETCURSOR = 0x20;
77-
const int MA_NOACTIVATE = 0x0003;
78-
79-
switch (m.Msg)
80-
{
81-
// Prevent activation by mouse interaction
82-
case WM_MOUSEACTIVATE:
83-
m.Result = (IntPtr)MA_NOACTIVATE;
84-
return;
85-
// We're never active, so we need to do our own mouse handling
86-
case WM_LBUTTONDOWN:
87-
MouseButtonDown(GetMouseLocation(m.LParam));
88-
return;
89-
case WM_MOUSEMOVE:
90-
MouseMoved(GetMouseLocation(m.LParam));
91-
return;
92-
case WM_LBUTTONUP:
93-
MouseButtonUp(GetMouseLocation(m.LParam));
94-
return;
95-
case WM_SETCURSOR:
96-
// We need to handle this message to prevent flicker (possibly because we're not 'active').
97-
m.Result = new IntPtr(1); //Signify that we dealt with the message.
98-
return;
99-
default:
100-
base.WndProc(ref m);
101-
return;
102-
}
103-
}
104-
105-
void ShowToolTip()
68+
}
69+
70+
protected override void WndProc(ref Message m)
71+
{
72+
const int WM_MOUSEACTIVATE = 0x21;
73+
const int WM_MOUSEMOVE = 0x0200;
74+
const int WM_LBUTTONDOWN = 0x0201;
75+
const int WM_LBUTTONUP = 0x0202;
76+
const int WM_LBUTTONDBLCLK = 0x203;
77+
const int WM_SETCURSOR = 0x20;
78+
const int MA_NOACTIVATE = 0x0003;
79+
80+
switch (m.Msg)
81+
{
82+
// Prevent activation by mouse interaction
83+
case WM_MOUSEACTIVATE:
84+
m.Result = (IntPtr)MA_NOACTIVATE;
85+
return;
86+
// We're never active, so we need to do our own mouse handling
87+
case WM_LBUTTONDOWN:
88+
MouseButtonDown(GetMouseLocation(m.LParam));
89+
return;
90+
case WM_MOUSEMOVE:
91+
MouseMoved(GetMouseLocation(m.LParam));
92+
return;
93+
case WM_LBUTTONUP:
94+
MouseButtonUp(GetMouseLocation(m.LParam));
95+
return;
96+
case WM_SETCURSOR:
97+
case WM_LBUTTONDBLCLK:
98+
// We need to handle this message to prevent flicker (possibly because we're not 'active').
99+
m.Result = new IntPtr(1); //Signify that we dealt with the message.
100+
return;
101+
default:
102+
base.WndProc(ref m);
103+
return;
104+
}
105+
}
106+
107+
void ShowToolTip()
106108
{
107109
try
108110
{

0 commit comments

Comments
 (0)