Subj : Re: Size problems with TTextGadget To : borland.public.cpp.borlandcpp From : Bob Gonder Date : Tue Apr 19 2005 10:17 am Alan Jones wrote: >However, I find I have to set the numChars to 6 to hold a message that is 11 >characters wide. Yes, that is to be expected. > This is on Windows NT. When I run the same program on >Windows XP, the space for this Gadget is much wider. So much wider that >most of my gadgets are pushed right off the screen. Don't know why that is. Have a look at GetTextMetrics() and the tmMaxCharWidth that it returns. You might be able to use that value to calculate relatively stable sized gadgets. Then, you could use GetTextExtentPoint32() to calculate the size of you actual string. TEXTMETRIC metric; SIZE size; GetTextMetrics( hdc, &metric ); GetTextExtentPoint32( hdc, TheString, strlen(TheString, &size ); GadgetChars = 1+ (size.X / metric.tmMaxCharWidth). .