> On Aug 21, 2006, at 4:11 PM, Phil M wrote: > > > On Aug 21, 2006, at 3:39 PM, Brian Heibert wrote: > >> I tried the previous solution that worked for PushButtons but now > >> I am using a custom button that looks better with Brushed Metal > >> windows > > > > You can only guesstimate the size of the string (in pixels) with Len > > (). Unless you use a monospaced font like Courier, different > > characters take different amounts of space... a caption of 10 m's > > "mmmmmmmmmm" is considerably longer (in pixels) than 10 dots/ > > periods "..........". The "m" character is usually the longest > > character in the roman alphabet, and should be a good "worst-case" > > size for estimations. > > Or, do as had been suggested before and actually measure how many > pixels that text will take. > > dim p as picture > p = new picture (1,1,32) > > p.graphics.textfont = me.textfont > p.graphics.textsize = me.textsize > > return p.graphics.stringWidth(me.caption) > > the solution that worked for a push button should mostly still be on > the right track for this custom button
There is a Microsoft sample on the link below that shows how to size Text in Pixels using the GetTextExtentPoint32 API: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/fontext_8smq.asp Gregg Morrison _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html>
