Skip to content
GitLab
    • GitLab: the DevOps platform
    • Explore GitLab
    • Install GitLab
    • How GitLab compares
    • Get started
    • GitLab docs
    • GitLab Learn
  • Pricing
  • Talk to an expert
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
    Projects Groups Snippets
  • Sign up now
  • Login
  • Sign in / Register
  • Lazarus Lazarus
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 2,112
    • Issues 2,112
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 14
    • Merge requests 14
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • FPC
  • LazarusLazarus
  • LazarusLazarus
  • Issues
  • #21877
Closed
Open
Issue created Apr 28, 2012 by FPC Admin account@fpc_adminOwner

TStaticText : bad Width with Autosize := True;

Original Reporter info from Mantis: HexNihilo
  • Reporter name:

Description:

Hello

Simply code :

procedure TForm1.FormCreate(Sender: TObject);
{uses StdCtrls}
var
 i : Integer;
begin
 sTmp := 'Test';
 for i := 0 to 99 do sTmp := sTmp + LineEnding +
                            'Line '+ IntToStr(i) + 'gfhg jhgf jhghg';

 aStaticText := TStaticText.Create(nil);
 with  aStaticText do begin
  Parent   := Form1;
  AutoSize := False;
  Visible  := False;
 end;

 bStaticText := TStaticText.Create(nil);
 with  bStaticText do begin
  Parent   := Form1;
  AutoSize := False;
  Visible  := False;
  Width    := 5000;    {or other > Real width. Why ???}
 end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
 aW, bW : Integer;
begin
 with aStaticText do begin
  BeginUpdateBounds;
  Caption  := sTmp;
  Visible  := True;
  AutoSize := True;
  aW       := Width;
  Visible  := False;
  EndUpdateBounds;
 end;
 with bStaticText do begin
  BeginUpdateBounds;
  Caption  := sTmp;
  Visible  := True;
  AutoSize := True;
  bW       := Width;
  Visible := False;
  EndUpdateBounds;
 end;
 Showmessage(IntToStr(aW) +'-' +IntToStr(bW));
end;                           

Result : 69-149 (149 is correct). It seem's that 69 is a default value.
You need to declare Autosize := False and a "big" width... and Autosize := True.

I suppose that it is a bug.
Regards

Additional information:

Ubuntu 10.04 LTS - lazarus_0.9.31.35363-0_amd64 - fpc_2.6.1-120214_amd64

Mantis conversion info:

  • Mantis ID: 21877
  • Version: 0.9.31 (SVN)
  • Fixed in revision: r59018 (#0a8bae0c)
Assignee
Assign to
Time tracking