Advertisement

Screen Rect

Started by May 15, 2000 04:42 PM
2 comments, last by fury3 24 years, 7 months ago
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
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
Advertisement
And this will also do it

int ScreenWidth = GetSystemMetrics(SM_CXSCREEN);
int ScreenHeight = GetSystemMetrics(SM_CYSCREEN);
A polar bear is a rectangular bear after a coordinate transform.
Thanx!

This topic is closed to new replies.

Advertisement