Click to See Complete Forum and Search --> : Fit StaticTextControl with text


alcon17
May 26th, 1999, 02:52 PM
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

Paul McKenzie
May 26th, 1999, 09:02 PM
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