Jump to content
  • Advertisement
Sign in to follow this  
BS-er

Setting and using interior window dimensions

This topic is 4499 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 am writing a windows program in which I need to create a "canvas" that is 480 pixels wide and 640 pixels high. The window has a menu above. When I create the window, the OUTSIDE dimensions are 480x640. When I blit a bitmap starting at 0,0, it is on top of the window borders. However I want a surefire approach to make the interior of the window 480x640, regardless of the menu bar and title bar. Also, when setting pixels or blitting, I want to make sure I know the pixel indices of the interior corners. Any suggestions?

Share this post


Link to post
Share on other sites
Advertisement
The interior of a window is called "client rect" in windows. Obviosly the other stuff (border, caption) is called non-client rect.

To get the size of different parts of the non-client rect use GetSystemMetrics with some of these values:
SM_CXFIXEDFRAME
SM_CYFIXEDFRAME
SM_CXSIZEFRAME
SM_CYSIZEFRAME
SM_CYCAPTION
SM_CYMENU

In that way you can get the difference between the exterior and interior of the window. You can also use the difference in size returned by GetClientRect (retrieves the interior size) and GetWindowRect (retrieves the exterior size).

Bonus tip: You can convert between screen coordinates and client coordinates with ScreenToClient and ClientToScreen.

Share this post


Link to post
Share on other sites
Quote:
Original post by Extrarius
Use AdjustWindowRect(Ex) to convert a rectangle filled with the desired client size to the dimensions needed for the whole window.


Great thanks for that!
I just realized that my calculations (clientSize -> windowSize) for CreateWindow were wrong and I was loosing a few pixels. Now that I corrected this, my client rect and DX backbuffer are finally same size - everything looks soooo sharp now[smile].

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!