CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Posts
    21

    Fit StaticTextControl with text

    I'm kinda new at this...i'm making the jump from VB to Visual C++ and was wondering how i would make the rect for a static text control "AutoSize" to my member variable CString.

    Any help or source code would be helpful.
    Thanks
    Al


  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Fit StaticTextControl with text

    You could get a good idea of the width and height of the string by calling GetTextExtentPoint32(). You need to call CStatic::GetDC() to get the device context that you'll need for the first parameter. You may need to fudge a couple of pixels here and there to get a good fit, but this should get you on the right track. Also check the on-line help on GetTextExtentPoint32() for more info.

    Regards,

    Paul McKenzie


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