Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi SynEdit TFontStyles aus INI lesen? (https://www.delphipraxis.net/85207-synedit-tfontstyles-aus-ini-lesen.html)

Grolle 27. Jan 2007 12:19


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...

SirThornberry 27. Jan 2007 12:21

Re: SynEdit TFontStyles aus INI lesen?
 
Hast du schon versucht den Integer einfach auf TFontStyles zu casten?

Grolle 27. Jan 2007 12:25

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

Blackheart 27. Jan 2007 12:40

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]';

Grolle 27. Jan 2007 12:47

Re: SynEdit TFontStyles aus INI lesen?
 
Ok, so geht's natürlich auch. Sind die Int-Werte Standard für TFontStyles?
Viele Grüße...

Muetze1 28. Jan 2007 03:45

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;

Luckie 14. Feb 2007 10:52

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:

[Pascal Error] SaveLoadCls.pas(239): E2015 Operator not applicable to this operand type
:gruebel:

bigg 14. Feb 2007 11:01

Re: SynEdit TFontStyles aus INI lesen?
 
moin,

einfach über Synedit.Highlighter.LoadFromFile() einlesen.

Luckie 14. Feb 2007 11:05

Re: SynEdit TFontStyles aus INI lesen?
 
Ich habe keine SynEdit-Komponente. ;) Aber ich denke, es muss so aussehen:
Delphi-Quellcode:
  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;
Und so:
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;

bigg 14. Feb 2007 11:12

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 00:42 Uhr.
Seite 1 von 2  1 2      

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