Dear experts,
In my application, I am using a custom control that is a GroupBox and a CheckBox instead of a common caption. I got the control here:
http://www.codeguru.com/cpp/cpp/cpp_mfc/article.php/c4149
I had to change the code to allow the checkbox to have multiline text:
CRect rc;
GetWindowRect(rc); // Get the rect of the GroupBox
this->ScreenToClient(rc);
// Change rc to be used for the checkbox
rc.left += 5;
rc.right = min(rc.left + czText.cx, rc.right - 5);
int iGroupBoxWidth = rc.right - rc.left;
double iLinesCount = ceil((double)czText.cx / iGroupBoxWidth);
rc.top -= (long)((iLinesCount - 1) * czText.cy / 2);
rc.bottom = (long)(rc.top + czText.cy * iLinesCount);
if(style == BS_AUTOCHECKBOX)
{
m_TitleBox.Create(strText, BS_AUTOCHECKBOX | BS_MULTILINE | WS_CHILD | WS_TABSTOP, rc, this, ID_TITLE);
}
As you can see, I change rc.top to have the middle of the checkbox neatly on the same level as the top edge of the groupbox, as in case of single-line caption. The multiline caption should be spread equally over and under that level. I can see that the checkbox is in the right place, so the top of the caption is calculated correctly, but the upper part of the caption text is cut off. I can see the caption not higher than the upper edge of the checkbox. Could you please tell me why this happens?
Thanks.
Here I attached an image to show how it looks.