Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Formula for font size and textbox width
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00455959
Message ID:
00455965
Views:
28
>I'm sure this has been asked before, but the search isn't working. Is there a formula that will take the font, font size, and the number of characters and return what width the textbox should be set to? I realize proportional fonts make things harder, but if it used an average character width, that would be fine.
>
>Thanks,
>
Michelle,

This piece of code should help you (see also FAQ #7959676 by Vlad):
     local lcCaption, lcFont, lnSize, lcStyle, lnCaptionWidth, lnSpaces
* Form.scalemode should be = 0 - Pixels
     lcFont = space(32)  
     lnSize = 0
     lcStyle = space(4)
* Retrieve  Title Bar font attributes    
     =GetTitleAttributes(@lcFont,@lnSize, @lcStyle)
     lcCaption=rtrim(pcCaption) +'version ' +alltrim(transform(this.nVersion))
     lnCaptionWidth=txtwidth(lcCaption,lcFont,lnSize,lcStyle)*;
          fontmetric(6,lcFont,lnSize,lcStyle)+iif(this.controlbox, ;
          iif(this.maxbutton or this.minbutton, 3, 1) * sysmetric(33)+sysmetric(16),0)
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform