-
September 5th, 2011, 06:30 AM
#1
Get Monitor Resolution
Hi,
I'm looking for a method to get the monitor resolution (native) or the current pixel aspect ratio.
I want the resolution of the hardware LCD screen (number of pixels... width and height)... not the current resolution from windows panel
If this info is not available, I would like to know the pixel aspect ratio (if not square). Why? Because when I run my direct3D app in fullscreen, the pixel aspect is not always square and I have an image not well stretched.
This happens with a 1920x1080 monitor (native) and when I use 1600x900 resolution in full screen.
Any idea to fix this bug?
Thanks.
-
September 6th, 2011, 04:10 AM
#2
Re: Get Monitor Resolution
there u go:
int width = GetSystemMetrics(SM_CXSCREEN);
int height = GetSystemMetrics(SM_CYSCREEN);
-
September 7th, 2011, 09:16 AM
#3
Re: Get Monitor Resolution
Note that SM_CXSCREEN/SM_CYSCREEN give the width/height of the primary monitor.
On a multi monitor system, you can use EnumDisplayMonitors or GetDeviceCaps.
-
September 7th, 2011, 10:16 PM
#4
Re: Get Monitor Resolution
no I don't want the resolution of the current display settings.
I want to know the physical resolution of the monitor (hardware). I have a 24" with 1920x1080 pixels and I want to get 1920 for width and 1080 for height even if my current resolution under windows is 1024x576
-
September 12th, 2011, 08:11 AM
#5
Re: Get Monitor Resolution
Try EnumDisplaySettingsEx with ENUM_CURRENT_SETTINGS
See also a previous discussion at http://www.codeguru.com/forum/showthread.php?t=348483
-
September 13th, 2011, 02:22 AM
#6
Re: Get Monitor Resolution
Originally Posted by olivthill2
This is not what the guy wants. He wants physical device resolution, while the proposed by you give logical resolution values.
Best regards,
Igor
-
September 14th, 2011, 01:16 PM
#7
Re: Get Monitor Resolution
I found a trick with DirectX to retrieve the physical resolution of the monitor
Enumerate all available full screen resolutions with EnumAdapterModes, and the biggest resolution should be the physical resolution
-
September 15th, 2011, 05:06 AM
#8
Re: Get Monitor Resolution
and the biggest resolution should be the physical resolution
No it shouldn't. It just depends on installed/selected video driver capabilities. In most likely 99% cases it's going to work as expected. But no guarantee for working always fine.
Best regards,
Igor
-
September 17th, 2011, 03:35 AM
#9
Re: Get Monitor Resolution
-
September 17th, 2011, 01:36 PM
#10
Re: Get Monitor Resolution
Again, it gives logical resolution, not monitor device physical characteristics.
Best regards,
Igor
-
September 17th, 2011, 10:04 PM
#11
Re: Get Monitor Resolution
Originally Posted by Igor Vartanov
Again, it gives logical resolution, not monitor device physical characteristics.
The MSDN site is somehow confusing, take an excerpt from the MSDN that came with VS6:
HORZRES Width, in pixels, of the screen.
VERTRES Height, in raster lines, of the screen.
This function targets PHYSICAL DEVICES.
You should try it first.
Last edited by srelu; September 17th, 2011 at 10:19 PM.
Reason: incomplete
-
September 18th, 2011, 09:09 PM
#12
Re: Get Monitor Resolution
Already did.
Best regards,
Igor
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|