-
Notifications
You must be signed in to change notification settings - Fork 1
/
Program.cs
683 lines (603 loc) · 28.1 KB
/
Program.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
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
using System;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
using System.Text;
using Windows.Win32;
using Windows.Win32.Foundation;
using Windows.Win32.Graphics.Gdi;
namespace AppContainer
{
internal partial class Program
{
private static readonly Windows.Win32.UI.WindowsAndMessaging.WNDPROC _wndProc = new Windows.Win32.UI.WindowsAndMessaging.WNDPROC(WindowProc);
private static Process? appProcess;
private static HWND hostWindow;
private static Bitmap? backgroundImage;
private static Bitmap? overlayImage;
private static string? overlayPosition;
private static HWND appWindow;
private static int appWidth;
private static int appHeight;
private static readonly string logFilePath = "AppContainer.log";
private delegate void WindowSizeChanged();
private static event WindowSizeChanged? OnWindowSizeChanged;
[STAThread]
private static void Main(string[] args)
{
try
{
var arguments = Utils.ParseArguments(args);
#if !DEBUG
PInvoke.AttachConsole(unchecked((uint)-1));
#endif
Log("Application started");
if (arguments.TryGetValue("window-title", out var appWindowTitle))
{
appWindow = PInvoke.FindWindow(null, appWindowTitle);
if (appWindow == IntPtr.Zero)
{
throw new InvalidOperationException($"Could not find a window with the title: '{appWindowTitle}'. Please ensure the app window is open and the title is correct.");
}
}
else if (arguments.TryGetValue("window-handle", out var windowHandle))
{
appWindow = Utils.ConvertAndValidateWindowHandle(windowHandle);
}
else
{
throw new ArgumentException("Neither 'window-title' nor 'window-handle' argument provided. Please specify either the app window title or handle.");
}
var monitor = Utils.GetMonitorFromWindow(appWindow);
// Load the background image or set the background color
if (arguments.TryGetValue("background-image", out string? backgroundImagePath))
{
if (!File.Exists(backgroundImagePath))
{
throw new FileNotFoundException($"Background image not found at the specified path: {backgroundImagePath}. Please ensure the file exists and the path is correct.");
}
backgroundImage = new Bitmap(backgroundImagePath);
Log($"Background image loaded: {backgroundImagePath}");
}
else if (arguments.TryGetValue("background-color", out string? backgroundColorHex))
{
if (!Utils.IsValidHexColor(backgroundColorHex))
{
throw new ArgumentException("Invalid background color hex value. Please provide a valid hex color code.");
}
Color backgroundColor = ColorTranslator.FromHtml(backgroundColorHex);
backgroundImage = Utils.CreateSolidColorBitmap(backgroundColor,
monitor.Width,
monitor.Height);
Log($"Background color set: {backgroundColorHex}");
}
else if (arguments.TryGetValue("background-gradient", out string? gradientColors))
{
var colors = gradientColors.Split(';');
if (colors.Length != 2 || !Utils.IsValidHexColor(colors[0]) || !Utils.IsValidHexColor(colors[1]))
{
throw new ArgumentException("Invalid background gradient value. Please provide two valid hex color codes separated by a semicolon.");
}
Color color1 = ColorTranslator.FromHtml(colors[0]);
Color color2 = ColorTranslator.FromHtml(colors[1]);
backgroundImage = Utils.CreateGradientBitmap(color1, color2,
monitor.Width,
monitor.Height);
Log($"Background gradient set from {colors[0]} to {colors[1]}");
}
else
{
throw new ArgumentException("Background image or background color argument is missing. Please provide a valid path using the 'background-image' argument or a valid hex color code using the 'background-color' argument.");
}
if (arguments.TryGetValue("overlay-image", out string? overlayImagePath))
{
try
{
if (!File.Exists(overlayImagePath))
{
throw new FileNotFoundException($"Overlay image not found at the specified path: {overlayImagePath}");
}
overlayImage = new Bitmap(overlayImagePath);
Log($"Overlay image loaded successfully: {overlayImagePath}");
// Parse overlay position
if (arguments.TryGetValue("overlay-position", out string? position))
{
overlayPosition = position.ToLower();
if (!IsValidOverlayPosition(overlayPosition))
{
throw new ArgumentException("Invalid overlay-position value. Valid values are: center, top-left, top-right, bottom-left, bottom-right.");
}
Log($"Overlay position set to: {overlayPosition}");
}
else
{
throw new ArgumentException("overlay-position argument is required when using an overlay image.");
}
}
catch (Exception ex)
{
Log($"Error loading overlay image: {ex.Message}");
if (overlayImage is not null)
{
overlayImage.Dispose();
}
overlayImage = null;
overlayPosition = string.Empty;
}
}
// Create the host window
hostWindow = CreateHostWindow(monitor);
if (hostWindow == IntPtr.Zero)
{
throw new InvalidOperationException("Failed to create host window. Please check if you have sufficient permissions and system resources.");
}
Log("Host window created successfully");
appProcess = GetProcessByWindow(appWindow);
if (appProcess == null)
{
throw new InvalidOperationException("Failed to find the app process. Please ensure the app is running and accessible.");
}
Log($"App process found: {appProcess.ProcessName} (ID: {appProcess.Id})");
if (!arguments.TryGetValue("width", out var width))
{
throw new ArgumentException("Width argument is missing. Please provide a valid width using the 'width' argument.");
}
if (!arguments.TryGetValue("height", out var height))
{
throw new ArgumentException("Height argument is missing. Please provide a valid height using the 'height' argument.");
}
// Set desired app window size
// (0 means fullscreen, -1 means use existing size)
if (!int.TryParse(width, out appWidth) || !int.TryParse(height, out appHeight))
{
throw new ArgumentException("Invalid width or height value. Please provide valid integer values for width and height.");
}
if (appWidth < -1 || appHeight < -1)
{
throw new ArgumentOutOfRangeException("width/height", "Invalid width or height value. Values must be -1 (use existing size), 0 (fullscreen), or a positive integer.");
}
// Set the host window title and icon to match the app window
UpdateHostWindowTitleAndIcon();
// Embed the app window as a child of the host window
EmbedAppWindow();
// Monitor the app process exit
appProcess.EnableRaisingEvents = true;
appProcess.Exited += (sender, e) =>
{
Log("App process exited.");
PInvoke.PostMessage(hostWindow, WM_CLOSE, 0, IntPtr.Zero);
};
// Subscribe to the window size changed event
OnWindowSizeChanged += HandleWindowSizeChanged;
// Run a message loop to keep the host window responsive
RunMessageLoop();
}
catch (Exception ex)
{
Log($"Fatal error: {ex.Message}\n{ex.StackTrace}");
string errorMessage = $"An error occurred: {ex.Message}\n\nFor more details, please check the log file at: {logFilePath}";
PInvoke.MessageBox(HWND.Null, errorMessage, "Error", Windows.Win32.UI.WindowsAndMessaging.MESSAGEBOX_STYLE.MB_OK | Windows.Win32.UI.WindowsAndMessaging.MESSAGEBOX_STYLE.MB_ICONERROR);
}
finally
{
if (backgroundImage != null)
{
backgroundImage.Dispose();
}
if (overlayImage != null)
{
overlayImage.Dispose();
}
Log("Application ended");
#if !DEBUG
PInvoke.FreeConsole();
#endif
Environment.Exit(0);
}
}
/// <summary>
/// Creates the host window for the application.
/// </summary>
/// <returns>A handle to the created window, or IntPtr.Zero if the creation fails.</returns>
/// <exception cref="Exception">Thrown when window class registration or window creation fails.</exception>
private unsafe static HWND CreateHostWindow(Monitor monitor)
{
HINSTANCE hInstance = new(Process.GetCurrentProcess().Handle);
if (hInstance == IntPtr.Zero)
{
throw new Exception($"Failed to get module handle. Error code: {Marshal.GetLastWin32Error()}");
}
const string WindowClassName = "AppContainerClass";
const string WindowName = "AppContainer";
ushort classId;
fixed (char* pClassName = WindowClassName)
fixed (char* pWindowName = WindowName)
{
Windows.Win32.UI.WindowsAndMessaging.WNDCLASSEXW wndClass = new Windows.Win32.UI.WindowsAndMessaging.WNDCLASSEXW
{
cbSize = (uint)Marshal.SizeOf<Windows.Win32.UI.WindowsAndMessaging.WNDCLASSEXW>(),
lpfnWndProc = _wndProc,
hInstance = hInstance,
lpszClassName = pClassName,
hbrBackground = HBRUSH.Null
};
classId = PInvoke.RegisterClassEx(in wndClass);
if (classId == 0)
{
int error = Marshal.GetLastWin32Error();
throw new Exception($"Failed to register window class. Error code: {error}");
}
Log($"Window class registered successfully. Class ID: {classId}");
HWND hwnd = PInvoke.CreateWindowEx(
0,
pClassName,
pWindowName,
Windows.Win32.UI.WindowsAndMessaging.WINDOW_STYLE.WS_POPUP | Windows.Win32.UI.WindowsAndMessaging.WINDOW_STYLE.WS_VISIBLE,
monitor.X,
monitor.Y,
monitor.Width,
monitor.Height,
HWND.Null,
Windows.Win32.UI.WindowsAndMessaging.HMENU.Null,
hInstance,
null);
if (hwnd == IntPtr.Zero)
{
int error = Marshal.GetLastWin32Error();
throw new Exception($"Failed to create window. Error code: {error}");
}
Log("Window created successfully");
return hwnd;
}
}
/// <summary>
/// Embeds the app window as a child of the host window.
/// </summary>
/// <exception cref="Exception">Thrown when setting the parent window fails.</exception>
private static void EmbedAppWindow()
{
// Remove the app window's title bar and border
var style = PInvoke.GetWindowLong(appWindow, Windows.Win32.UI.WindowsAndMessaging.WINDOW_LONG_PTR_INDEX.GWL_STYLE);
style &= ~(WS_CAPTION | WS_THICKFRAME | WS_MINIMIZE | WS_MAXIMIZE | WS_SYSMENU);
if (PInvoke.SetWindowLong(appWindow, Windows.Win32.UI.WindowsAndMessaging.WINDOW_LONG_PTR_INDEX.GWL_STYLE, style) == 0)
{
Log($"Warning: Failed to set window style. Error code: {Marshal.GetLastWin32Error()}");
}
if (PInvoke.SetParent(appWindow, hostWindow) == HWND.Null)
{
throw new Exception($"Failed to set parent window. Error code: {Marshal.GetLastWin32Error()}");
}
// Determine the size to use for the app window
DetermineAppWindowSize();
// Center and resize the app window
CenterAndResizeAppWindow();
// Set up a timer to periodically check for window size changes
if (PInvoke.SetTimer(hostWindow, 1, 100, null) == default)
{
Log($"Warning: Failed to set timer. Error code: {Marshal.GetLastWin32Error()}");
}
Log("App window embedded successfully");
}
/// <summary>
/// Determines the size to use for the app window based on the provided arguments.
/// </summary>
private static void DetermineAppWindowSize()
{
if (appWidth == 0 && appHeight == 0)
{
// Use fullscreen (host window size) if both width and height are 0
if (!PInvoke.GetClientRect(hostWindow, out var hostRect))
{
Log($"Warning: Failed to get host window rect. Error code: {Marshal.GetLastWin32Error()}");
return;
}
appWidth = hostRect.right - hostRect.left;
appHeight = hostRect.bottom - hostRect.top;
Log($"Using fullscreen size: {appWidth}x{appHeight}");
}
else if (appWidth == -1 && appHeight == -1)
{
// Use existing app window size if both width and height are -1
if (!PInvoke.GetWindowRect(appWindow, out var appRect))
{
Log($"Warning: Failed to get app window rect. Error code: {Marshal.GetLastWin32Error()}");
return;
}
appWidth = appRect.right - appRect.left;
appHeight = appRect.bottom - appRect.top;
Log($"Using existing app window size: {appWidth}x{appHeight}");
}
else
{
// Use the specified size
Log($"Using specified app window size: {appWidth}x{appHeight}");
}
}
/// <summary>
/// Handles changes in the app window size.
/// </summary>
private static void HandleWindowSizeChanged()
{
if (!PInvoke.GetWindowRect(appWindow, out var appRect))
{
Log($"Warning: Failed to get window rect. Error code: {Marshal.GetLastWin32Error()}");
return;
}
int newWidth = appRect.right - appRect.left;
int newHeight = appRect.bottom - appRect.top;
// Only update if the size has actually changed
if (newWidth != appWidth || newHeight != appHeight)
{
appWidth = newWidth;
appHeight = newHeight;
CenterAndResizeAppWindow();
PInvoke.RedrawWindow(hostWindow, null, null, Windows.Win32.Graphics.Gdi.REDRAW_WINDOW_FLAGS.RDW_INVALIDATE | Windows.Win32.Graphics.Gdi.REDRAW_WINDOW_FLAGS.RDW_UPDATENOW);
Log($"Window size changed: {appWidth}x{appHeight}");
}
}
/// <summary>
/// Centers and resizes the app window within the host window.
/// </summary>
private static void CenterAndResizeAppWindow()
{
if (!PInvoke.GetClientRect(hostWindow, out var clientRect))
{
Log($"Warning: Failed to get client rect. Error code: {Marshal.GetLastWin32Error()}");
return;
}
int hostWidth = clientRect.right - clientRect.left;
int hostHeight = clientRect.bottom - clientRect.top;
int x = (hostWidth - appWidth) / 2;
int y = (hostHeight - appHeight) / 2;
if (!PInvoke.MoveWindow(appWindow, x, y, appWidth, appHeight, true))
{
Log($"Warning: Failed to move window. Error code: {Marshal.GetLastWin32Error()}");
}
}
/// <summary>
/// Updates the host window's title and icon to match the app window.
/// </summary>
private unsafe static void UpdateHostWindowTitleAndIcon()
{
// Get the app window title
int bufferSize = PInvoke.GetWindowTextLength(appWindow) + 1;
//ADDRESS WONT CHANGE, THIS VARIABLE SHOULD BE USED WITH IN THIS SCOPE.
fixed (char* windowNameChars = new char[bufferSize])
{
if (PInvoke.GetWindowText(appWindow, windowNameChars, bufferSize) == 0)
{
int error = Marshal.GetLastWin32Error();
if (error != 0) // Only log if there's an actual error, not just an empty title
{
Log($"Warning: Failed to get window text. Error code: {error}");
}
}
else
{
string appWindowTitle = new(windowNameChars);
// Log the title for debugging
Log($"Retrieved window title: {appWindowTitle}");
if (!PInvoke.SetWindowText(hostWindow, appWindowTitle))
{
Log($"Warning: Failed to set window text. Error code: {Marshal.GetLastWin32Error()}");
}
else
{
Log($"Successfully set host window title to: {appWindowTitle}");
}
}
}
// Get the app window icon
IntPtr hIcon = PInvoke.SendMessage(appWindow, WM_GETICON, ICON_BIG, IntPtr.Zero);
if (hIcon == IntPtr.Zero)
{
nuint classLongPtr = PInvoke.GetClassLongPtr(appWindow, Windows.Win32.UI.WindowsAndMessaging.GET_CLASS_LONG_INDEX.GCL_HICON);
hIcon = (IntPtr)classLongPtr;
}
if (hIcon != IntPtr.Zero)
{
PInvoke.SendMessage(hostWindow, WM_SETICON, ICON_BIG, hIcon);
}
else
{
Log("Warning: Failed to get window icon.");
}
Log("Host window title and icon updated");
}
/// <summary>
/// Runs the main message loop for the application.
/// </summary>
private static void RunMessageLoop()
{
Log("Entering message loop");
while (PInvoke.GetMessage(out var msg, HWND.Null, 0, 0))
{
PInvoke.TranslateMessage(msg);
PInvoke.DispatchMessage(msg);
}
// Cleanup and kill the app process if still running
if (appProcess != null && !appProcess.HasExited)
{
try
{
appProcess.Kill();
Log("App process terminated");
}
catch (Exception ex)
{
Log($"Error terminating app process: {ex.Message}");
}
}
Log("Exiting message loop");
}
/// <summary>
/// Retrieves the Process object associated with a given window handle.
/// </summary>
/// <param name="hWnd">The handle of the window.</param>
/// <returns>The Process object associated with the window, or null if not found.</returns>
private unsafe static Process? GetProcessByWindow(HWND hWnd)
{
uint processId;
uint threadId = PInvoke.GetWindowThreadProcessId(hWnd, &processId);
if (threadId is 0)
{
throw new Exception("Unable to determine process for supplied window");
}
try
{
return Process.GetProcessById((int)processId);
}
catch (ArgumentException)
{
Log($"Warning: Process with ID {processId} not found.");
return null;
}
}
/// <summary>
/// The window procedure for handling window messages.
/// </summary>
/// <param name="hWnd">A handle to the window.</param>
/// <param name="msg">The message.</param>
/// <param name="wParam">Additional message information.</param>
/// <param name="lParam">Additional message information.</param>
/// <returns>The result of the message processing.</returns>
private static LRESULT WindowProc(HWND hWnd, uint msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_PAINT:
if (backgroundImage is not null)
{
var hdc = PInvoke.BeginPaint(hWnd, out var ps);
using (Graphics g = Graphics.FromHdc(hdc))
{
try
{
var monitor = Utils.GetMonitorFromWindow(hWnd);
g.DrawImage(backgroundImage, 0, 0, monitor.Width, monitor.Height);
// Draw the overlay image if it exists
if (overlayImage is not null && !string.IsNullOrEmpty(overlayPosition))
{
DrawOverlayImage(g, overlayImage, overlayPosition, monitor.Width, monitor.Height);
}
}
catch (Exception ex)
{
Log($"Error during WM_PAINT: {ex.Message}");
}
}
PInvoke.EndPaint(hWnd, ps);
}
break;
case WM_SIZE:
// Handle resize event
CenterAndResizeAppWindow();
PInvoke.RedrawWindow(hWnd, null, null, Windows.Win32.Graphics.Gdi.REDRAW_WINDOW_FLAGS.RDW_INVALIDATE | Windows.Win32.Graphics.Gdi.REDRAW_WINDOW_FLAGS.RDW_UPDATENOW);
return (LRESULT)IntPtr.Zero;
case WM_CLOSE:
// Cleanup and exit the host window
PInvoke.DestroyWindow(hWnd);
PInvoke.PostQuitMessage(0);
break;
case WM_TIMER:
// Check for window size changes
if (PInvoke.GetWindowRect(appWindow, out var currentRect))
{
int currentWidth = currentRect.right - currentRect.left;
int currentHeight = currentRect.bottom - currentRect.top;
if (currentWidth != appWidth || currentHeight != appHeight)
{
OnWindowSizeChanged?.Invoke();
}
}
else
{
Log($"Warning: Failed to get window rect in WM_TIMER. Error code: {Marshal.GetLastWin32Error()}");
}
break;
}
return PInvoke.DefWindowProc(hWnd, msg, wParam, lParam);
}
private static void DrawOverlayImage(Graphics g, Image image, string position, int hostWidth, int hostHeight)
{
try
{
int x, y;
switch (position)
{
case "center":
x = (hostWidth - image.Width) / 2;
y = (hostHeight - image.Height) / 2;
break;
case "top-left":
x = 0;
y = 0;
break;
case "top-right":
x = hostWidth - image.Width;
y = 0;
break;
case "bottom-left":
x = 0;
y = hostHeight - image.Height;
break;
case "bottom-right":
x = hostWidth - image.Width;
y = hostHeight - image.Height;
break;
default:
throw new ArgumentException("Invalid overlay position");
}
var colorMatrix = new ColorMatrix
{
Matrix33 = 1.0f // Set the alpha value to 1 (fully opaque)
};
var imageAttributes = new ImageAttributes();
imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
g.DrawImage(image, new Rectangle(x, y, image.Width, image.Height),
0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttributes);
Log($"Overlay image drawn successfully at position: {position}");
}
catch (Exception ex)
{
Log($"Error drawing overlay image: {ex.Message}");
}
}
private static bool IsValidOverlayPosition(string position)
{
return position == "center" || position == "top-left" || position == "top-right" ||
position == "bottom-left" || position == "bottom-right";
}
/// <summary>
/// Logs a message to the console and, in debug mode, to a file.
/// </summary>
/// <param name="message">The message to log.</param>
private static void Log(string message)
{
#if !DEBUG
string logMessage = $"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] {message}";
Console.WriteLine(logMessage);
File.AppendAllText(logFilePath, logMessage + Environment.NewLine);
#endif
}
#region Win32 API
private const int WS_POPUP = unchecked((int)0x80000000);
private const int WS_VISIBLE = 0x10000000;
private const int WS_CAPTION = 0xC00000;
private const int WS_THICKFRAME = 0x40000;
private const int WS_MINIMIZE = 0x20000000;
private const int WS_MAXIMIZE = 0x1000000;
private const int WS_SYSMENU = 0x80000;
private const int GWL_STYLE = -16;
private const uint WM_PAINT = 0x000F;
private const uint WM_SIZE = 0x0005;
private const uint WM_CLOSE = 0x0010;
private const uint WM_TIMER = 0x0113;
private const uint WM_GETICON = 0x007F;
private const uint WM_SETICON = 0x0080;
private const int ICON_BIG = 1;
private const int GCL_HICON = -14;
#endregion
}
}