TFont ohne Create und Free.

Rund um die LCL und andere Komponenten
Antworten
Mathias
Beiträge: 6204
Registriert: Do 2. Jan 2014, 17:21
OS, Lazarus, FPC: Linux (die neusten Trunk)
CPU-Target: 64Bit
Wohnort: Schweiz

TFont ohne Create und Free.

Beitrag von Mathias »

Darf man das so machen, oder muss da noch eine Create oder Free rein ?

Code: Alles auswählen

procedure TForm1.Button1Click(Sender: TObject);
var
  fnt: TFont;
begin
  fnt := Font;
  if FontDialog1.Execute then begin
    fnt := FontDialog1.Font;
  end;
  Label1.Font := fnt;
end; 
Mit Lazarus sehe ich grün
Mit Java und C/C++ sehe ich rot

Warf
Beiträge: 1910
Registriert: Di 23. Sep 2014, 17:46
OS, Lazarus, FPC: Win10 | Linux
CPU-Target: x86_64

Re: TFont ohne Create und Free.

Beitrag von Warf »

Label.SetFont (welches von der Font property ausgeführt wird) benutzt Assign, also macht ne deep-copy vom font. Also absolut kein problem

Mathias
Beiträge: 6204
Registriert: Do 2. Jan 2014, 17:21
OS, Lazarus, FPC: Linux (die neusten Trunk)
CPU-Target: 64Bit
Wohnort: Schweiz

Re: TFont ohne Create und Free.

Beitrag von Mathias »

Code: Alles auswählen

 fnt := FontDialog1.Font;
Dies auch nicht ?
Mit Lazarus sehe ich grün
Mit Java und C/C++ sehe ich rot

Antworten