TStaticText : bad Width with Autosize := True;
Original Reporter info from Mantis: HexNihilo
-
Reporter name:
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)