public static extern bool TrackMouseEvent([In, Out] TRACKMOUSEEVENT lpEventTrack); [DllImport("User32.dll", CharSet = CharSet.Auto)] [StructLayout(LayoutKind.Sequential)] public class TRACKMOUSEEVENT { public uint cbSize; public uint dwFlags; public IntPtr hwndTrack; public uint dwHoverTime; }
以上是用到的API和结构体
1、写一个方法用来处理TrackMouseEvent
2、 WndProc 处理消息 WM_NCMOUSEMOVE
3、处理WM_NCMOUSELEAVE
完成,这个消息就可以获取到啦!
WM_MOUSELEAVE 类似