diff --git a/Source/OpenTK/Platform/Windows/API.cs b/Source/OpenTK/Platform/Windows/API.cs index ccd77bc5..87f2695f 100644 --- a/Source/OpenTK/Platform/Windows/API.cs +++ b/Source/OpenTK/Platform/Windows/API.cs @@ -943,6 +943,30 @@ namespace OpenTK.Platform.Windows [DllImport("user32.dll", SetLastError = true)] public static extern HMONITOR MonitorFromWindow(HWND hwnd, MonitorFrom dwFlags); + #endregion + + #region SetProcessDPIAware + + /// + /// Sets the current process as dots per inch (dpi) aware. + /// Note: SetProcessDPIAware is subject to a possible race condition + /// if a DLL caches dpi settings during initialization. + /// For this reason, it is recommended that dpi-aware be set through + /// the application (.exe) manifest rather than by calling SetProcessDPIAware. + /// + /// + /// If the function succeeds, the return value is true. + /// Otherwise, the return value is false. + /// + /// + /// DLLs should accept the dpi setting of the host process + /// rather than call SetProcessDPIAware themselves. + /// To be set properly, dpiAware should be specified as part + /// of the application (.exe) manifest. + /// + [DllImport("user32.dll")] + internal static extern BOOL SetProcessDPIAware(); + #endregion #endregion diff --git a/Source/OpenTK/Platform/Windows/WinFactory.cs b/Source/OpenTK/Platform/Windows/WinFactory.cs index c5d8fcc3..877d63f3 100644 --- a/Source/OpenTK/Platform/Windows/WinFactory.cs +++ b/Source/OpenTK/Platform/Windows/WinFactory.cs @@ -26,7 +26,8 @@ #endregion using System; -using System.Collections.Generic; +using System.Collections.Generic; +using System.Diagnostics; using System.Text; namespace OpenTK.Platform.Windows @@ -37,7 +38,18 @@ namespace OpenTK.Platform.Windows class WinFactory : IPlatformFactory { readonly object SyncRoot = new object(); - IInputDriver2 inputDriver; + IInputDriver2 inputDriver; + + public WinFactory() + { + if (System.Environment.OSVersion.Version.Major >= 6) + { + // Enable high-dpi support + // Only available on Windows Vista and higher + bool result = Functions.SetProcessDPIAware(); + Debug.Print("SetProcessDPIAware() returned {0}", result); + } + } #region IPlatformFactory Members