Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

fury3

Screen Rect

This topic is 6913 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m trying to find the width and height of the screen using ''GetBoundsRect()'', but I cannot get it to work: RECT Rect; int ScreenWidth; int ScreenHeight; GetBoundsRect(GetDC(0), &Rect, 0); ScreenWidth = Rect.right; ScreenHeight = Rect.bottom; Sometimes the values are correct, but mostly they are too large. Is this the right approach? Are their other ways to find the width and height of the screen? Thanx in Advance

Share this post


Link to post
Share on other sites
Advertisement
A call to GetDesktopWindow() will return a pointer to the desktop. Then call GetWindowRect(LPRECT rect) to get the screen rectangle.

CWnd *screen = GetDesktopWindow();
RECT desktop;
screen->GetWindowRect(&desktop);

desktop.x is the width (in pixels), and desktop.y is the height.

Do do it with GetBoundsRect(), the first parameter GetDC(0) is not good, since this is not a pointer to the screen but an empty pointer to nothing. From the previous code, you can do GetBoundsRect(screen->GetDC(), desktop);

Edited by - Zipster on May 15, 2000 6:47:39 PM

Share this post


Link to post
Share on other sites
And this will also do it

int ScreenWidth = GetSystemMetrics(SM_CXSCREEN);
int ScreenHeight = GetSystemMetrics(SM_CYSCREEN);

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!