using System;
using System.Runtime.InteropServices;
namespace Vanara.PInvoke
{
public static partial class User32
{
/// The state of the other mouse buttons plus the SHIFT and CTRL keys.
[PInvokeData("winuser.h")]
[Flags]
public enum MouseButtonState
{
/// The left mouse button is down.
MK_LBUTTON = 0x0001,
/// The right mouse button is down.
MK_RBUTTON = 0x0002,
/// The SHIFT key is down.
MK_SHIFT = 0x0004,
/// The CTRL key is down.
MK_CONTROL = 0x0008,
/// The middle mouse button is down.
MK_MBUTTON = 0x0010,
/// The XBUTTON1 button is down.
MK_XBUTTON1 = 0x0020,
/// The XBUTTON2 button is down.
MK_XBUTTON2 = 0x0040,
}
/// The services requested in a structure.
[Flags]
public enum TME : uint
{
///
/// The caller wants to cancel a prior tracking request. The caller should also specify the type of tracking that it wants to
/// cancel. For example, to cancel hover tracking, the caller must pass the TME_CANCEL and TME_HOVER flags.
///
TME_CANCEL = 0x80000000,
///
/// The caller wants hover notification. Notification is delivered as a WM_MOUSEHOVER message.
/// If the caller requests hover tracking while hover tracking is already active, the hover timer will be reset.
/// This flag is ignored if the mouse pointer is not over the specified window or area.
///
TME_HOVER = 0x00000001,
///
/// The caller wants leave notification. Notification is delivered as a WM_MOUSELEAVE message. If the mouse is not over the
/// specified window or area, a leave notification is generated immediately and no further tracking is performed.
///
TME_LEAVE = 0x00000002,
///
/// The caller wants hover and leave notification for the nonclient areas. Notification is delivered as WM_NCMOUSEHOVER and
/// WM_NCMOUSELEAVE messages.
///
TME_NONCLIENT = 0x00000010,
///
/// The function fills in the structure instead of treating it as a tracking request. The structure is filled such that had that
/// structure been passed to TrackMouseEvent, it would generate the current tracking. The only anomaly is that the hover time-out
/// returned is always the actual time-out and not HOVER_DEFAULT, if HOVER_DEFAULT was specified during the original
/// TrackMouseEvent request.
///
TME_QUERY = 0x40000000,
}
/// Posts messages when the mouse pointer leaves a window or hovers over a window for a specified amount of time.
///
/// Type: LPTRACKMOUSEEVENT
/// A pointer to a TRACKMOUSEEVENT structure that contains tracking information.
///
///
/// Type: BOOL
/// If the function succeeds, the return value is nonzero .
/// If the function fails, return value is zero. To get extended error information, call GetLastError.
///
// BOOL WINAPI TrackMouseEvent( _Inout_ LPTRACKMOUSEEVENT lpEventTrack); https://msdn.microsoft.com/en-us/library/windows/desktop/ms646265(v=vs.85).aspx
[DllImport(Lib.User32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("Winuser.h", MSDNShortId = "ms646265")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool TrackMouseEvent(ref TRACKMOUSEEVENT lpEventTrack);
///
/// Used by the TrackMouseEvent function to track when the mouse pointer leaves a window or hovers over a window for a specified
/// amount of time.
///
[PInvokeData("Winuser.h", MSDNShortId = "ms645604")]
[StructLayout(LayoutKind.Sequential)]
public struct TRACKMOUSEEVENT
{
/// The size of the TRACKMOUSEEVENT structure, in bytes.
public uint cbSize;
/// The services requested
public TME dwFlags;
/// A handle to the window to track.
public HWND hwndTrack;
///
/// The hover time-out (if TME_HOVER was specified in dwFlags), in milliseconds. Can be HOVER_DEFAULT, which means to use the
/// system default hover time-out.
///
public uint dwHoverTime;
}
}
}