CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Threaded View

  1. #1
    Join Date
    Aug 2009
    Posts
    27

    Checkable GroupBox problem

    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_...icle.php/c4149
    I had to change the code to allow the checkbox to have multiline text:
    Code:
          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?
    I have attached an image to show how it looks.
    Thanks.
    Attached Images Attached Images
    Last edited by dpreznik; February 9th, 2011 at 04:22 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured