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):
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):
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; |