Sign in to follow this  
Stroyev

How to get desktop resolution? (Win32)

Recommended Posts

I have two monitors and extended desktop. True resolution is (2*1280, 1024). But, standart function: GetDeviceCaps(::GetDC(0), DESKTOPHORZRES); and GetSystemMetrics( SM_CXSCREEN ); returned desktop width as 1280.

Share this post


Link to post
Share on other sites
You want to use the EnumDisplayDevices method. Here's a sample:


DISPLAY_DEVICE device;
device.cb = sizeof(DISPLAY_DEVICE);

for(int i = 0; ; i++)
{
if (!::EnumDisplayDevices(NULL, i, ref device, 0))
break;

printf("Enumerated device: (id: %s) (name: %s) (state: %d)\n", device.DeviceID, device.DeviceName, device.StateFlags);

// If it's not connected to the desktop, then ignore it.
if ((device.StateFlags & ATTACHED_TO_DESKTOP) == 0)
continue;

// Get the display mode settings of this device.
DEVMODE devMode;
if (!::EnumDisplaySettings(device.DeviceName, ENUM_CURRENT_SETTINGS, &devMode))
continue;

printf(" Position: (%d, %d) Size: %dx%d\n", devMode.dmPosition.x, devMode.dmPosition.y,
devMode.dmPelsWidth, devMode.dmPelsHeight);
}


Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by Stroyev
thanks,

But, I am work in VisualStudio6, and its have very old PlatformSDK :)
Nothing EnumDisplayDevices function :D
So download a new PlatformSDK freely from microsoft. If VC6 won't compile it, download Visual C++ 2005 Express Edition for free (legally) at
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=126678&SiteID=1

-Extrarius

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this