![]() |
SynEdit TFontStyles aus INI lesen?
Hallo,
kann mir jemand sagen, wie ich die TFontStyles die von den SynEdit-Highlightern in eine INI geschrieben werden parsen kann? Für die verschiedenen Stile nehme ich Checkboxen. Allerdings stehe ich beim auslesen auf'm Schlauch. Die Werte werden als Integer in die INI geschrieben. Viele Grüße... |
Re: SynEdit TFontStyles aus INI lesen?
Hast du schon versucht den Integer einfach auf TFontStyles zu casten?
|
Re: SynEdit TFontStyles aus INI lesen?
Hi,
ich habs so probiert, was aber nicht hingehauen hat:
Delphi-Quellcode:
procedure TForm3.readstyles(y : TFontStyles);
begin if fsBold in y then Checkbox1.Checked; if fsItalic in y then Checkbox2.Checked; if fsUnderline in y then Checkbox3.Checked; if fsStrikeout in y then Checkbox4.Checked; end; und: style := TFontStyles(TFontStyle(ti.ReadInteger(f, 'Style', 0))); readstyles(style); |
Re: SynEdit TFontStyles aus INI lesen?
Wie SirThornberry sagte Das kannst Du doch mit dem Integerwert lösen, Ich hab das mal so gelöst noch mit extra Anzeige.
Delphi-Quellcode:
WriteInteger('Textdatei', 'Style', Integer(TFontStyle(Form1.SynEdit1.Font.Style)));
.... dummy:= (ReadInteger('Textdatei', 'Style', 0)); if dummy=0 then Label7.Caption:='[Standard]'; if dummy=1 then Label7.Caption:='[Fett]'; if dummy=2 then Label7.Caption:='[Kursiv]'; if dummy=3 then Label7.Caption:='[Fett, Kursiv]'; if dummy=4 then Label7.Caption:='[Standard, Unterstrichen]'; if dummy=5 then Label7.Caption:='[Fett, Unterstrichen]'; if dummy=6 then Label7.Caption:='[Kursiv, Unterstrichen]'; if dummy=7 then Label7.Caption:='[Fett, Kursiv, Unterstrichen]'; if dummy=8 then Label7.Caption:='[Standard, Durchgestrichen]'; if dummy=9 then Label7.Caption:='[Fett, Durchgestrichen]'; if dummy=10 then Label7.Caption:='[Kursiv, Durchgestrichen]'; if dummy=11 then Label7.Caption:='[Fett, Kursiv, Durchgestrichen]'; if dummy=12 then Label7.Caption:='[Standard, Durch und Unterstrichen]'; if dummy=13 then Label7.Caption:='[Fett, Durch und Unterstrichen]'; if dummy=14 then Label7.Caption:='[Kursiv, Durch und Unterstrichen]'; if dummy=15 then Label7.Caption:='[Fett, Kursiv, Durch und Unterstrichen]'; |
Re: SynEdit TFontStyles aus INI lesen?
Ok, so geht's natürlich auch. Sind die Int-Werte Standard für TFontStyles?
Viele Grüße... |
Re: SynEdit TFontStyles aus INI lesen?
Omg, da wird man doch blöde bei dem Code. Set Of stellt eine Bitmaske dar und von daher lässt es sich genauso einfach in eine solche ablegen.
Delphi-Quellcode:
Function FontStyleToInt(Const AFontStyles: TFontStyle): Integer;
Begin Result := 0; if fsBold in y then Result := Result Or $01; if fsItalic in y then Result := Result Or $02; if fsUnderline in y then Result := Result Or $04; if fsStrikeout in y then Result := Result Or $08; End; Function IntToFontStyle(Const AInt: Integer): TFontStyle; Begin Result := []; If ( AInt And $01 ) <> 0 Then Include(Result, fsBold); If ( AInt And $02 ) <> 0 Then Include(Result, fsItalic); If ( AInt And $04 ) <> 0 Then Include(Result, fsUnderline); If ( AInt And $08 ) <> 0 Then Include(Result, fsStrikeOut); End; |
Re: SynEdit TFontStyles aus INI lesen?
Ich habe jetzt versucht Motzis Lösung zu nehmen. Allerdings wo kommt bei FontStyleToInt das y her? Ersetze ich es durch AFontStyles, bekomme ich den Fehler:
Zitat:
|
Re: SynEdit TFontStyles aus INI lesen?
moin,
einfach über Synedit.Highlighter.LoadFromFile() einlesen. |
Re: SynEdit TFontStyles aus INI lesen?
Ich habe keine SynEdit-Komponente. ;) Aber ich denke, es muss so aussehen:
Delphi-Quellcode:
Und so:
function FontStyleToInt(const AFontStyles: TFontStyles): Integer;
begin Result := 0; if fsBold in AFontStyles then Result := Result or $01; if fsItalic in AFontStyles then Result := Result or $02; if fsUnderline in AFontStyles then Result := Result or $04; if fsStrikeout in AFontStyles then Result := Result or $08; end;
Delphi-Quellcode:
function IntToFontStyle(const AInt: Integer): TFontStyles;
begin Result := []; if (AInt and $01) <> 0 then Include(Result, fsBold); if (AInt and $02) <> 0 then Include(Result, fsItalic); if (AInt and $04) <> 0 then Include(Result, fsUnderline); if (AInt and $08) <> 0 then Include(Result, fsStrikeOut); end; |
Re: SynEdit TFontStyles aus INI lesen?
oh, Luckie hab deinen Post gar nicht gelesen. Bin vom Thread-Ersteller ausgegangen. :mrgreen:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:28 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz