Jump to content

View more

Image of the Day

Inventory ! Va falloir trouver une autre couleur pour le cadre D: #AzTroScreenshot #screenshotsaturday https://t.co/PvxhGL7cOH
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Getting desktop width and height with WinAPI

4: Adsense

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   

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

#2 Endurion   Members   

5320
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   

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   

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.