diff --git a/ShareX.HelpersLib/Native/NativeConstants.cs b/ShareX.HelpersLib/Native/NativeConstants.cs
index 883225893..9b48e04c7 100644
--- a/ShareX.HelpersLib/Native/NativeConstants.cs
+++ b/ShareX.HelpersLib/Native/NativeConstants.cs
@@ -27,6 +27,27 @@ namespace ShareX.HelpersLib
{
public static class NativeConstants
{
+ ///
+ /// Places the window at the top of the Z order.
+ ///
+ public const int HWND_TOP = 0;
+
+ ///
+ /// 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.
+ ///
+ public const int HWND_BOTTOM = 1;
+
+ ///
+ /// Places the window above all non-topmost windows. The window maintains its topmost position even when it is deactivated.
+ ///
+ public const int HWND_TOPMOST = -1;
+
+ ///
+ /// 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.
+ ///
+ public const int HWND_NOTOPMOST = -2;
+
public const int GWL_WNDPROC = -4;
public const int GWL_HINSTANCE = -6;
public const int GWL_HWNDPARENT = -8;
diff --git a/ShareX.HelpersLib/Native/NativeEnums.cs b/ShareX.HelpersLib/Native/NativeEnums.cs
index 69402acce..fed0db5d4 100644
--- a/ShareX.HelpersLib/Native/NativeEnums.cs
+++ b/ShareX.HelpersLib/Native/NativeEnums.cs
@@ -1912,29 +1912,6 @@ public enum OpenFileMode
Reopen = 0x00008000
}
- ///
- /// Special window handles
- ///
- public enum SpecialWindowHandles
- {
- ///
- /// 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.
- ///
- HWND_TOP = 0,
- ///
- /// 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.
- ///
- HWND_BOTTOM = 1,
- ///
- /// Places the window at the top of the Z order.
- ///
- HWND_TOPMOST = -1,
- ///
- /// Places the window above all non-topmost windows. The window maintains its topmost position even when it is deactivated.
- ///
- HWND_NOTOPMOST = -2
- }
-
[Flags]
public enum SetWindowPosFlags : uint
{
diff --git a/ShareX.HelpersLib/Native/WindowInfo.cs b/ShareX.HelpersLib/Native/WindowInfo.cs
index adf127df6..fe1cf0554 100644
--- a/ShareX.HelpersLib/Native/WindowInfo.cs
+++ b/ShareX.HelpersLib/Native/WindowInfo.cs
@@ -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()
diff --git a/ShareX/Forms/NotificationForm.cs b/ShareX/Forms/NotificationForm.cs
index 32bd0d24e..07b201502 100644
--- a/ShareX/Forms/NotificationForm.cs
+++ b/ShareX/Forms/NotificationForm.cs
@@ -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();
diff --git a/ShareX/Tools/PinToScreen/PinToScreenForm.cs b/ShareX/Tools/PinToScreen/PinToScreenForm.cs
index 19f2aadc0..0f20d390d 100644
--- a/ShareX/Tools/PinToScreen/PinToScreenForm.cs
+++ b/ShareX/Tools/PinToScreen/PinToScreenForm.cs
@@ -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();
}