DarkUI.Net5/DarkUI/Win32/DarkControlScrollFilter.cs

28 lines
814 B
C#

using System.Drawing;
using System.Windows.Forms;
namespace DarkUI
{
public class DarkControlScrollFilter : IMessageFilter
{
public bool PreFilterMessage(ref Message m)
{
switch (m.Msg)
{
case (int)WM.MOUSEWHEEL:
case (int)WM.MOUSEHWHEEL:
var hControlUnderMouse = Native.WindowFromPoint(new Point((int)m.LParam));
if (hControlUnderMouse == m.HWnd)
return false; // Already headed for the right control.
// Redirect the message to the control under the mouse.
Native.SendMessage(hControlUnderMouse, (uint)m.Msg, m.WParam, m.LParam);
return true;
}
return false;
}
}
}