public static bool TryFindDpiAwarenessContextsEqual(System.Windows.Forms.DpiAwarenessContext dpiContextA, System.Windows.Forms.DpiAwarenessContext dpiContextB) { if (dpiContextA == System.Windows.Forms.DpiAwarenessContext.DPI_AWARENESS_CONTEXT_UNSPECIFIED && dpiContextB == System.Windows.Forms.DpiAwarenessContext.DPI_AWARENESS_CONTEXT_UNSPECIFIED) { return(true); } if (ApiHelper.IsApiAvailable("user32.dll", "AreDpiAwarenessContextsEqual")) { return(AreDpiAwarenessContextsEqual(dpiContextA, dpiContextB)); } return(false); }
public DpiAwarenessScope(System.Windows.Forms.DpiAwarenessContext awareness) { if (!EnableDpiChangedHighDpiImprovements) { return; } try { if (!CommonUnsafeNativeMethods.TryFindDpiAwarenessContextsEqual(awareness, System.Windows.Forms.DpiAwarenessContext.DPI_AWARENESS_CONTEXT_UNSPECIFIED)) { originalAwareness = CommonUnsafeNativeMethods.GetThreadDpiAwarenessContext(); if (!CommonUnsafeNativeMethods.TryFindDpiAwarenessContextsEqual(originalAwareness, awareness) && !CommonUnsafeNativeMethods.TryFindDpiAwarenessContextsEqual(originalAwareness, System.Windows.Forms.DpiAwarenessContext.DPI_AWARENESS_CONTEXT_UNAWARE)) { originalAwareness = CommonUnsafeNativeMethods.SetThreadDpiAwarenessContext(awareness); dpiAwarenessScopeIsSet = true; } } } catch (EntryPointNotFoundException) { dpiAwarenessScopeIsSet = false; } }
internal static System.Windows.Forms.DpiAwarenessContext TryGetDpiAwarenessContextForWindow(IntPtr hWnd) { System.Windows.Forms.DpiAwarenessContext result = System.Windows.Forms.DpiAwarenessContext.DPI_AWARENESS_CONTEXT_UNSPECIFIED; try { if (ApiHelper.IsApiAvailable("user32.dll", "GetWindowDpiAwarenessContext")) { if (ApiHelper.IsApiAvailable("user32.dll", "GetAwarenessFromDpiAwarenessContext")) { IntPtr windowDpiAwarenessContext = GetWindowDpiAwarenessContext(hWnd); DPI_AWARENESS awarenessFromDpiAwarenessContext = GetAwarenessFromDpiAwarenessContext(windowDpiAwarenessContext); result = ConvertToDpiAwarenessContext(awarenessFromDpiAwarenessContext); return(result); } return(result); } return(result); } catch { return(result); } }
public static IDisposable EnterDpiAwarenessScope(System.Windows.Forms.DpiAwarenessContext awareness) { return(new DpiAwarenessScope(awareness)); }
public static System.Windows.Forms.DpiAwarenessContext TrySetThreadDpiAwarenessContext(System.Windows.Forms.DpiAwarenessContext dpiCOntext) { if (ApiHelper.IsApiAvailable("user32.dll", "SetThreadDpiAwarenessContext")) { return(SetThreadDpiAwarenessContext(dpiCOntext)); } return(System.Windows.Forms.DpiAwarenessContext.DPI_AWARENESS_CONTEXT_UNSPECIFIED); }
internal static extern bool AreDpiAwarenessContextsEqual(System.Windows.Forms.DpiAwarenessContext dpiContextA, System.Windows.Forms.DpiAwarenessContext dpiContextB);
internal static extern System.Windows.Forms.DpiAwarenessContext SetThreadDpiAwarenessContext(System.Windows.Forms.DpiAwarenessContext dpiContext);