-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCursorOverlayNativeMethods.cs
More file actions
80 lines (67 loc) · 2.48 KB
/
Copy pathCursorOverlayNativeMethods.cs
File metadata and controls
80 lines (67 loc) · 2.48 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
79
80
using System.Runtime.InteropServices;
namespace SwitchifyPc.Windows.CursorOverlay;
internal static partial class CursorOverlayNativeMethods
{
internal const int WS_EX_LAYERED = 0x00080000;
internal const int WS_EX_TRANSPARENT = 0x00000020;
internal const int WS_EX_TOPMOST = 0x00000008;
internal const int WS_EX_TOOLWINDOW = 0x00000080;
internal const int WS_EX_NOACTIVATE = 0x08000000;
internal const uint SWP_NOSIZE = 0x0001;
internal const uint SWP_NOMOVE = 0x0002;
internal const uint SWP_NOACTIVATE = 0x0010;
internal const uint SWP_SHOWWINDOW = 0x0040;
internal const int ULW_ALPHA = 0x00000002;
internal const byte AC_SRC_OVER = 0x00;
internal const byte AC_SRC_ALPHA = 0x01;
internal static readonly IntPtr HWND_TOPMOST = new(-1);
[StructLayout(LayoutKind.Sequential)]
internal struct Point(int x, int y)
{
internal int X = x;
internal int Y = y;
}
[StructLayout(LayoutKind.Sequential)]
internal struct Size(int cx, int cy)
{
internal int Cx = cx;
internal int Cy = cy;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct BlendFunction
{
internal byte BlendOp;
internal byte BlendFlags;
internal byte SourceConstantAlpha;
internal byte AlphaFormat;
}
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool UpdateLayeredWindow(
IntPtr hWnd,
IntPtr hdcDst,
ref Point pptDst,
ref Size psize,
IntPtr hdcSrc,
ref Point pptSrc,
int crKey,
ref BlendFunction pblend,
int dwFlags);
[DllImport("user32.dll")]
internal static extern IntPtr GetDC(IntPtr hWnd);
[DllImport("user32.dll")]
internal static extern int ReleaseDC(IntPtr hWnd, IntPtr hdc);
[DllImport("gdi32.dll")]
internal static extern IntPtr CreateCompatibleDC(IntPtr hdc);
[DllImport("gdi32.dll")]
internal static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj);
[DllImport("gdi32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool DeleteObject(IntPtr hObject);
[DllImport("gdi32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool DeleteDC(IntPtr hdc);
}