public static void CreateMainWindowAndRun( WindowClass windowClass, string?windowTitle = null, WindowStyles style = WindowStyles.OverlappedWindow, ExtendedWindowStyles extendedStyle = ExtendedWindowStyles.Default, MenuHandle menuHandle = default) { CreateMainWindowAndRun(windowClass, DefaultBounds, windowTitle, style, extendedStyle, menuHandle); }
public static unsafe Atom RegisterClass(ref WindowClass windowClass) { Atom atom; using (var marshaller = new WindowClass.Marshaller()) { marshaller.FillNative(out WNDCLASSEX native, ref windowClass); atom = Imports.RegisterClassExW(ref native); if (!atom.IsValid) { throw Errors.GetIoExceptionForLastError(); } } return(atom); }
/// <summary> /// Creates a window of the specified class and processes the message loop. /// Does not return until the message loop exits. /// </summary> public static void CreateMainWindowAndRun( WindowClass windowClass, Rectangle bounds, string?windowTitle = null, WindowStyles style = WindowStyles.OverlappedWindow, ExtendedWindowStyles extendedStyle = ExtendedWindowStyles.Default, MenuHandle menuHandle = default) { if (!windowClass.IsRegistered) { windowClass.Register(); } WindowHandle mainWindow = windowClass.CreateWindow( bounds, windowTitle, style, extendedStyle, isMainWindow: true, menuHandle: menuHandle); try { mainWindow.ShowWindow(ShowWindowCommand.Normal); mainWindow.UpdateWindow(); while (GetMessage(out WindowMessage message)) { TranslateMessage(ref message); DispatchMessage(ref message); } // Make sure our window class doesn't get collected while we're pumping messages GC.KeepAlive(windowClass); } catch { // Hit the P/Invoke directly as we want to throw the original error. Imports.DestroyWindow(mainWindow); throw; } }
/// <summary> /// Creates a window of the specified class and processes the message loop. /// Does not return until the message loop exits. /// </summary> public static void CreateMainWindowAndRun( WindowClass windowClass, Rectangle bounds, string windowTitle = null, WindowStyles style = WindowStyles.OverlappedWindow, ExtendedWindowStyles extendedStyle = ExtendedWindowStyles.Default, MenuHandle menuHandle = default) { // Hack for launching as a .NET Core Windows Application Console.Console.TryFreeConsole(); if (!windowClass.IsRegistered) { windowClass.Register(); } WindowHandle mainWindow = windowClass.CreateWindow( bounds, windowTitle, style, extendedStyle, isMainWindow: true, menuHandle: menuHandle); mainWindow.ShowWindow(ShowWindowCommand.Normal); mainWindow.UpdateWindow(); while (GetMessage(out WindowMessage message)) { TranslateMessage(ref message); DispatchMessage(ref message); } // Make sure our window class doesn't get collected while were pumping GC.KeepAlive(windowClass); }
public static Atom RegisterClass(ref WindowClass windowClass) => WindowMethods.RegisterClass(ref windowClass);