Recent

Author Topic: Dynamically set Height and Width of a TStaticText  (Read 2037 times)

Relativity

  • Full Member
  • ***
  • Posts: 103
Dynamically set Height and Width of a TStaticText
« on: October 06, 2015, 04:14:50 pm »
I have a TPanel containing a TLabel and a TStatictText.
The panel can be resized by the user in run-time and I want the TLabel and TStaticText in it to automatically resize thereupon, in order to fit the instantaneous size of the TPanel.

For the Label I do something like:
TLabel.Width := Round (TPanel.Width * 0.9);
TLabel.Height := Round (TPanel.Height * 0.9);
etc.

having set TLabel.OptimalFill to True in the object inspector.

For the TStaticText I would like to do the same, but it doesn't work: the size on the text remains unchanged and, on the other side, for TStaticText there is no OptimalFill property available to set.
I use TStaticText because that inscription has a fixed text and I thought that, when the text is fixed, one should use TStaticText, because maybe it demands less resources.
Do you think that I should use TLabel instead ?
"How'm I gonna get through?"
  -- Pet Shop Boys

zeljko

  • Hero Member
  • *****
  • Posts: 1594
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Dynamically set Height and Width of a TStaticText
« Reply #1 on: October 06, 2015, 05:43:22 pm »
TLabel is TGraphicControl, TStaticText is widgetset control (TWinControl) and it has handle which points to widgetset hwnd, so it's obvious that TLabel is "cheaper" control.

Relativity

  • Full Member
  • ***
  • Posts: 103
Re: Dynamically set Height and Width of a TStaticText
« Reply #2 on: October 08, 2015, 09:29:32 am »
Thank you.
I have changed those TStaticText inscriptions to TLabel.
"How'm I gonna get through?"
  -- Pet Shop Boys

 

TinyPortal © 2005-2018