[Lazarus] Fit TFrom's width so that it's caption isn't cut off?
Avishai
avishai.gore at gmail.com
Sun Nov 17 15:29:13 CET 2013
I used this code to AutoSize a TMemo but you might be able to modify
it for your needs. The problem I see is that TForm.Caption.Font is
not effected by the TForm.Font. Maybe set the Font to default in the
routine.
------------
function GetTextHeight(ACtrl: TControl): Integer;
var
C: TBitMap;
begin
Result:= -1;
C := TBitmap.Create;
try
C.Canvas.Font.Assign(ACtrl.Font);
Result:= C.Canvas.TextHeight('TextHeight');
finally
C.Free;
end;
end;
procedure TForm1.BitBtn3Click(Sender: TObject);
var
H: Integer;
begin
H:= GetTextHeight(Memo1);
If H>-1 then
Memo1.Height:= (H*Memo1.Lines.Count)+H div 2;
end;
On Sun, Nov 17, 2013 at 3:47 PM, Bart <bartjunk64 at gmail.com> wrote:
> Hi all,
>
> Is there a crossplatform way to determine the necessary width for a
> TForm so that it's caption wont be cut off?
> It does have to work regardless of the (amount of) bordericons the form has.
>
> NB. Needed for http://bugs.freepascal.org/view.php?id=19637
>
> Bart
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
--
Shalom,
Avishai
avishai.gore at gmail.com
אבישי גוֹר
More information about the Lazarus
mailing list