Archived

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

dr_slash_uh

Windows size and Screen size

Recommended Posts

dr_slash_uh    122
I was wondering if someone can tell me how to find the actual size of the of the client area of a window using opengl. I set the window size to 800X600 but when i use the mouse to capture the coordinates it becomes 791x553. Is there a formula I must use to figure it out. I do have a menu bar that is taking away from some of the height though. Thanks

Share this post


Link to post
Share on other sites
GetClientRect()

assuming you're using windows of course. Unless I've gotten my functions twisted, GetWindowRect is the size of the window, GetClientRect gets the size of the window you can actually draw on.

[edit] figured I'd be more helpful and show usage too:
RECT clientRect;
GetClientRect(hWnd,&clientRect);

-Arek the Absolute

[edited by - Arek the Absolute on March 29, 2004 9:02:47 PM]

Share this post


Link to post
Share on other sites
Oluseyi    2103
Arek is correct. Note that the dimensions you pass to the window creation procedure set the window size, not the client area (the region you draw on) size.

To obtain a client area of specific dimensions, use AdjustWindowRect before calling CreateWindow[Ex].

Share this post


Link to post
Share on other sites
Oluseyi    2103
If you absolutely want a book, though, pick the appropriate version of Charles Petzold''s Programming Windows X (replace X with your target - Me, XP, 2000, 98, etc) series.

Share this post


Link to post
Share on other sites
Jerry Velders    122
One other note .. GetWindowRect returns the coords of the window in screen (desktop) space, while GetClientRect returns coords relative to the window (ie. upper left always 0,0)

Share this post


Link to post
Share on other sites