首页 > Windows开发 > 详细

C#:屏幕显示区域问题

时间:2016-05-06 14:41:24      阅读:217      评论:0      收藏:0      [点我收藏+]

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

技术分享
/// <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

 

C#:屏幕显示区域问题

原文:http://www.cnblogs.com/shenchao/p/5465533.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!