views:

285

answers:

1

I have a check box that I want to accurately measure so I can position controls on a dialog correctly. I can easily measure the size of the text on the control - but I don't know the "official" way of calculating the size of the check box and the gap before (or after) the text.

+3  A: 

I'm pretty sure the width of the checkbox is equal to

int x = GetSystemMetrics( SM_CXMENUCHECK );
int y = GetSystemMetrics( SM_CYMENUCHECK );

You can then work out the area inside by subtracting the following ...

   int xInner = GetSystemMetrics( SM_CXEDGE );
   int yInner = GetSystemMetrics( SM_CYEDGE );

I use that in my code and haven't had a problem thus far ...

Goz
Seems to work fine for me :)(Odd how it's "menu check" and there isn't an option for a regular check box?)
Mark Ingram