• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 501
  • Last Modified:

How to calculate width and height of check box?

How to calculate width and height of check mark of CButton created with BS_CHECKBOX?

I need to resize this button if text not get in client area of button.
If I use simple button I calculate width and height of text by using DrawText with nFormat value DT_CALCRECT, but with button with BS_CHECKBOX flag DrawText not calculating text's width correctly...

Can I calculate width and height of this check mark? Or this value stored in Registry?

If I can't I need to use my own check mark in owner draw button... :-(
0
Nicolay_Ch
Asked:
Nicolay_Ch
  • 2
1 Solution
 
chensuCommented:
If the check box does not have text (the caption of the button), use the following code.

CRect rect;
TheButton.GetWindowRect(&rect);

int nWidth = rect.Width(), nHeight = rect.Height();
0
 
Nicolay_ChAuthor Commented:
I try it two days ago...
But when I create Control I need to set this Rect in Create func...
What for I read this Rect if I setting it?
0
 
mikeblasCommented:

HBITMAP hBmp = LoadBitmap(NULL, MAKEINTRESOURCE(OBM_CHECK));

if (hBmp != NULL)
{
   BITMAP bmp;
   GetObject(hBmp, sizeof(BITMAP), &bmp);
   printf("%d wide, %d high\n", bmp.bmWidth, bmp.bmHeight);
}

..B ekiM
0
 
Nicolay_ChAuthor Commented:
Ha-ha-ha... ;-)
Execelent...
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now