【问题标题】:Problems with screen resolution displaying on 4K在 4K 上显示屏幕分辨率的问题
【发布时间】:2016-10-14 14:35:31
【问题描述】:

当我尝试使用 4K 分辨率获得实际分辨率时:

Screen.PrimaryScreen.Bounds.Width

或者:

System.Windows.SystemParameters.PrimaryScreenWidth

它将显示分辨率为 2560x1440。这很奇怪 几次显示正确的分辨率 3840x2160。但我不知道怎么可能。

【问题讨论】:

标签: c# resolution screen-resolution


【解决方案1】:

问题是因为 windows 试图渲染没有任何 dpi 管理的应用程序。因此,Windows 假装它正在以另一个分辨率运行应用程序。 如果您使用的是大于 6.0 主版本的 windows 操作系统,您可以使用以下功能:

private enum ProcessDPIAwareness
{
        ProcessDPIUnaware = 0,
        ProcessSystemDPIAware = 1,
        ProcessPerMonitorDPIAware = 2
}

    [DllImport("shcore.dll")]
    private static extern int SetProcessDpiAwareness(ProcessDPIAwareness value);



    private static void SetDpiAwareness()
        {
           if (Environment.OSVersion.Version.Major >= 6)
                 {
                       SetProcessDpiAwareness(ProcessDPIAwareness.ProcessPerMonitorDPIAware);
                 }
         }

【讨论】:

    猜你喜欢
    • 2020-02-25
    • 2017-04-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-15
    • 1970-01-01
    相关资源
    最近更新 更多