mirror of
https://github.com/ckaczor/wpf-notifyicon.git
synced 2026-01-18 01:35:38 -05:00
Code modernising (#8)
* Applied some code conventions, used more current language features which should improve readability and making it easier to re-factor / modify. Also fixed some typos in documentation. * Changes based on PR conversation for the SystemInfo * Some modifications due to conversations on the PR, especially I removed the FlagsAttribute on the BalloonFlags. * Removed Silverlight targeting in code.
This commit is contained in:
@@ -8,6 +8,8 @@ namespace Hardcodet.Wpf.TaskbarNotification.Interop
|
||||
/// </summary>
|
||||
internal static class WinApi
|
||||
{
|
||||
private const string User32 = "user32.dll";
|
||||
|
||||
/// <summary>
|
||||
/// Creates, updates or deletes the taskbar icon.
|
||||
/// </summary>
|
||||
@@ -18,7 +20,7 @@ namespace Hardcodet.Wpf.TaskbarNotification.Interop
|
||||
/// <summary>
|
||||
/// Creates the helper window that receives messages from the taskar icon.
|
||||
/// </summary>
|
||||
[DllImport("USER32.DLL", EntryPoint = "CreateWindowExW", SetLastError = true)]
|
||||
[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,
|
||||
@@ -28,21 +30,21 @@ namespace Hardcodet.Wpf.TaskbarNotification.Interop
|
||||
/// <summary>
|
||||
/// Processes a default windows procedure.
|
||||
/// </summary>
|
||||
[DllImport("USER32.DLL")]
|
||||
[DllImport(User32)]
|
||||
public static extern IntPtr DefWindowProc(IntPtr hWnd, uint msg, IntPtr wparam, IntPtr lparam);
|
||||
|
||||
/// <summary>
|
||||
/// Registers the helper window class.
|
||||
/// </summary>
|
||||
[DllImport("USER32.DLL", EntryPoint = "RegisterClassW", SetLastError = true)]
|
||||
[DllImport(User32, EntryPoint = "RegisterClassW", SetLastError = true)]
|
||||
public static extern short RegisterClass(ref WindowClass lpWndClass);
|
||||
|
||||
/// <summary>
|
||||
/// Registers a listener for a window message.
|
||||
/// </summary>
|
||||
/// <param name="lpString"></param>
|
||||
/// <returns></returns>
|
||||
[DllImport("User32.Dll", EntryPoint = "RegisterWindowMessageW")]
|
||||
/// <returns>uint</returns>
|
||||
[DllImport(User32, EntryPoint = "RegisterWindowMessageW")]
|
||||
public static extern uint RegisterWindowMessage([MarshalAs(UnmanagedType.LPWStr)] string lpString);
|
||||
|
||||
/// <summary>
|
||||
@@ -50,8 +52,8 @@ namespace Hardcodet.Wpf.TaskbarNotification.Interop
|
||||
/// taskbar icon.
|
||||
/// </summary>
|
||||
/// <param name="hWnd"></param>
|
||||
/// <returns></returns>
|
||||
[DllImport("USER32.DLL", SetLastError = true)]
|
||||
/// <returns>bool</returns>
|
||||
[DllImport(User32, SetLastError = true)]
|
||||
public static extern bool DestroyWindow(IntPtr hWnd);
|
||||
|
||||
|
||||
@@ -59,8 +61,8 @@ namespace Hardcodet.Wpf.TaskbarNotification.Interop
|
||||
/// Gives focus to a given window.
|
||||
/// </summary>
|
||||
/// <param name="hWnd"></param>
|
||||
/// <returns></returns>
|
||||
[DllImport("USER32.DLL")]
|
||||
/// <returns>bool</returns>
|
||||
[DllImport(User32)]
|
||||
public static extern bool SetForegroundWindow(IntPtr hWnd);
|
||||
|
||||
|
||||
@@ -72,18 +74,18 @@ namespace Hardcodet.Wpf.TaskbarNotification.Interop
|
||||
/// <returns>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.</returns>
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
|
||||
[DllImport(User32, CharSet = CharSet.Auto, ExactSpelling = true)]
|
||||
public static extern int GetDoubleClickTime();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the screen coordinates of the current mouse position.
|
||||
/// </summary>
|
||||
[DllImport("USER32.DLL", SetLastError = true)]
|
||||
[DllImport(User32, SetLastError = true)]
|
||||
public static extern bool GetPhysicalCursorPos(ref Point lpPoint);
|
||||
|
||||
|
||||
[DllImport("USER32.DLL", SetLastError = true)]
|
||||
[DllImport(User32, SetLastError = true)]
|
||||
public static extern bool GetCursorPos(ref Point lpPoint);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user