![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 7 of 7 total |
![]() |
Mon, Mar 11 2013 11:45 AM | Permanent Link |
Matthew Jones | Is there a way to find out how wide text would be on screen?
Something like the Canvas.TextWidth or DrawText with DT_CALCRECT. The reason I am asking is that I want to be able to "word wrap" some radio buttons. Given they don't do it, but a TLabel does (with the right options), I'd like to work out if text will fit a radio button, and if not, to truncate it and put the rest in a TLabel. But to do that nicely I need to know how wide some text will be. I could just go with "30 characters" or something, but 'iiii' is narrower than 'WWWW' and I don't want to risk cutting off characters. Open to suggestions here. One thought is that I could stick it in a TLabel, and see how high it goes, but then I'd not know where the break was. Also, I don't know if the height is "live" or calculated asynchronously. I know not of how this Javascript magic works, so would appreciate any insight anyone can offer. /Matthew Jones/ |
Mon, Mar 11 2013 2:02 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Matthew,
<< Is there a way to find out how wide text would be on screen? Something like the Canvas.TextWidth or DrawText with DT_CALCRECT. >> Yes, you can use the (undocumented) TextManager class in the WebCtrls.wbs unit: TTextManager = class public function TextHeight(const Value: String; Font: TFont): Integer; function TextWidth(const Value: String; Font: TFont): Integer; end; Just use the TextWidth method to find out how wide a string is, given a particular font. EWB uses this for things like message dialogs, etc. If you have any other questions, please let me know. Tim Young Elevate Software www.elevatesoft.com |
Mon, Mar 11 2013 3:28 PM | Permanent Link |
Matthew Jones | Brilliant, I will experiment soon. Presumably I can pass in the Font property of a
radio button or something. /Matthew Jones/ |
Tue, Mar 12 2013 4:17 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Matthew,
<< Brilliant, I will experiment soon. Presumably I can pass in the Font property of a radio button or something. >> Correct. Tim Young Elevate Software www.elevatesoft.com |
Thu, May 9 2013 1:23 PM | Permanent Link |
Matthew Jones | Just to confirm, this TextManager all works just perfectly.
/Matthew Jones/ |
Tue, Sep 8 2015 9:39 AM | Permanent Link |
Walter Matte Tactical Business Corporation | Is there an similar function to TextWidth in EWB2?
Walter |
Tue, Sep 8 2015 9:54 AM | Permanent Link |
Walter Matte Tactical Business Corporation | Found it.....
TContentSizer in WebUI. walter |
This web page was last updated on Friday, February 14, 2025 at 12:13 PM | Privacy Policy![]() © 2025 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |