-
-
Notifications
You must be signed in to change notification settings - Fork 335
/
ScrollMessageFilter.cs
executable file
·51 lines (45 loc) · 1.08 KB
/
ScrollMessageFilter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
namespace Eto.WinForms
{
class ScrollMessageFilter : swf.IMessageFilter
{
public static bool IsScrollable(swf.Control control)
{
var p = control as swf.ScrollableControl;
if (p != null)
return p.AutoScroll;
return control is swf.DataGridView
#if NETFRAMEWORK
|| control is swf.DataGrid
#endif
|| control is swf.TreeView
|| control is swf.ListControl
|| control is swf.RichTextBox;
}
public bool PreFilterMessage(ref swf.Message m)
{
if (m.Msg == (int)Win32.WM.MOUSEWHEEL)
{
var c = swf.Control.FromHandle(m.HWnd);
if (c == null)
return false;
while (c.Parent != null)
c = c.Parent;
var cp = swf.Cursor.Position;
swf.Control scrollChild = null;
while (c != null)
{
if (IsScrollable(c))
scrollChild = c;
if (!c.HasChildren)
break;
c = c.GetChildAtPoint(c.PointToClient(cp), swf.GetChildAtPointSkip.Invisible);
}
if (scrollChild == null)
return false;
Win32.SendMessage(scrollChild.Handle, (Win32.WM)m.Msg, m.WParam, m.LParam);
return true;
}
return false;
}
}
}