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