Recent

Author Topic: Autosize  (Read 6084 times)

mikiwoz

  • Full Member
  • ***
  • Posts: 130
Autosize
« on: September 28, 2004, 05:33:52 pm »
Does TLabel's AutoSize work?
I have a small label, and when I set the Caption property to a realy LONG caption - notthing happens, though I have AutoSize set to True.
I tried both DoAutoSize and AdjustSize after setting the caption, but I keep on getting errors:
"Error: identifier idents no member "DOAUTOSIZE" (or "ADJUSTSIZE")"
"Error: illegal expresson"

StaticText does not have WordWrap property, and therefore I cannot use it.  :?

mikiwoz

  • Full Member
  • ***
  • Posts: 130
Autosize
« Reply #1 on: November 03, 2004, 10:23:01 am »
Well, I've tried StaticText but it's AutoSize also does not work, at least for me. Is it some kind of error, or are those functionalities not implemented in the LCL yet?

I have an FPC ver 1.9.5 / Lazarus 0.9.2 beta / Linux (kernel 2.6.3)

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Autosize
« Reply #2 on: November 03, 2004, 04:55:23 pm »
I think it is not implemented yet.

mikiwoz

  • Full Member
  • ***
  • Posts: 130
Autosize
« Reply #3 on: November 03, 2004, 08:09:59 pm »
Any idea when it'll be implemented, then? :)

Adam.Pilorz

  • Jr. Member
  • **
  • Posts: 67
    • http://www.pilotmp3.devtown.net
Autosize
« Reply #4 on: November 03, 2004, 08:12:19 pm »
You can always use something like: Label1.Width:=Form1.Canvas.TextWidth(Label1.Caption);. Of course you must set Form1.Canvas.Font properties (FontName and Size) to Label1.Font props. I'm using such method and it works rather good.

mikiwoz

  • Full Member
  • ***
  • Posts: 130
Autosize
« Reply #5 on: November 05, 2004, 11:20:15 am »
Thanks for the hint, I've managed to write a little bit more sophisticated autosizing function now. :)
But there are two more issues, this time concerning WordWrap property:
1. When WordWrap is set to true, I cannot centre the text on the label. I suppose "it is not implementted yet" :)
2. When I assign some text to SomeLabel.Caption, WordWrap wraps the text properly. Now, when I resize this labell with my AutoSize implementation, text is not re-wrapped for the label's new dimensions. I worked around this problem simply (but definetely not neatly) by re-assigning the text to  the label (setting WordWrap to false and then back to true did not work).

Adam.Pilorz

  • Jr. Member
  • **
  • Posts: 67
    • http://www.pilotmp3.devtown.net
Autosize
« Reply #6 on: November 05, 2004, 05:59:17 pm »
Hmm... You can always add SomeLabel.Caption:=SomeLabel.Caption in OnResize event. However it might be not the best way :). And about centering, unfortunatly I have no idea, how to do it beter...

mikiwoz

  • Full Member
  • ***
  • Posts: 130
Autosize
« Reply #7 on: November 07, 2004, 03:52:45 pm »
I've tried it before, it does not work, I suppose it's due to optimization :) Well, anyway, thaks for the TextWidth hint. Helped a lot!

 

TinyPortal © 2005-2018