Click here to Skip to main content
15,890,825 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi every body!

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

Thanks , DoOstL
Posted
Comments
[no name] 28-Jun-11 5:21am    
please expalin what exactly you are trying to achive.
Sergey Alexandrovich Kryukov 28-Jun-11 13:33pm    
It is WPF, Forms, ASP.NET. Tag it! Use "Improve question".
--SA

int ScreenWidth, ScreenHeight;
ScreenWidth = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
ScreenHeight = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
 
Share this answer
 
 
Share this answer
 
If it is a web application use this Javascript.
C#
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);
        }
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900