public static extern ushort RegisterClassEx([In] ref WindowClassEx lpwcx);
public WindowsApplicationHost(Game game) : base(game) { // TODO: Add options for EnableHighResolution if (PlatformDetection.IsWindows10Version1703OrGreater()) { if (SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) || SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE)) { Log.Debug("Win32", "Enabled per monitor DPI awareness."); } } else if (PlatformDetection.IsWindows8Point1OrGreater()) { if (SetProcessDpiAwareness(ProcessDpiAwareness.PerMonitorDpiAware) == 0) { Log.Debug("Enabled per monitor DPI awareness."); } else { Log.Error("Failed to set process DPI awareness"); } } else { SetProcessDPIAware(); } //EnumDisplayMonitors(IntPtr.Zero, IntPtr.Zero, // (IntPtr monitor, IntPtr hdcMonitor, ref RECT lprcMonitor, IntPtr data) => // { // var monitorInfo = new MonitorInfo // { // Size = (uint)Marshal.SizeOf<MonitorInfo>() // }; // if (!GetMonitorInfo(monitor, ref monitorInfo)) // throw Marshal.GetExceptionForHR(Marshal.GetHRForLastWin32Error()); // Rectangle bounds = monitorInfo.MonitorRect; // RECT workingArea = monitorInfo.WorkRect; // return true; // }, IntPtr.Zero); // Register main class. _wndProc = ProcessWindowMessage; var wndClassEx = new WindowClassEx { Size = (uint)Unsafe.SizeOf <WindowClassEx>(), Styles = WindowClassStyles.CS_HREDRAW | WindowClassStyles.CS_VREDRAW | WindowClassStyles.CS_OWNDC, WindowProc = _wndProc, InstanceHandle = HInstance, CursorHandle = LoadCursor(IntPtr.Zero, SystemCursor.IDC_ARROW), BackgroundBrushHandle = IntPtr.Zero, IconHandle = IntPtr.Zero, ClassName = WndClassName, }; var atom = RegisterClassEx(ref wndClassEx); if (atom == 0) { throw new InvalidOperationException( $"Failed to register window class. Error: {Marshal.GetLastWin32Error()}" ); } MainView = new Win32Window(this, "Vortice", 800, 600); }