用户监视器的分辨率 [英] resolution of monitor of user

查看:84
本文介绍了用户监视器的分辨率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

我想了解如何获得用户显示器的分辨率?

谢谢,DoOstL

Hi every body!

I wanna understand how can i get the resolution of monitor of user?

Thanks , DoOstL

推荐答案

int ScreenWidth, ScreenHeight;
ScreenWidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
ScreenHeight = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;


您可以使用以下属性获取它.

system.windows.forms.systeminformation.primarymonitorsize [ ^ ]

system.windows.forms.systeminformation.virtualscreen [ ^ ]
You can get it using following properties.

system.windows.forms.systeminformation.primarymonitorsize[^]

system.windows.forms.systeminformation.virtualscreen[^]


如果它是 Web应用程序,请使用此Javascript.
If it is a web application use this Javascript.
function fnScreenWidthHeight() {
            //for IE
            var viewportwidth;
            var viewportheight;

            // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
            if (typeof window.innerWidth != 'undefined') {
                viewportwidth = window.innerWidth;
                viewportheight = window.innerHeight;
            }

            // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
            else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
                viewportwidth = document.documentElement.clientWidth;
                viewportheight = document.documentElement.clientHeight;
            }

            // older versions of IE
            else {
                viewportwidth = document.getElementsByTagName('body')[0].clientWidth;
                viewportheight = document.getElementsByTagName('body')[0].clientHeight;
            }
            alert('Your viewport width is ' + viewportwidth + 'x' + viewportheight);
        }


这篇关于用户监视器的分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆