-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclsNativeMethods.cs
More file actions
78 lines (59 loc) · 2.98 KB
/
clsNativeMethods.cs
File metadata and controls
78 lines (59 loc) · 2.98 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using System.Runtime.InteropServices;
namespace AlarmClock;
internal class NativeMethods
{
internal const int WM_NCLBUTTONDOWN = 161;
internal const int HT_CAPTION = 2;
internal const int GWL_EXSTYLE = -20;
internal const int WS_EX_TRANSPARENT = 32;
internal const int WM_HOTKEY = 0x312;
internal const int HOTKEY_ID0 = 0x0311;
internal const int HOTKEY_ID1 = 0x0310;
internal const int SW_SHOWNOACTIVATE = 4;
internal const int WS_EX_TOOLWINDOW = 0x00000080;
//internal const int SW_SHOWNA = 8;
//internal const int SW_SHOWDEFAULT = 10;
//private const int WS_EX_TOPMOST = 0x00000008;
// Konstanten für SetWindowPos
public const int HWND_TOPMOST = -1;
//public const int HWND_NOTOPMOST = -2;
//public const int HWND_TOP = 0; // Für normales "oben" in der Z-Reihenfolge (nicht topmost)
public const uint SWP_NOSIZE = 0x0001;
public const uint SWP_NOMOVE = 0x0002;
public const uint SWP_NOACTIVATE = 0x0010;
//public const uint SWP_NOZORDER = 0x0004; // Behält die aktuelle Z-Reihenfolge bei (ignoriert hWndInsertAfter)
public const uint SWP_SHOWWINDOW = 0x0040;
internal enum Modifiers : uint
{
Control = 0x0002, Shift = 0x0004, Win = 0x0008
}
//public static bool IsTopMost(IntPtr hWnd) => (GetWindowLong(hWnd, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0;
//[DllImport("user32.dll")]
//internal static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
[DllImport("user32.dll")]
internal static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
[DllImport("user32.dll", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);
//[DllImport("user32.dll")]
//[return: MarshalAs(UnmanagedType.Bool)]
//internal static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, uint vk);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool UnregisterHotKey(IntPtr hWnd, int id);
[DllImport("user32.dll")]
internal static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern int SendMessage(nint hWnd, int Msg, int wParam, int lParam);
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern bool ReleaseCapture();
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern int SetWindowLong(nint hWnd, int nIndex, int dwNewLong);
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern int GetWindowLong(nint hWnd, int nIndex);
[DllImport("powrprof.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool SetSuspendState(bool hibernate, bool forceCritical, bool disableWakeEvent);
}