Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Getting desktop width and height with WinAPI


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 stenny   Members   -  Reputation: 142

Like
0Likes
Like

Posted 19 November 2006 - 12:14 AM

Hello, How can I get the width and height of the desktop, with just bear-naked WinAPI? For the window's size you can use GetWindowRect, but what's the desktop's function? -Stenny

Sponsor:

#2 Endurion   Crossbones+   -  Reputation: 3847

Like
0Likes
Like

Posted 19 November 2006 - 12:42 AM

Use GetSystemMetrics with SM_CXSCREEN and SM_CYSCREEN.

Things get a bit more complicated if you want to detect a virtual desktop with more than one monitor. If it's enough you can use SM_CXVIRTUALSCREEN and S_CYVIRTUALSCREEN (i might be off with the constants name).

#3 Todo   Members   -  Reputation: 451

Like
1Likes
Like

Posted 19 November 2006 - 12:46 AM

You could use either
a) GetSystemMetrics( SM_CXSCREEN ), GetSystemMetrics( SM_CYSCREEN ) OR
b) GetDeviceCaps( hDC, HORZRES ), GetDeviceCaps( hDC, VERTRES )

If you have a multi-monitor setup, there's also the notion of SM_CXVIRTUALSCREEN
and SM_CYVIRTUALSCREEN.

EDIT: beaten to it ;-)

#4 stenny   Members   -  Reputation: 142

Like
1Likes
Like

Posted 19 November 2006 - 12:49 AM

Ah, I got another way!


int Width, Height
HWND hDWnd;
RECT ScreenRect;

hDWnd = GetDesktopWindow();
GetWindowRect(hDWnd, &ScreenRect);

Width = ScreenRect.right;
Height = ScreenRect.bottom;




-Stenny




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS