Hide window from task switcher
This commit is contained in:
@@ -3,14 +3,22 @@
|
|||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:controls="using:NotificationFlyout.Uwp.UI.Controls">
|
xmlns:controls="using:NotificationFlyout.Uwp.UI.Controls">
|
||||||
<Grid
|
<StackPanel
|
||||||
Width="330"
|
Width="330"
|
||||||
Height="360"
|
Height="500"
|
||||||
Margin="24">
|
Margin="24">
|
||||||
<ComboBox x:Name="test" Margin="0,0,0,8" SelectionChanged="test_SelectionChanged">
|
<ComboBox
|
||||||
|
x:Name="test"
|
||||||
|
Margin="0,0,0,8"
|
||||||
|
SelectionChanged="test_SelectionChanged">
|
||||||
<ComboBoxItem>System</ComboBoxItem>
|
<ComboBoxItem>System</ComboBoxItem>
|
||||||
<ComboBoxItem>Dark</ComboBoxItem>
|
<ComboBoxItem>Dark</ComboBoxItem>
|
||||||
<ComboBoxItem>Light</ComboBoxItem>
|
<ComboBoxItem>Light</ComboBoxItem>
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
</Grid>
|
<Button Margin="0,0,0,8" Content="Button" />
|
||||||
|
<Slider Margin="0,0,0,8" />
|
||||||
|
<TextBox Margin="0,0,0,8" />
|
||||||
|
<ToggleButton Margin="0,0,0,8" />
|
||||||
|
<CalendarView Margin="0,0,0,8" />
|
||||||
|
</StackPanel>
|
||||||
</controls:NotificationFlyoutPresenter>
|
</controls:NotificationFlyoutPresenter>
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ namespace NotificationFlyout.Wpf.UI.Controls
|
|||||||
|
|
||||||
UpdateWindow();
|
UpdateWindow();
|
||||||
UpdateIcon();
|
UpdateIcon();
|
||||||
|
this.Hidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnTaskbarChanged(object sender, EventArgs args)
|
private void OnTaskbarChanged(object sender, EventArgs args)
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ namespace NotificationFlyout.Wpf.UI.Extensions
|
|||||||
{
|
{
|
||||||
public static class WindowExtensions
|
public static class WindowExtensions
|
||||||
{
|
{
|
||||||
|
private const int GWL_EX_STYLE = -20;
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
private enum WindowFlag : uint
|
private enum WindowFlag : uint
|
||||||
{
|
{
|
||||||
@@ -15,17 +17,9 @@ namespace NotificationFlyout.Wpf.UI.Extensions
|
|||||||
SWP_NOZORDER = 0x0004,
|
SWP_NOZORDER = 0x0004,
|
||||||
SWP_NOACTIVATE = 0x0010,
|
SWP_NOACTIVATE = 0x0010,
|
||||||
WS_EX_NOACTIVATE = 0x08000000,
|
WS_EX_NOACTIVATE = 0x08000000,
|
||||||
SWP_SHOWWINDOW = 0x0040
|
SWP_SHOWWINDOW = 0x0040,
|
||||||
}
|
WS_EX_APPWINDOW = 0x00040000,
|
||||||
|
WS_EX_TOOLWINDOW = 0x00000080
|
||||||
public static void SetWindowPosition(this Window window, double top, double left, double height, double width)
|
|
||||||
{
|
|
||||||
PInvoke.SetWindowPos((HWND)window.GetHandle(), (HWND)IntPtr.Zero, (int)left, (int)top, (int)width, (int)height, (uint)WindowFlag.SWP_NOSIZE | (uint)WindowFlag.SWP_NOZORDER | (uint)WindowFlag.SWP_NOACTIVATE);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void SetTopAll(this Window window)
|
|
||||||
{
|
|
||||||
PInvoke.SetWindowPos((HWND)window.GetHandle(), (HWND)new IntPtr(-1), 0, 0, 0, 0, (uint)WindowFlag.SWP_NOMOVE | (uint)WindowFlag.SWP_NOSIZE | (uint)WindowFlag.WS_EX_NOACTIVATE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IntPtr GetHandle(this Window window)
|
public static IntPtr GetHandle(this Window window)
|
||||||
@@ -33,5 +27,21 @@ namespace NotificationFlyout.Wpf.UI.Extensions
|
|||||||
var helper = new WindowInteropHelper(window);
|
var helper = new WindowInteropHelper(window);
|
||||||
return helper.Handle;
|
return helper.Handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Hidden(this Window window)
|
||||||
|
{
|
||||||
|
var handle = window.GetHandle();
|
||||||
|
PInvoke.SetWindowLong((HWND)handle, GWL_EX_STYLE, (PInvoke.GetWindowLong((HWND)handle, GWL_EX_STYLE) | (int)WindowFlag.WS_EX_TOOLWINDOW) & ~(int)WindowFlag.WS_EX_APPWINDOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetTopAll(this Window window)
|
||||||
|
{
|
||||||
|
PInvoke.SetWindowPos((HWND)window.GetHandle(), (HWND)new IntPtr(-1), 0, 0, 0, 0, (uint)WindowFlag.SWP_NOMOVE | (uint)WindowFlag.SWP_NOSIZE | (uint)WindowFlag.WS_EX_NOACTIVATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetWindowPosition(this Window window, double top, double left, double height, double width)
|
||||||
|
{
|
||||||
|
PInvoke.SetWindowPos((HWND)window.GetHandle(), (HWND)IntPtr.Zero, (int)left, (int)top, (int)width, (int)height, (uint)WindowFlag.SWP_NOSIZE | (uint)WindowFlag.SWP_NOZORDER | (uint)WindowFlag.SWP_NOACTIVATE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,3 +9,5 @@ RegisterWindowMessage
|
|||||||
FindWindow
|
FindWindow
|
||||||
SHAppBarMessage
|
SHAppBarMessage
|
||||||
SetWindowPos
|
SetWindowPos
|
||||||
|
GetWindowLong
|
||||||
|
SetWindowLong
|
||||||
Reference in New Issue
Block a user