Autor Beitrag
FriFra
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 557

Win XP Prof, Win XP Home,Win Server 2003,Win 98SE,Win 2000,Win NT4,Win 3.11,Suse Linux 7.3 Prof,Suse Linux 8.0 Prof
D2k5 Prof, D7 Prof, D5 Standard, D3 Prof, K3 Prof
BeitragVerfasst: So 30.06.02 12:00 
Ich habe in meinem Programm ein Image, auf welches eingelesene Werte in einem eingestellten Intervall geschrieben werden. Ich benötige dafür mehrere verschiedene Schriftarten und habe deshalb für die jeweiligen Textelemente Variablen vom Typ TFont angelegt.

Ändere ich nun zur Laufzeit die Eigenschaften einer TFont Variable werden machmal auch die Werte beliebiger anderer Font-Varialben mit geändert... dann hilft nur noch ein Programmneustart um die Werte wieder zu "entkoppeln".

Ausgaberoutine (Beispiel):
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
//Text1
Image1.Canvas.Lock;
Image1.Canvas.Font:=T1Font;
Image1.Canvas.TextOut(0,0, 'Text1');
 Image1.Canvas.Unlock;
 //Text1

//Text2
Image1.Canvas.Lock;
Image1.Canvas.Font:=T2Font;
Image1.Canvas.TextOut(0,10, 'Text2');
 Image1.Canvas.Unlock;
 //Text2

//Text3
Image1.Canvas.Lock;
Image1.Canvas.Font:=T3Font;
Image1.Canvas.TextOut(0,30, 'Text3');
 Image1.Canvas.Unlock;
 //Text3



Fonteinstellung (Beispiel):
ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
procedure TfrmLabel.BitBtn1Click(Sender: TObject);
begin
with FontDialog1 do
 begin
 Font := Main.T1Font;
  if Execute then
   begin
   Main.T1Font := Font;
   //Neu schreiben...
   ChangeProp(Sender);
   end;
 end;

procedure TfrmLabel.BitBtn2Click(Sender: TObject);
begin
with FontDialog1 do
 begin
 Font := Main.T2Font;
  if Execute then
   begin
   Main.T2Font := Font;
   //Neu schreiben...
   ChangeProp(Sender);
   end;
 end;

procedure TfrmLabel.BitBtn3Click(Sender: TObject);
begin
with FontDialog1 do
 begin
 Font := Main.T3Font;
  if Execute then
   begin
   Main.T3Font := Font;
   //Neu schreiben...
   ChangeProp(Sender);
   end;
 end;
Maverick
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: Di 02.07.02 11:02 
Auf jeden fall sind TFont wie alle Instanzen von Klassen immer Pointer,
wenn du
Main.T3Font := Font ausführst, zeigen beide Fonts auf den gleichen Speicherbereich, änderst du danach einen Wert, ändert sich auch der andere
FriFra Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 557

Win XP Prof, Win XP Home,Win Server 2003,Win 98SE,Win 2000,Win NT4,Win 3.11,Suse Linux 7.3 Prof,Suse Linux 8.0 Prof
D2k5 Prof, D7 Prof, D5 Standard, D3 Prof, K3 Prof
BeitragVerfasst: Di 02.07.02 11:25 
Über Font.Assign(...) habe ich das Problem in den Griff bekommen....
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Di 02.07.02 11:27 
Maverick hat folgendes geschrieben:
...zeigen beide Fonts auf den gleichen Speicherbereich, änderst du danach einen Wert, ändert sich auch der andere
Nicht unbedingt. In den meisten Fällen handelt es sich um ein Property und wenn Du diesen Properties einen Wert zuweist sieht die Zuweisung dann meistens intern so aus:
ausblenden Quelltext
1:
2:
3:
4:
Procedure tMyClass.SetFont (aValue: tFont);
Begin
  fFont.Assign (aValue)
End;
Gruß