tags:

views:

697

answers:

2

I'm writing a direct3d application and after noticing strange bugs such as anti-aliasing occurring even when it was turned off and the mouse pointer not lining up to things with the same coordinates as itself I discovered that when creating a window the width and height parameters include the border. The program was rendering a 800x600 graphics output to a window of the same size, but because of the borders it was squished into 792x566 rectangle. I've increased the size of the window to compensate, but this does not work if the system uses a border style other the standard XP style. (Classic style, for example)

Is there a way to tell what the border width and heights will be before I create the window?

+2  A: 

It sounds like you are looking for the GetSystemMetrics function. For example, the border width in pixels is returned by

GetSystemMetrics(SM_CXBORDER)

ADDED: For the total size you will need to add together the various "pieces" of the non-client area: border, frame sizes, title bars, etc.

DocMax
You'll need more than that when you create the window depending on whether you have menus/captions/etc. So make sure you cater for those cases as well as SM_CXBORDER.
OJ
Wow thanks I didn't know GetSystemMetrics() was so useful.
da_code_monkey
+2  A: 

Another option would be to make sure the D3D surface is the same size as the client rectangle size (GetClientRect()). Then you know you'll render to the appropriate size and not have to worry at all about the width of menus, borders, etc.

OJ