Autor Beitrag
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: Di 04.09.07 20:30 
Hallo,

ich hab folgendes Problem:

Ich hab mir zum speichern von Fonts zwei Objekte vom Typ TFont gemacht
ausblenden Delphi-Quelltext
1:
2:
Font1 := TFont.Create;
Font2 := TFont.Create;


Und zwei Funktion zum speichern von Fontstyles:
ausblenden Delphi-Quelltext
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:
function LoadFontStyle(AString: String):TFontStyles;
begin
  if AString[1] = '1' then
    result := result + [fsStrikeout];
  if AString[2] = '1' then
    result := result + [fsUnderline];
  if AString[3] = '1' then
    result := result + [fsItalic];
  if AString[4] = '1' then
    result := result + [fsBold];
end;


function SaveFontStyle(AStyle: TFontStyle): String;
begin
  if AStyle = AStyle + [fsStrikeOut] then
    result := '1'
  else result := '0';
  if AStyle = AStyle + [fsUnderline] then
    result := result + '1'
  else result := result + '0';
  if AStyle = AStyle + [fsItalic] then
    result := result + '1'
  else result := result + '0';
  if AStyle = AStyle + [fsBold] then
    result := result + '1'
  else result := result + '0';
end;


nun lad ich in Font1 einen String mit 0000 und in Font2 einen mit 0010.

Wenn ich nun diesen Code ausführe:
ausblenden Delphi-Quelltext
1:
2:
3:
Fontdialog1.Font.Assign(Font1);
if FontDialog1.Execute then
  Font1.Assign(Fontdialog1.Font);


dann zeigt er mir immer das Underline gesetzt ist obwohl ichs im String ja nicht gesetzt hab.

das gleiche passiert mit Fontdialog2 und Font2.

warum funktioniert der Code nicht???

lg elundril
Logikmensch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 390

Win XP
Delphi 2007 Prof., XE2, XE5
BeitragVerfasst: Mi 05.09.07 12:13 
Hallo!

Du schreibst:
Zitat:
...dann zeigt er mir immer das Underline gesetzt ist obwohl ichs im String ja nicht gesetzt hab.


Naja, das ist jetzt schwer zu beantworten. Vielleicht funktioniert ja Dein Code, aber die nachgeschaltete Überprüfung (Anzeige von Text etc.) ist irgendwo fehlerhaft. Dass Dein Assign gearbeitet hat, lässt sich doch leicht prüfen mit

if fsUnderline in Font1.Style then...

Prüf's halt schrittweise ab. Wenn die Flags nach dem Dialog-Execute doch richtig gesetzt sind (davon gehe ich jetzt mal aus), dann liegt der Fehler bestimmt in dem weiteren Verlauf Deines Codes. Wie arbeitest Du mit dem Assign'ten Font denn weiter?

_________________
Es gibt keine Probleme - nur Lösungen!