mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-02 21:20:28 +12:00
Added TopMost option
This commit is contained in:
parent
2228e300c9
commit
d252c9345e
|
@ -27,7 +27,6 @@ private void InitializeComponent()
|
||||||
this.ShowInTaskbar = false;
|
this.ShowInTaskbar = false;
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
||||||
this.Text = "ShareX - Pin to screen";
|
this.Text = "ShareX - Pin to screen";
|
||||||
this.TopMost = true;
|
|
||||||
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.PinToScreenForm_KeyUp);
|
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.PinToScreenForm_KeyUp);
|
||||||
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PinToScreenForm_MouseDown);
|
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PinToScreenForm_MouseDown);
|
||||||
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.PinToScreenForm_MouseUp);
|
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.PinToScreenForm_MouseUp);
|
||||||
|
|
|
@ -114,6 +114,7 @@ private PinToScreenForm(PinToScreenOptions options)
|
||||||
ImageOpacity = Options.InitialOpacity;
|
ImageOpacity = Options.InitialOpacity;
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
TopMost = Options.TopMost;
|
||||||
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true);
|
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint, true);
|
||||||
|
|
||||||
isDWMEnabled = NativeMethods.IsDWMEnabled();
|
isDWMEnabled = NativeMethods.IsDWMEnabled();
|
||||||
|
@ -162,6 +163,7 @@ private void AutoSizeForm()
|
||||||
}
|
}
|
||||||
|
|
||||||
Point newLocation = Location;
|
Point newLocation = Location;
|
||||||
|
SpecialWindowHandles insertAfter = Options.TopMost ? SpecialWindowHandles.HWND_TOPMOST : SpecialWindowHandles.HWND_TOP;
|
||||||
SetWindowPosFlags flags = SetWindowPosFlags.SWP_NOACTIVATE;
|
SetWindowPosFlags flags = SetWindowPosFlags.SWP_NOACTIVATE;
|
||||||
|
|
||||||
if (Options.KeepCenterLocation)
|
if (Options.KeepCenterLocation)
|
||||||
|
@ -174,7 +176,7 @@ private void AutoSizeForm()
|
||||||
flags |= SetWindowPosFlags.SWP_NOMOVE;
|
flags |= SetWindowPosFlags.SWP_NOMOVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
NativeMethods.SetWindowPos(Handle, (IntPtr)SpecialWindowHandles.HWND_TOPMOST, newLocation.X, newLocation.Y, newSize.Width, newSize.Height, flags);
|
NativeMethods.SetWindowPos(Handle, (IntPtr)insertAfter, newLocation.X, newLocation.Y, newSize.Width, newSize.Height, flags);
|
||||||
|
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ public class PinToScreenOptions
|
||||||
public int OpacityStep { get; set; } = 10;
|
public int OpacityStep { get; set; } = 10;
|
||||||
public ContentAlignment Placement { get; set; } = ContentAlignment.BottomRight;
|
public ContentAlignment Placement { get; set; } = ContentAlignment.BottomRight;
|
||||||
public int PlacementOffset { get; set; } = 10;
|
public int PlacementOffset { get; set; } = 10;
|
||||||
|
public bool TopMost { get; set; } = true;
|
||||||
public bool KeepCenterLocation { get; set; } = true;
|
public bool KeepCenterLocation { get; set; } = true;
|
||||||
public bool ShowShadow { get; set; } = true;
|
public bool ShowShadow { get; set; } = true;
|
||||||
public Color BackgroundColor { get; set; } = Color.White;
|
public Color BackgroundColor { get; set; } = Color.White;
|
||||||
|
|
Loading…
Reference in a new issue