Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Variable vom Typ "TFontStyles" in Ini speichern (https://www.delphipraxis.net/134513-variable-vom-typ-tfontstyles-ini-speichern.html)

Helmi 23. Mai 2009 18:46


Variable vom Typ "TFontStyles" in Ini speichern
 
Hallo,

wie könnte ich am Besten und am Einfachsten eine Variable vom Typ "TFontStyles"
in einer Ini-Datei speichern?

toms 23. Mai 2009 18:51

Re: Variable vom Typ "TFontStyles" in Ini speicher
 
ungetestet:

Delphi-Quellcode:
var
  fs : Longint;
Delphi-Quellcode:
 
// schreiben:
  fs := Byte(Font.Style);
  IniFile.WriteInteger('Font', 'Style', fs);
// lesen:
  fs := IniFile.ReadInteger('Font', 'Style', 0);
  Font.Style := TFontStyles(Byte(fs));

Helmi 23. Mai 2009 18:54

Re: Variable vom Typ "TFontStyles" in Ini speicher
 
Danke!

Ich hab zwar einen Versuch mit einem Cast auf Integer gemacht, aber nicht auf Byte.
Und mit Integer hats nicht funktioniert.

himitsu 23. Mai 2009 19:15

Re: Variable vom Typ "TFontStyles" in Ini speicher
 
Wenn durch {$MinEnumSize} TFontStyle auf Integergröße gebracht würde, dann ginge es auch mit Integer :nerd:

ansonsten muß einfach nur die Größe des IntegerTyps der Größe des anderen Typs entsprechen
Delphi-Quellcode:
SizeOf(Byte) = SizeOf(TFontStyle)
Delphi-Quellcode:
// schreiben:
IniFile.WriteInteger('Font', 'Style', Byte(Font.Style));
// lesen:
Font.Style := TFontStyles(Byte(IniFile.ReadInteger('Font', 'Style', 0));


// schreiben: man könnte hier auch notfalls Ord verwenden
IniFile.WriteInteger('Font', 'Style', Ord(Font.Style));

Helmi 23. Mai 2009 19:20

Re: Variable vom Typ "TFontStyles" in Ini speicher
 
Danke
ich habs jetzt mit nem Byte gemacht


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:32 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz