Recent

Author Topic: Label Optimal Fill  (Read 286 times)

Raul_ES

  • Full Member
  • ***
  • Posts: 174
  • My interests: Healthcare & Computers
    • My Linkedin Profile, you can add me to stay in contact.
Label Optimal Fill
« 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



Pharmacy + Chemistry + Biology + Healthcare + Computing

If you have any interest or project related with these areas feel free to contact me!

wp

  • Hero Member
  • *****
  • Posts: 7645
Re: Label Optimal Fill
« Reply #1 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.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

lucamar

  • Hero Member
  • *****
  • Posts: 3089
Re: Label Optimal Fill
« Reply #2 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.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.8/FPC 3.0.4 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Raul_ES

  • Full Member
  • ***
  • Posts: 174
  • My interests: Healthcare & Computers
    • My Linkedin Profile, you can add me to stay in contact.
Re: Label Optimal Fill
« Reply #3 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
Pharmacy + Chemistry + Biology + Healthcare + Computing

If you have any interest or project related with these areas feel free to contact me!

 

TinyPortal © 2005-2018