How to Get and Set the System Resolution using C#
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to Get and Set the System Resolution using C#
Can any one guide me how to Get and Set the Screen Resolution using C# in Runtime .
Regards,
AR
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I found the solution for getting the screen resolution, But how to set in Runtime?
var d = Sys["Desktop"];
ShowMessage(d["Height"]);
ShowMessage(d["Width"]);
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
AFAIK, there is no simple way to do this in TestComplete.
As a workaround, you can download a simple command line utility here and then run it from TestComplete like this
Sys.OleObject("WScript.Shell").Run("C:\\chscrres.exe 800 600");
Gennadiy Alpaev
Software Testing Automation Tips - my new book
TestComplete Cookbook is published!
About Community Experts
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
See also http://www.automatedqa.com/support/viewarticle.aspx?aid=8962
/Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Following code is not changing the system Resolution , can you let me what could be the problem with the code.
function SetDisplay(x,y,d)
{
var dm, dwLastError;
res = -1;
dm = Win32API["DEVMODE"]();
if(Win32API["EnumDisplaySettings"](VarToInteger(0), -1, dm) != 0)
{
dm["dmPelsWidth"] = x;
dm["dmPelsHeight"] = y;
dm["dmBitsPerPel"] = d;
res = Win32API["ChangeDisplaySettings"](dm, 0);
}
else
{
dwLastError = Win32API["GetLastError"]();
Log["Error"]("Error code: " + VarToStr(dwLastError));
}
return res
}
function TestSetDisplay()
{
// SetDisplay(1024, 768, 32);
//
// Log["Message"]("New resolution: " + VarToStr(Sys["Desktop"]["Width"]) +
//
// "x"+VarToStr(Sys["Desktop"]["Height"]));
//Delay(2000);
SetDisplay(1280, 1024, 64);
Log["Message"]("New resolution: " + VarToStr(Sys["Desktop"]["Width"]) +
"x"+VarToStr(Sys["Desktop"]["Height"]));
}
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just a quick guess: are you sure that 64 bits/pixel is a correct value for the color depth?
(This is in the SetDisplay(1280, 1024, 64); line.)
Shouldn't it be 32 instead of 64? Or you are using 64-bit OS?
/Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Even i have tried with 32 Bit , Here also it is not working.
Regards,
Abdul
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks . I got the solution. It should be 32 Bit as I am working 32 Bit OS.
Regards,
Abdul
