Lazarus

Free Pascal => Beginners => Topic started by: Raul_ES on August 11, 2020, 05:31:23 pm

Title: Label Optimal Fill
Post by: Raul_ES on August 11, 2020, 05:31:23 pm
Hello,

I dont seem to make a label to resize its text fonts (to an optimal size) whenever the label changes it's dimensions. Check the blue box with the number please. I am sure it has to be something easy that I missed somewhere.

I thought that setting OptimalFill := True would just do the trick.


??

regards



Title: Re: Label Optimal Fill
Post by: wp on August 11, 2020, 05:48:07 pm
It is working here (Laz trunk/FC 3.2.0, Win 10): OptimalFill := true and AutoSize := false do the trick.

What are your Lazarus/FPC versions? OS? There was a fix related to Optimalfill in May 2017, about Laz 1.6.x time. If you have a Lazarus of that period you should definitely upgrade.
Title: Re: Label Optimal Fill
Post by: lucamar on August 11, 2020, 06:12:37 pm
I have found (thorugh trial and error) that after resizing the label (for example if it's anchored on the four sides and the form is maximized) the "OptimalFill" isn't recalculated unless you set again the label's caption. It seems it doesn't happen always but enough times that I now automatically add SomeLabel.Caption := 'whatever'; whenever that might happen.
Title: Re: Label Optimal Fill
Post by: Raul_ES on August 13, 2020, 12:58:58 am
Thanks,

I use CodeTyphon 7.00/7.10 and FPC 3.3.1 and also Lazarus 2.0.18 with FPC 3.0.4

The label is anchored at every side. Thanks to your suggestions, I solved the situation forcing to update the label whenever is resized. It's a little wierd but it actually makes it work:

Code: Pascal  [Select][+][-]
  1. procedure TFrame_posHDSqt.Panel14Resize(Sender: TObject);
  2. var
  3.   value : string;
  4. begin
  5.   value := Label_totalImport.Caption;
  6.   Label_totalImport.Caption := ' ';
  7.   Label_totalImport.Caption:= value;
  8. end;
  9.    

regards
TinyPortal © 2005-2018