tags:

views:

114

answers:

1

How to get the Monitor Screen Resolution from an hWnd?

I am using an hWnd because the window could be located on any one of multiple monitors.

i.e. the hWnd top/left coordinate is on a Monitor that has a Screen Resolution of 800 x 600.

I program in a language called PL/B and it allows calling Windows API.

What Window APIs can be used?

+3  A: 

The user32 function MonitorFromWindow allows you to pass in an hwnd, and returns a handle to the monitor it's on (or a default - see the linked MSDN article for details). With that you can call GetMonitorInfo to retrieve a MONITORINFO struct which contains a RECT detailing its resolution.

See the Multiple Screens Reference section of MSDN for more details.

I'd add example code but I don't know the language you referenced, and I don't know how useful C# example code would be to you. If you think it'll help, let me know and I'll code up something real quick.

Erik Forbes
Thank you very much Erik. I was able to convert it to PL/B using the references you supplied.
Gerhard Weiss
Great, I'm glad to hear it. =)
Erik Forbes