Autor Beitrag
AlexBegin
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 39



BeitragVerfasst: Di 12.05.09 15:47 
Ich möchte gern FontDialog.Font.Style in einer Variabel speichern und dies später in eine Ini-Datei abspeichern.

Bei

FontDialog.Font.Name (String)
FontDialog.Font.Color (Integer)
FontDialog.Font.Size (integer)

funktioniert es. Nur bei FontDialog.Font.Style kommt immer wieder eine Fehlermeldung, das man zwei verschiedene Variabel-Typen benutzt. Kann mir jemand weiter helfen?

Bis dann Alex
Jakob_Ullmann
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Di 12.05.09 16:10 
Was hat die Variable denn für einen Typ? Sollte eigentlich TFontStyles sein.
AlexBegin Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 39



BeitragVerfasst: Di 12.05.09 16:40 
Richtig, FontDialog.Font.Style ist der Typ TFontStyles. Ich möchte aber diese Information von FontDialog.Font.Style in eine Variabel zwischenspeichern. Wenn ich eine Variabel als String deklariere, z.B.

ausblenden Quelltext
1:
Font_Style_Test := FontDialog.Font.Style					


gibt es die Fehlermeldung die ich oben genannt habe. Wie kann ich trotzdem die Information von FontDialog.Font.Style in eine Variabel zwischenspeichern.

---Moderiert von user profile iconNarses: Beiträge zusammengefasst---

Habe gerade nochmals gesucht und eine Lösung von smiegel gefunden. Damit funktioniert es einwandfrei.

www.delphi-forum.de/...fontdialog+speichern
Jakob_Ullmann
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Di 12.05.09 18:58 
Zitat:
Richtig, FontDialog.Font.Style ist der Typ TFontStyles. Ich möchte aber diese Information von FontDialog.Font.Style in eine Variabel zwischenspeichern. Wenn ich eine Variabel als String deklariere, z.B.


Und wenn du das in einer Variablen zwischenspeichern willst, deklariere die Variable doch einfach auch als TFontStyles:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var
  a: TFontStyles;
begin
  FontDialog1.Execute;
  a := FontDialog1.Font.Style;
end;


klappt einwandfrei.

Zitat:
Habe gerade nochmals gesucht und eine Lösung von smiegel gefunden. Damit funktioniert es einwandfrei.


Meinst du die hier?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
var fs:Integer;
...
fs:=Integer(TFontStyle(Font.Style));
...
...
// in die andere Richtung
Font.Style:=TFontStyles(TFontStyle(fs));
...


Abgesehen davon, dass eine Deklaration von fs als Byte vielleicht platzsparender wäre, ist das doch etwas umständlich. Im Speicher sieht das afaik bei beiden gleich aus...