zoukankan      html  css  js  c++  java
  • C#:屏幕显示区域问题

    更改电脑屏幕显示的文字大小后,平面显示区域问题。

    /// <summary>
            /// 屏幕显示尺寸
            /// </summary>
            public static Size ReviseScreenSize
            {
                get
                {
                    float pixels = getLogPiex();
                    float dxPrecent = 96 / pixels; //pixels / 96;
                    Screen s = Screen.PrimaryScreen;
                    Size primarySize = s.Bounds.Size;
                    Size returnSize = new Size();
                    returnSize.Width = (int)(primarySize.Width * dxPrecent);
                    returnSize.Height = (int)(primarySize.Height * dxPrecent);
                    return returnSize;
                }
            }
    
            public static float getLogPiex()
            {
                float returnValue = 96;
                RegistryKey key = Registry.CurrentUser;
                RegistryKey pixeKey = key.OpenSubKey("Control Panel\Desktop");
                if (pixeKey != null)
                {
                    var pixels = pixeKey.GetValue("LogPixels");
                    if (pixels != null)
                    {
                        returnValue = float.Parse(pixels.ToString());
                    }
                    pixeKey.Close();
                }
                return returnValue;
            }
    View Code
  • 相关阅读:
    Java线程
    IO流
    staitc
    权限修饰符
    nexus
    Maven
    Git 常用命令
    获取url参数
    创建存储过程和函数
    三层引号
  • 原文地址:https://www.cnblogs.com/shenchao/p/5465533.html
Copyright © 2011-2022 走看看