Introduction
It is a sample program It will demonstrate how to change resolution at runtime.
All programmers are facing common problem is how to change screen Resolution dynamically. In .Net 2005 it's very easy to change the screen resolution. Here I will explain you how can we get the screen resolution and how we will change the resolution dynamically and while unloading the page it will come as it was before. In .NET we can access the values of user's screen resolution through the Resolution class. It also affects all running (and minimized) programs.
Page_Load Code
Screen Srn = Screen.PrimaryScreen;
tempHeight = Srn.Bounds.Width;
tempWidth = Srn.Bounds.Height;
Page.ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script type=\"text/javascript\">alert('" + "Your Current Resolution is = " + tempHeight + " * " + tempWidth + "');</script>");
//if you want Automatically Change res.at page load. please uncomment this code.
if (tempHeight == 600)//if the system is 800*600 Res.then change to
{
FixHeight = 768;
FixWidth = 1024;
Resolution.CResolution ChangeRes = new Resolution.CResolution(FixHeight, FixWidth);
}
Change Resoultion
switch (cboRes.SelectedValue.ToString())
{
case "800*600":
FixHeight = 800;
FixWidth = 600;
Resolution.CResolution ChangeRes600 = new Resolution.CResolution(FixHeight, FixWidth);
break;
case "1024*768":
FixHeight = 1024;
FixWidth = 768;
Resolution.CResolution ChangeRes768 = new Resolution.CResolution(FixHeight, FixWidth);
break;
case "1280*1024":
FixHeight = 1280;
FixWidth = 1024;
Resolution.CResolution ChangeRes1024 = new Resolution.CResolution(FixHeight, FixWidth);
break;
}
arun singhPosted Feb 11, 2015, 6:12 AM
hi sir its throwing error "Failed to change the resolutions"
George VarghesePosted Jun 21, 2014, 5:37 AM
this will work only in windows os what abount mac
TSIPLPosted Dec 19, 2013, 6:25 AM
help me in changing the resolution of both the monitors
TSIPLPosted Dec 19, 2013, 6:25 AM
hello ur code works great but i use two monitors simultaneously and resolution of only one monitor gets changes
sunit kumarPosted Jun 15, 2012, 7:16 AM
it is webbased only i want the window based
suba ranjanaPosted Jun 5, 2012, 2:13 AM
i need to view and change power plan settings in windows 7 using c#
Vasistan SakkaravarthiPosted Mar 14, 2012, 2:35 AM
i need to know how to implement this in windows application
zara shaikhPosted Mar 18, 2011, 2:31 PM
hi i m making d website in wich i need dis resolution coding thnx alot
dusselPosted Dec 2, 2010, 7:50 AM
In fact he is using windows apis to change the resolution. There is no class "Resolution" in .Net. For all who want to get the code but don't want to register: It's just a wrapper class called cResolution in an userdefined namespace Resolution that makes use of win32 api calls "EnumDisplaySettings" and "ChangeDisplaySettings". There are tons of examples for .net using this api, so no need to register. The opening paragraph "In .Net 2005 it's very easy to change the screen resolution" does only apply with an additional "if you already have a class which handles changing the resolution". Sorry man, but this is ridiculous.
richa namdeveditedPosted Jun 24, 2010, 1:22 AMEdited Jun 24, 2010, 1:27 AM
How to change web site according to screen resolution in mobile. please give me a answer in [email protected]................. its argent for me. Please send the code. Its a very argent work for me...................... thanksssss
chandruswami RamalingamPosted Jun 10, 2010, 12:03 AM
can you please tell me the namespace used for Resolution class in c#.net
raja sekaranPosted Dec 24, 2009, 1:41 AM
This is hosting probelm.. if u r hosting in asp.net management server it is working fine.. But not working in IIS.. I am trying to find solution for this.. Hope Soon...
raja sekaranPosted Dec 23, 2009, 8:13 AM
HI George, i got an error message says that "Unable to process your request" can u suggest me???
selvaraj sPosted Dec 16, 2009, 12:33 AM
Hi, your coding is working correctly. i am using this code in c#.net windows application. But cannot able to change screen resolution. I am getting message " Description: Failed To Change The Resolution". how to solve this problem. pls help me. Selvaraj.S
Bhavna GarasiaPosted Aug 10, 2009, 3:52 AM
hello sir, your code is working very good. thank you. Garasia Bhavna.
Former memberPosted Jul 1, 2009, 8:59 AM
Hi, Is it possible in windows based application ? I want to change resolution at runtime.Please send me code. i was try but this is not [email protected]
kartik sukumarnPosted Jan 30, 2009, 3:53 AM
This one is not working shows the exception....
karthizenPosted Jan 28, 2009, 5:26 AM
I am a beginner to c# & right now doing a windows application, I guess the above example is for web application. Can anyone guide me in changing the resolution while working in windows application? Regards, karthik
hossam nofalPosted Dec 20, 2008, 6:11 PM
thanks
Marcela OcarizPosted Sep 25, 2008, 3:15 PM
Hi.... I have already test this funcion "Screen.PrimaryScreen;" But it return diferent values where i exceute my web page on Windwos Server and on Windows Vista Why? Why if a change my resolution in Vista... this value is always the same? Tnk's
vinayak huparePosted Feb 24, 2008, 11:59 PM
hello sir my que i , in C# how to compare two word (.doc) files? please reply me sir
Lokesh SharmaPosted Dec 28, 2007, 7:02 AM
hello sir in which namespace resolution class is found. i am having problem in locating this class
siddique haiderPosted Dec 18, 2007, 7:53 AM
Its great dear. Well done man. I like it. Thanks once again of you
mohan rajeditedPosted May 31, 2007, 2:40 AMEdited May 31, 2007, 4:33 AM
Hi Sir, now i am working in software programmer. how to change the screen resolution in vb.net? send the answere to my email id is [email protected] by mohan raj. ===================> Replay me<========================
mohan rajPosted May 31, 2007, 2:25 AM
Hi Sir, now i am working in software programmer. how to change the screen resolution in vb.net? send the answere to my email id is [email protected]
Ranjan KumarPosted Dec 28, 2006, 11:10 PM
Sir, I am ranjan .1) How can we create dynamic too tip text in VB.Net.So that whatever content is in the textbox or any other control when i take the mouse over the control I can see all the content of that control which is unvisible to me. 2) ur code on screen resolution is fine but if u can send it in VB.Net source code. My email id is :[email protected] cellno.09891550294 It'S urgent pls send it as soon as possible till tomorrow. Thanking you.
asad khanPosted Nov 12, 2006, 9:40 AM
hey sir, i am student of graduate program in first semister I have to submit my presentation on "C graphics" at 22nd of this month. Can you help me for making presentation? Please reply me earlier.....My ID is [email protected]
Pankaj GuptaPosted Nov 1, 2006, 3:10 AM
Can u please tell me in which namespace screen class is? Pankaj Gupta
BrianPosted Oct 23, 2006, 3:48 PM
I was able to run the screen res function once or twice and it worked and then after that I would get this error MessageBox.Show("Unable to process your request"); MessageBox.Show("Description: Unable To Process Your Request. Sorry For This Inconvenience.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); What might I be missing
BrianPosted Oct 23, 2006, 3:46 PM
I was
BrianPosted Oct 23, 2006, 3:46 PM
I