mirror of
https://github.com/colhountech/DarkUI.Net5.git
synced 2025-07-02 07:09:27 +03:00
ControlScrollFilter can be added to the application's message filter list to re-route all mousewheel events to the control the user is current hovering over with their cursor.
28 lines
810 B
C#
28 lines
810 B
C#
using System.Drawing;
|
|
using System.Windows.Forms;
|
|
|
|
namespace DarkUI
|
|
{
|
|
public class ControlScrollFilter : 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;
|
|
}
|
|
}
|
|
}
|