using System;
using System.Runtime.InteropServices;
namespace Hardcodet.Wpf.TaskbarNotification.Interop
{
///
/// Win32 API imports.
///
internal static class WinApi
{
private const string User32 = "user32.dll";
///
/// Creates, updates or deletes the taskbar icon.
///
[DllImport("shell32.Dll", CharSet = CharSet.Unicode)]
public static extern bool Shell_NotifyIcon(NotifyCommand cmd, [In] ref NotifyIconData data);
///
/// Creates the helper window that receives messages from the taskar icon.
///
[DllImport(User32, EntryPoint = "CreateWindowExW", SetLastError = true)]
public static extern IntPtr CreateWindowEx(int dwExStyle, [MarshalAs(UnmanagedType.LPWStr)] string lpClassName,
[MarshalAs(UnmanagedType.LPWStr)] string lpWindowName, int dwStyle, int x, int y,
int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance,
IntPtr lpParam);
///
/// Processes a default windows procedure.
///
[DllImport(User32)]
public static extern IntPtr DefWindowProc(IntPtr hWnd, uint msg, IntPtr wparam, IntPtr lparam);
///
/// Registers the helper window class.
///
[DllImport(User32, EntryPoint = "RegisterClassW", SetLastError = true)]
public static extern short RegisterClass(ref WindowClass lpWndClass);
///
/// Registers a listener for a window message.
///
///
/// uint
[DllImport(User32, EntryPoint = "RegisterWindowMessageW")]
public static extern uint RegisterWindowMessage([MarshalAs(UnmanagedType.LPWStr)] string lpString);
///
/// Used to destroy the hidden helper window that receives messages from the
/// taskbar icon.
///
///
/// bool
[DllImport(User32, SetLastError = true)]
public static extern bool DestroyWindow(IntPtr hWnd);
///
/// Gives focus to a given window.
///
///
/// bool
[DllImport(User32)]
public static extern bool SetForegroundWindow(IntPtr hWnd);
///
/// Gets the maximum number of milliseconds that can elapse between a
/// first click and a second click for the OS to consider the
/// mouse action a double-click.
///
/// The maximum amount of time, in milliseconds, that can
/// elapse between a first click and a second click for the OS to
/// consider the mouse action a double-click.
[DllImport(User32, CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern int GetDoubleClickTime();
///
/// Gets the screen coordinates of the current mouse position.
///
[DllImport(User32, SetLastError = true)]
public static extern bool GetPhysicalCursorPos(ref Point lpPoint);
[DllImport(User32, SetLastError = true)]
public static extern bool GetCursorPos(ref Point lpPoint);
}
}