-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHwnd.cs
648 lines (544 loc) · 21.8 KB
/
Hwnd.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
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
using System;
using System.Runtime.InteropServices;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Media;
using Projzo.Model;
using Windows.Foundation;
namespace Projzo.Interop
{
public enum ShowWindowCommands : int
{
SW_HIDE = 0,
SW_SHOWNORMAL = 1,
SW_NORMAL = 1,
SW_SHOWMINIMIZED = 2,
SW_SHOWMAXIMIZED = 3,
SW_MAXIMIZE = 3,
SW_SHOWNOACTIVATE = 4,
SW_SHOW = 5,
SW_MINIMIZE = 6,
SW_SHOWMINNOACTIVE = 7,
SW_SHOWNA = 8,
SW_RESTORE = 9,
SW_SHOWDEFAULT = 10,
SW_FORCEMINIMIZE = 11,
SW_MAX = 11
}
public enum WindowMessage : uint
{
WM_USER = 0x400,
WM_CTLCOLORSTATIC = 0x0138,
WM_SYSCOMMAND = 0x0112,
WM_MOVE = 0x0003,
WM_SIZE = 0x0005
}
public class Hwnd
{
private static WndProcDelegate _currDelegate;
[DllImport("Kernel32.dll")]
public static extern uint GetLastError();
[DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);
[DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern bool GetClientRect(IntPtr hWnd, out RECT lpRect);
[DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
public const int SWP_NOSIZE = 0x0001;
public const int SWP_NOMOVE = 0x0002;
public const int SWP_NOZORDER = 0x0004;
public const int SWP_NOREDRAW = 0x0008;
public const int SWP_NOACTIVATE = 0x0010;
public const int SWP_FRAMECHANGED = 0x0020; /* The frame changed: send WM_NCCALCSIZE */
public const int SWP_SHOWWINDOW = 0x0040;
public const int SWP_HIDEWINDOW = 0x0080;
public const int SWP_NOCOPYBITS = 0x0100;
public const int SWP_NOOWNERZORDER = 0x0200; /* Don't do owner Z ordering */
public const int SWP_NOSENDCHANGING = 0x0400; /* Don't send WM_WINDOWPOSCHANGING */
public const int SWP_DRAWFRAME = SWP_FRAMECHANGED;
public const int SWP_NOREPOSITION = SWP_NOOWNERZORDER;
public const int SWP_DEFERERASE = 0x2000;
public const int SWP_ASYNCWINDOWPOS = 0x4000;
public static readonly IntPtr HWND_BOTTOM = (IntPtr)1;
public static readonly IntPtr HWND_NOTOPMOST = (IntPtr)(-2);
public static readonly IntPtr HWND_TOP = IntPtr.Zero;
public static readonly IntPtr HWND_TOPMOST = (IntPtr)(-1);
[DllImport("User32.dll", SetLastError = true)]
public static extern UInt16 RegisterClassW([In] ref WNDCLASS lpWndClass);
[DllImport("User32.dll", SetLastError = true)]
public static extern IntPtr CreateWindowExW(int dwExStyle,
[MarshalAs(UnmanagedType.LPWStr)]
string lpClassName,
[MarshalAs(UnmanagedType.LPWStr)]
string lpWindowName,
int dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, IntPtr lpParam);
public const int CS_VREDRAW = 0x0001,
CS_HREDRAW = 0x0002;
public const int WS_OVERLAPPED = 0x00000000,
WS_POPUP = unchecked((int)0x80000000),
WS_CHILD = 0x40000000,
WS_MINIMIZE = 0x20000000,
WS_VISIBLE = 0x10000000,
WS_DISABLED = 0x08000000,
WS_CLIPSIBLINGS = 0x04000000,
WS_CLIPCHILDREN = 0x02000000,
WS_MAXIMIZE = 0x01000000,
WS_CAPTION = 0x00C00000,
WS_BORDER = 0x00800000,
WS_DLGFRAME = 0x00400000,
WS_VSCROLL = 0x00200000,
WS_HSCROLL = 0x00100000,
WS_SYSMENU = 0x00080000,
WS_THICKFRAME = 0x00040000,
WS_TABSTOP = 0x00010000,
WS_MINIMIZEBOX = 0x00020000,
WS_MAXIMIZEBOX = 0x00010000,
WS_OVERLAPPEDWINDOW = WS_OVERLAPPED |
WS_CAPTION |
WS_SYSMENU |
WS_THICKFRAME |
WS_MINIMIZEBOX |
WS_MAXIMIZEBOX;
public const int WS_EX_DLGMODALFRAME = 0x00000001;
public const int WS_EX_NOPARENTNOTIFY = 0x00000004;
public const int WS_EX_TOPMOST = 0x00000008;
public const int WS_EX_ACCEPTFILES = 0x00000010;
public const int WS_EX_TRANSPARENT = 0x00000020;
public const int WS_EX_MDICHILD = 0x00000040;
public const int WS_EX_TOOLWINDOW = 0x00000080;
public const int WS_EX_WINDOWEDGE = 0x00000100;
public const int WS_EX_CLIENTEDGE = 0x00000200;
public const int WS_EX_CONTEXTHELP = 0x00000400;
public const int WS_EX_RIGHT = 0x00001000;
public const int WS_EX_LEFT = 0x00000000;
public const int WS_EX_RTLREADING = 0x00002000;
public const int WS_EX_LTRREADING = 0x00000000;
public const int WS_EX_LEFTSCROLLBAR = 0x00004000;
public const int WS_EX_RIGHTSCROLLBAR = 0x00000000;
public const int WS_EX_CONTROLPARENT = 0x00010000;
public const int WS_EX_STATICEDGE = 0x00020000;
public const int WS_EX_APPWINDOW = 0x00040000;
public const int WS_EX_OVERLAPPEDWINDOW = (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE);
public const int WS_EX_PALETTEWINDOW = (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST);
public const int WS_EX_LAYERED = 0x00080000;
public const int WS_EX_NOINHERITLAYOUT = 0x00100000; // Disable inheritence of mirroring by children
public const int WS_EX_NOREDIRECTIONBITMAP = 0x00200000;
public const int WS_EX_LAYOUTRTL = 0x00400000; // Right to left mirroring
public const int WS_EX_COMPOSITED = 0x02000000;
public const int WS_EX_NOACTIVATE = 0x08000000;
[DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern bool MoveWindow(IntPtr hWnd, int x, int y, int cx, int cy, bool repaint);
[DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern bool ShowWindow(IntPtr hWnd, int nShowCmd);
public const uint LWA_COLORKEY = 0x00000001;
public const uint LWA_ALPHA = 0x00000002;
[DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern bool SetLayeredWindowAttributes(IntPtr hwnd, uint crKey, byte bAlpha, uint dwFlags);
[DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndParent);
const int GWL_STYLE = (-16);
const int GWL_EXSTYLE = (-20);
public const int GWL_WNDPROC = (-4);
public static IntPtr SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong)
{
if (IntPtr.Size == 4)
{
return SetWindowLongPtr32(hWnd, nIndex, dwNewLong);
}
return SetWindowLongPtr64(hWnd, nIndex, dwNewLong);
}
[DllImport("User32.dll", CharSet = CharSet.Auto, EntryPoint = "SetWindowLong")]
public static extern IntPtr SetWindowLongPtr32(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
[DllImport("User32.dll", CharSet = CharSet.Auto, EntryPoint = "SetWindowLongPtr")]
public static extern IntPtr SetWindowLongPtr64(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
public static IntPtr SetClassLong(HandleRef hWnd, int nIndex, IntPtr dwNewLong)
{
if (IntPtr.Size > 4)
return SetClassLongPtr64(hWnd, nIndex, dwNewLong);
else
return new IntPtr(SetClassLongPtr32(hWnd, nIndex, unchecked((uint)dwNewLong.ToInt32())));
}
[DllImport("user32.dll", EntryPoint = "SetClassLong")]
public static extern uint SetClassLongPtr32(HandleRef hWnd, int nIndex, uint dwNewLong);
[DllImport("user32.dll", EntryPoint = "SetClassLongPtr")]
public static extern IntPtr SetClassLongPtr64(HandleRef hWnd, int nIndex, IntPtr dwNewLong);
// public static IntPtr GetWindowLong(HandleRef hWnd, int nIndex)
public static long GetWindowLong(IntPtr hWnd, int nIndex)
{
if (IntPtr.Size == 4)
{
return GetWindowLong32(hWnd, nIndex);
}
return GetWindowLongPtr64(hWnd, nIndex);
}
[DllImport("User32.dll", EntryPoint = "GetWindowLong", CharSet = CharSet.Auto)]
public static extern long GetWindowLong32(IntPtr hWnd, int nIndex);
[DllImport("User32.dll", EntryPoint = "GetWindowLongPtr", CharSet = CharSet.Auto)]
public static extern long GetWindowLongPtr64(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
public static extern IntPtr DefWindowProc(IntPtr hWnd, uint uMsg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr CallWindowProc(IntPtr lpPrevWndFunc, IntPtr hwnd, uint msg, IntPtr wParam, IntPtr lParam);
private const int GWLP_WNDPROC = -4;
public delegate IntPtr WndProcDelegate(IntPtr hwnd, uint message, IntPtr wParam, IntPtr lParam);
public static IntPtr SetWndProc(IntPtr hwnd, WndProcDelegate newProc)
{
//we assign to static variable so that garbage collector won't remove this instance of newProc
//Reference: https://www.travelneil.com/wndproc-in-uwp.html
_currDelegate = newProc;
IntPtr functionPointer = Marshal.GetFunctionPointerForDelegate(newProc);
return SetWindowLong(hwnd, GWLP_WNDPROC, functionPointer);
}
public static IntPtr SetWndProc(Window window, WndProcDelegate newProc)
{
//we assign to static variable so that garbage collector won't remove this instance of newProc
//Reference: https://www.travelneil.com/wndproc-in-uwp.html
_currDelegate = newProc;
IntPtr hwnd = WinRT.Interop.WindowNative.GetWindowHandle(window);
IntPtr functionPointer = Marshal.GetFunctionPointerForDelegate(newProc);
return SetWindowLong(hwnd, GWLP_WNDPROC, functionPointer);
}
public static IntPtr SetWndProc(Window window, IntPtr newProc)
{
_currDelegate = null;
IntPtr hwnd = WinRT.Interop.WindowNative.GetWindowHandle(window);
return SetWindowLong(hwnd, GWLP_WNDPROC, newProc);
}
[DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern bool GetCursorPos(out POINT point);
public static Point GetCursorPosByWindow(IntPtr hWnd)
{
POINT cursorPos;
Hwnd.GetCursorPos(out cursorPos);
Hwnd.ScreenToClient(hWnd, ref cursorPos);
Point pt = Dpi.UnscalePoint(new Windows.Foundation.Point(cursorPos.x, cursorPos.y));
return pt;
}
//hWndBase - The main window containing this element
public static Point GetCursorPosByFrameworkElement(FrameworkElement element, IntPtr hWndBase)
{
if (hWndBase == IntPtr.Zero) return new Point(0, 0);
Point wndPt = GetCursorPosByWindow(hWndBase);
GeneralTransform transform = element.TransformToVisual(null);
Rect rect = transform.TransformBounds(new Rect(0, 0, element.ActualWidth, element.ActualHeight));
return new Point(wndPt.X - rect.Left, wndPt.Y - rect.Top);
}
[DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern bool ScreenToClient(IntPtr hwnd, ref POINT point);
public const int CCHILDREN_TITLEBAR = 5;
[DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern bool GetTitleBarInfo(IntPtr hwnd, ref TITLEBARINFO ti);
[DllImport("user32.dll", EntryPoint = "SendMessage", CharSet = CharSet.Auto)]
public static extern IntPtr SendMessageCopyData(IntPtr hWnd, uint Msg, IntPtr wParam, ref COPYDATASTRUCT cds);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
public static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool IsWindow(IntPtr hWnd);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool IsWindowVisible(IntPtr hWnd);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool IsZoomed(IntPtr hWnd);
public const int SC_MINIMIZE = 0xF020;
public const int SC_MAXIMIZE = 0xF030;
}
[StructLayout(LayoutKind.Sequential)]
public struct TITLEBARINFO
{
public uint cbSize;
public RECT rcTitleBar;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = Hwnd.CCHILDREN_TITLEBAR + 1)]
public uint[] rgState;
}
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int left;
public int top;
public int right;
public int bottom;
public RECT(int Left, int Top, int Right, int Bottom)
{
left = Left;
top = Top;
right = Right;
bottom = Bottom;
}
}
// Defines the x- and y-coordinates of a point
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct POINT
{
public POINT(int x, int y)
{
this.x = x;
this.y = y;
}
public int x;
public int y;
}
[StructLayout(LayoutKind.Sequential)]
public struct SIZE
{
private int width;
private int height;
public int Width { set { width = value; } }
public int Height { set { height = value; } }
};
//
// Summary:
// Contains message information from a thread's message queue.
[StructLayout(LayoutKind.Sequential)]
public struct MSG
{
public IntPtr hwnd;
public int message;
public IntPtr wParam;
public IntPtr lParam;
public int time;
public int pt_x;
public int pt_y;
}
[StructLayout(LayoutKind.Sequential)]
public struct WNDCLASS
{
public uint style;
public IntPtr lpfnWndProc;
public int cbClsExtra;
public int cbWndExtra;
public IntPtr hInstance;
public IntPtr hIcon;
public IntPtr hCursor;
public IntPtr hbrBackground;
[MarshalAs(UnmanagedType.LPWStr)]
public string lpszMenuName;
[MarshalAs(UnmanagedType.LPWStr)]
public string lpszClassName;
}
// Window message flags
[Flags]
public enum WM : uint
{
ACTIVATE = 0x6,
ACTIVATEAPP = 0x1C,
AFXFIRST = 0x360,
AFXLAST = 0x37F,
APP = 0x8000,
ASKCBFORMATNAME = 0x30C,
CANCELJOURNAL = 0x4B,
CANCELMODE = 0x1F,
CAPTURECHANGED = 0x215,
CHANGECBCHAIN = 0x30D,
CHAR = 0x102,
CHARTOITEM = 0x2F,
CHILDACTIVATE = 0x22,
CLEAR = 0x303,
CLOSE = 0x10,
COMMAND = 0x111,
COMPACTING = 0x41,
COMPAREITEM = 0x39,
CONTEXTMENU = 0x7B,
COPY = 0x301,
COPYDATA = 0x4A,
CREATE = 0x1,
CTLCOLORBTN = 0x135,
CTLCOLORDLG = 0x136,
CTLCOLOREDIT = 0x133,
CTLCOLORLISTBOX = 0x134,
CTLCOLORMSGBOX = 0x132,
CTLCOLORSCROLLBAR = 0x137,
CTLCOLORSTATIC = 0x138,
CUT = 0x300,
DEADCHAR = 0x103,
DELETEITEM = 0x2D,
DESTROY = 0x2,
DESTROYCLIPBOARD = 0x307,
DEVICECHANGE = 0x219,
DEVMODECHANGE = 0x1B,
DISPLAYCHANGE = 0x7E,
DRAWCLIPBOARD = 0x308,
DRAWITEM = 0x2B,
DROPFILES = 0x233,
ENABLE = 0xA,
ENDSESSION = 0x16,
ENTERIDLE = 0x121,
ENTERMENULOOP = 0x211,
ENTERSIZEMOVE = 0x231,
ERASEBKGND = 0x14,
EXITMENULOOP = 0x212,
EXITSIZEMOVE = 0x232,
FONTCHANGE = 0x1D,
GETDLGCODE = 0x87,
GETFONT = 0x31,
GETHOTKEY = 0x33,
GETICON = 0x7F,
GETMINMAXINFO = 0x24,
GETOBJECT = 0x3D,
GETSYSMENU = 0x313,
GETTEXT = 0xD,
GETTEXTLENGTH = 0xE,
HANDHELDFIRST = 0x358,
HANDHELDLAST = 0x35F,
HELP = 0x53,
HOTKEY = 0x312,
HSCROLL = 0x114,
HSCROLLCLIPBOARD = 0x30E,
ICONERASEBKGND = 0x27,
IME_CHAR = 0x286,
IME_COMPOSITION = 0x10F,
IME_COMPOSITIONFULL = 0x284,
IME_CONTROL = 0x283,
IME_ENDCOMPOSITION = 0x10E,
IME_KEYDOWN = 0x290,
IME_KEYLAST = 0x10F,
IME_KEYUP = 0x291,
IME_NOTIFY = 0x282,
IME_REQUEST = 0x288,
IME_SELECT = 0x285,
IME_SETCONTEXT = 0x281,
IME_STARTCOMPOSITION = 0x10D,
INITDIALOG = 0x110,
INITMENU = 0x116,
INITMENUPOPUP = 0x117,
INPUTLANGCHANGE = 0x51,
INPUTLANGCHANGEREQUEST = 0x50,
KEYDOWN = 0x100,
KEYFIRST = 0x100,
KEYLAST = 0x108,
KEYUP = 0x101,
KILLFOCUS = 0x8,
LBUTTONDBLCLK = 0x203,
LBUTTONDOWN = 0x201,
LBUTTONUP = 0x202,
LVM_GETEDITCONTROL = 0x1018,
LVM_SETIMAGELIST = 0x1003,
MBUTTONDBLCLK = 0x209,
MBUTTONDOWN = 0x207,
MBUTTONUP = 0x208,
MDIACTIVATE = 0x222,
MDICASCADE = 0x227,
MDICREATE = 0x220,
MDIDESTROY = 0x221,
MDIGETACTIVE = 0x229,
MDIICONARRANGE = 0x228,
MDIMAXIMIZE = 0x225,
MDINEXT = 0x224,
MDIREFRESHMENU = 0x234,
MDIRESTORE = 0x223,
MDISETMENU = 0x230,
MDITILE = 0x226,
MEASUREITEM = 0x2C,
MENUCHAR = 0x120,
MENUCOMMAND = 0x126,
MENUDRAG = 0x123,
MENUGETOBJECT = 0x124,
MENURBUTTONUP = 0x122,
MENUSELECT = 0x11F,
MOUSEACTIVATE = 0x21,
MOUSEFIRST = 0x200,
MOUSEHOVER = 0x2A1,
MOUSELAST = 0x20A,
MOUSELEAVE = 0x2A3,
MOUSEMOVE = 0x200,
MOUSEWHEEL = 0x20A,
MOVE = 0x3,
MOVING = 0x216,
NCACTIVATE = 0x86,
NCCALCSIZE = 0x83,
NCCREATE = 0x81,
NCDESTROY = 0x82,
NCHITTEST = 0x84,
NCLBUTTONDBLCLK = 0xA3,
NCLBUTTONDOWN = 0xA1,
NCLBUTTONUP = 0xA2,
NCMBUTTONDBLCLK = 0xA9,
NCMBUTTONDOWN = 0xA7,
NCMBUTTONUP = 0xA8,
NCMOUSEHOVER = 0x2A0,
NCMOUSELEAVE = 0x2A2,
NCMOUSEMOVE = 0xA0,
NCPAINT = 0x85,
NCRBUTTONDBLCLK = 0xA6,
NCRBUTTONDOWN = 0xA4,
NCRBUTTONUP = 0xA5,
NEXTDLGCTL = 0x28,
NEXTMENU = 0x213,
NOTIFY = 0x4E,
NOTIFYFORMAT = 0x55,
NULL = 0x0,
PAINT = 0xF,
PAINTCLIPBOARD = 0x309,
PAINTICON = 0x26,
PALETTECHANGED = 0x311,
PALETTEISCHANGING = 0x310,
PARENTNOTIFY = 0x210,
PASTE = 0x302,
PENWINFIRST = 0x380,
PENWINLAST = 0x38F,
POWER = 0x48,
PRINT = 0x317,
PRINTCLIENT = 0x318,
QUERYDRAGICON = 0x37,
QUERYENDSESSION = 0x11,
QUERYNEWPALETTE = 0x30F,
QUERYOPEN = 0x13,
QUEUESYNC = 0x23,
QUIT = 0x12,
RBUTTONDBLCLK = 0x206,
RBUTTONDOWN = 0x204,
RBUTTONUP = 0x205,
RENDERALLFORMATS = 0x306,
RENDERFORMAT = 0x305,
SETCURSOR = 0x20,
SETFOCUS = 0x7,
SETFONT = 0x30,
SETHOTKEY = 0x32,
SETICON = 0x80,
SETMARGINS = 0xD3,
SETREDRAW = 0xB,
SETTEXT = 0xC,
SETTINGCHANGE = 0x1A,
SHOWWINDOW = 0x18,
SIZE = 0x5,
SIZECLIPBOARD = 0x30B,
SIZING = 0x214,
SPOOLERSTATUS = 0x2A,
STYLECHANGED = 0x7D,
STYLECHANGING = 0x7C,
SYNCPAINT = 0x88,
SYSCHAR = 0x106,
SYSCOLORCHANGE = 0x15,
SYSCOMMAND = 0x112,
SYSDEADCHAR = 0x107,
SYSKEYDOWN = 0x104,
SYSKEYUP = 0x105,
TCARD = 0x52,
TIMECHANGE = 0x1E,
TIMER = 0x113,
TVM_GETEDITCONTROL = 0x110F,
TVM_SETIMAGELIST = 0x1109,
UNDO = 0x304,
UNINITMENUPOPUP = 0x125,
USER = 0x400,
USERCHANGED = 0x54,
VKEYTOITEM = 0x2E,
VSCROLL = 0x115,
VSCROLLCLIPBOARD = 0x30A,
WINDOWPOSCHANGED = 0x47,
WINDOWPOSCHANGING = 0x46,
WININICHANGE = 0x1A,
SH_NOTIFY = 0x0401
}
[StructLayout(LayoutKind.Sequential)]
public struct COPYDATASTRUCT
{
public IntPtr dwData; // Any value the sender chooses. Perhaps its main window handle?
public int cbData; // The count of bytes in the message.
[MarshalAs(UnmanagedType.LPWStr)]
public string lpData;
}
}