mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-28 23:42:13 +12:00
Use const instead of enum
This commit is contained in:
parent
6fd4db7e35
commit
2f07fba591
5 changed files with 31 additions and 33 deletions
|
@ -27,6 +27,27 @@ namespace ShareX.HelpersLib
|
|||
{
|
||||
public static class NativeConstants
|
||||
{
|
||||
/// <summary>
|
||||
/// Places the window at the top of the Z order.
|
||||
/// </summary>
|
||||
public const int HWND_TOP = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Places the window at the bottom of the Z order.
|
||||
/// If the hWnd parameter identifies a topmost window, the window loses its topmost status and is placed at the bottom of all other windows.
|
||||
/// </summary>
|
||||
public const int HWND_BOTTOM = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Places the window above all non-topmost windows. The window maintains its topmost position even when it is deactivated.
|
||||
/// </summary>
|
||||
public const int HWND_TOPMOST = -1;
|
||||
|
||||
/// <summary>
|
||||
/// Places the window above all non-topmost windows (that is, behind all topmost windows). This flag has no effect if the window is already a non-topmost window.
|
||||
/// </summary>
|
||||
public const int HWND_NOTOPMOST = -2;
|
||||
|
||||
public const int GWL_WNDPROC = -4;
|
||||
public const int GWL_HINSTANCE = -6;
|
||||
public const int GWL_HWNDPARENT = -8;
|
||||
|
|
|
@ -1912,29 +1912,6 @@ public enum OpenFileMode
|
|||
Reopen = 0x00008000
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Special window handles
|
||||
/// </summary>
|
||||
public enum SpecialWindowHandles
|
||||
{
|
||||
/// <summary>
|
||||
/// Places the window at the bottom of the Z order. If the hWnd parameter identifies a topmost window, the window loses its topmost status and is placed at the bottom of all other windows.
|
||||
/// </summary>
|
||||
HWND_TOP = 0,
|
||||
/// <summary>
|
||||
/// Places the window above all non-topmost windows (that is, behind all topmost windows). This flag has no effect if the window is already a non-topmost window.
|
||||
/// </summary>
|
||||
HWND_BOTTOM = 1,
|
||||
/// <summary>
|
||||
/// Places the window at the top of the Z order.
|
||||
/// </summary>
|
||||
HWND_TOPMOST = -1,
|
||||
/// <summary>
|
||||
/// Places the window above all non-topmost windows. The window maintains its topmost position even when it is deactivated.
|
||||
/// </summary>
|
||||
HWND_NOTOPMOST = -2
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum SetWindowPosFlags : uint
|
||||
{
|
||||
|
|
|
@ -114,7 +114,7 @@ public bool TopMost
|
|||
}
|
||||
set
|
||||
{
|
||||
SetWindowPos(value ? SpecialWindowHandles.HWND_TOPMOST : SpecialWindowHandles.HWND_NOTOPMOST,
|
||||
SetWindowPos(value ? (IntPtr)NativeConstants.HWND_TOPMOST : (IntPtr)NativeConstants.HWND_NOTOPMOST,
|
||||
SetWindowPosFlags.SWP_NOMOVE | SetWindowPosFlags.SWP_NOSIZE);
|
||||
}
|
||||
}
|
||||
|
@ -162,22 +162,22 @@ public void Restore()
|
|||
|
||||
public void SetWindowPos(SetWindowPosFlags flags)
|
||||
{
|
||||
SetWindowPos(SpecialWindowHandles.HWND_TOP, 0, 0, 0, 0, flags);
|
||||
SetWindowPos((IntPtr)NativeConstants.HWND_TOP, 0, 0, 0, 0, flags);
|
||||
}
|
||||
|
||||
public void SetWindowPos(Rectangle rect, SetWindowPosFlags flags)
|
||||
{
|
||||
SetWindowPos(SpecialWindowHandles.HWND_TOP, rect.X, rect.Y, rect.Width, rect.Height, flags);
|
||||
SetWindowPos((IntPtr)NativeConstants.HWND_TOP, rect.X, rect.Y, rect.Width, rect.Height, flags);
|
||||
}
|
||||
|
||||
public void SetWindowPos(SpecialWindowHandles specialWindowHandles, SetWindowPosFlags flags)
|
||||
public void SetWindowPos(IntPtr insertAfter, SetWindowPosFlags flags)
|
||||
{
|
||||
SetWindowPos(specialWindowHandles, 0, 0, 0, 0, flags);
|
||||
SetWindowPos(insertAfter, 0, 0, 0, 0, flags);
|
||||
}
|
||||
|
||||
public void SetWindowPos(SpecialWindowHandles specialWindowHandles, int x, int y, int width, int height, SetWindowPosFlags flags)
|
||||
public void SetWindowPos(IntPtr insertAfter, int x, int y, int width, int height, SetWindowPosFlags flags)
|
||||
{
|
||||
NativeMethods.SetWindowPos(Handle, (IntPtr)specialWindowHandles, x, y, width, height, flags);
|
||||
NativeMethods.SetWindowPos(Handle, insertAfter, x, y, width, height, flags);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
|
|
@ -138,7 +138,7 @@ public void LoadConfig(NotificationFormConfig config)
|
|||
|
||||
Point position = Helpers.GetPosition(Config.Placement, Config.Offset, Screen.PrimaryScreen.WorkingArea, Config.Size);
|
||||
|
||||
NativeMethods.SetWindowPos(Handle, (IntPtr)SpecialWindowHandles.HWND_TOPMOST, position.X, position.Y, Config.Size.Width, Config.Size.Height,
|
||||
NativeMethods.SetWindowPos(Handle, (IntPtr)NativeConstants.HWND_TOPMOST, position.X, position.Y, Config.Size.Width, Config.Size.Height,
|
||||
SetWindowPosFlags.SWP_NOACTIVATE);
|
||||
|
||||
tDuration.Stop();
|
||||
|
|
|
@ -250,7 +250,7 @@ private void AutoSizeForm()
|
|||
Size newSize = FormSize;
|
||||
|
||||
Point newLocation = Location;
|
||||
SpecialWindowHandles insertAfter = Options.TopMost ? SpecialWindowHandles.HWND_TOPMOST : SpecialWindowHandles.HWND_TOP;
|
||||
IntPtr insertAfter = Options.TopMost ? (IntPtr)NativeConstants.HWND_TOPMOST : (IntPtr)NativeConstants.HWND_TOP;
|
||||
SetWindowPosFlags flags = SetWindowPosFlags.SWP_NOACTIVATE | SetWindowPosFlags.SWP_NOSENDCHANGING;
|
||||
|
||||
if (Options.KeepCenterLocation)
|
||||
|
@ -263,7 +263,7 @@ private void AutoSizeForm()
|
|||
flags |= SetWindowPosFlags.SWP_NOMOVE;
|
||||
}
|
||||
|
||||
NativeMethods.SetWindowPos(Handle, (IntPtr)insertAfter, newLocation.X, newLocation.Y, newSize.Width, newSize.Height, flags);
|
||||
NativeMethods.SetWindowPos(Handle, insertAfter, newLocation.X, newLocation.Y, newSize.Width, newSize.Height, flags);
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue