Screen Rect
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.
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement