How to get desktop resolution? (Win32)

Started by
6 comments, last by GameDev.net 18 years, 5 months ago
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.
Advertisement
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);}
thanks,

But, I am work in VisualStudio6, and its have very old PlatformSDK :)
Nothing EnumDisplayDevices function :D
then you need something like:

cxScreen = GetSystemMetrics(SM_CXSCREEN);
cyScreen = GetSystemMetrics(SM_CYSCREEN);
>GetSystemMetrics( SM_CXSCREEN );
its returned only first desktop size.
ok I have no idea then :(
Quote:Original post by DMINATOR
ok I have no idea then :(


Create wrap dll (for VisualStudio7) and use answer of Dean Harding :)
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

This topic is closed to new replies.

Advertisement