Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display Orientation

Status
Not open for further replies.

Geates

Programmer
Aug 25, 2009
1,566
US
I have written what I thought was a way to determine display orientation. It seemed to work until I ran it on a machine with a portrait orientation and it returned landscape. I'm using the Win32__DesktopMonitor object however, changes to the orientation will still result in a landscape orientation according to the object. Is there another object that may be more fitting or some clever/alternate code I could include? Any suggestions are appriated

Code:
function getDisplayOrientation(strComputer)
	set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
	set colItems = objWMIService.ExecQuery("Select * from Win32_DesktopMonitor",,0)

	for each objItem In colItems
		intWidth = objItem.ScreenWidth
		intHeight = objItem.ScreenHeight
	next

	if (intWidth < intHeight) then msgbox "portrait"	
	if (intWidth > intHeight) then msgbox "landscape"
end function

-Geates

"I hope I can chill and see the change - stop the bleed inside and feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 



You logic for portrait and landscape, may not necessarily correspond to the system designation.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
I think the logic is right but perhaps there is a layer in between the ui and the object that interferes. Although, I can change landscape resolutions and the object is updated. But the object is not updates the orientation changes.

-Geates

"I hope I can chill and see the change - stop the bleed inside and feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Just a thought as I've played around with it, but have your thought of using Win32_VideoController and doing the comparison of the CurrentHorizontalResolution vs CurrentVerticalResolution
 
Unfortunately, this didn't work either. Thanks for the suggestion.

-Geates

"I hope I can chill and see the change - stop the bleed inside and feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Good suggestion but still no dice. Although, it does iterate the controller's video modes - which could be useful.

-Geates

"I hope I can chill and see the change - stop the bleed inside and feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Funny. The flag has to be stored somewhere.

I wonder if it's not actually seen at the controller level though. Maybe "width" and "height" never swap, but at a higher level the renderer is directed to paint the image sideways. (Just brainstorming out my posterior...)

Try doing registry snapshots before and after changing orientation. Maybe it's only in there.

Jeff
[small][purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day
"The software I buy sucks, The software I write sucks. It's time to give up and have a beer..." - Me[/small]
 
I also considered that. As you said, maybe the width and height don't change. Maybe another layer is responsible for rendering orientation. :/

Pehaps there are some operating system variables which are modified and accessible via vbs

-Geates


"I hope I can chill and see the change - stop the bleed inside and feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
This one gives ScreenHeight & ScreenWidth as well as horizontal and vertical resolutions:

This one gives "Current" horizontal and vertical resolutions:

User32.dll has a EnumDisplaySettings method that does expose "orientation" I wouldn't know how to access that through VBS.


Jeff
[small][purple]It's never too early to begin preparing for [/purple]International Talk Like a Pirate Day
"The software I buy sucks, The software I write sucks. It's time to give up and have a beer..." - Me[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top