/// <summary> /// Indicates to the OS that this application is aware of high-DPI modes and handles /// it correctly. On some OS versions, if this function is not called then the application /// is virtualized to 96 DPI even if the system is running at 120 DPI. The rendering /// is then stretched by 125% (for 120 DPI) so that it is "physically" the correct size. /// </summary> /// <remarks> /// Note to implementors: This may be implemented as a no-op. /// </remarks> public static void EnableDpiAware() { if (OS.IsVistaOrLater) { try { bool bResult = SafeNativeMethods.SetProcessDPIAware(); if (!bResult) { NativeMethods.ThrowOnWin32Error("SetProcessDPIAware() returned false"); } } catch (Exception) { // Ignore any error } } }