-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIconHelper.cs
36 lines (28 loc) · 1.25 KB
/
IconHelper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Interop;
namespace SettingsManager;
public static class IconHelper {
const int GwlExStyle = -20;
const int WsExDlgModalFrame = 0x0001;
const int SwpNoSize = 0x0001;
const int SwpNoMove = 0x0002;
const int SwpNoZOrder = 0x0004;
const int SwpFrameChanged = 0x0020;
[DllImport("user32.dll")]
static extern int GetWindowLong(IntPtr hWnd, int index);
[DllImport("user32.dll")]
static extern int SetWindowLong(IntPtr hWnd, int index, int newStyle);
[DllImport("user32.dll")]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int width, int height, uint flags);
public static void RemoveIcon(Window window) {
// Get this window's handle
IntPtr hWnd = new WindowInteropHelper(window).Handle;
// Change the extended window style to not show a window icon
int extendedStyle = GetWindowLong(hWnd, GwlExStyle);
SetWindowLong(hWnd, GwlExStyle, extendedStyle | WsExDlgModalFrame);
// Update the window's non-client area to reflect the changes
SetWindowPos(hWnd, IntPtr.Zero, 0, 0, 0, 0, SwpNoMove | SwpNoSize | SwpNoZOrder | SwpFrameChanged);
}
}