Autor Beitrag
Harry M.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: Di 08.02.05 22:41 
also ich schraube grad an nen prog, was die einstellungen von delphi aus der registry ließt (was die farben des editors angeht), soweit so gut, jetzt lese ich den string aus der registry und diesen will ich als eigenschaft in meinem programm verwenden.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
//...  
REGISTRY.OpenKey('Software\Borland\Delphi\7.0\Editor\Highlight\Assembler',FALSE);
SynPasSyn1.AsmAttri.Foreground := REGISTRY.ReadString('Foreground Color New');
//..

jetzt meckert aber mein compiler aber

ausblenden Quelltext
1:
  [Fehler] frmMain.pas(282): Inkompatible Typen: 'TColor' und 'String'					


hat jemand ne ahnung wie trotzdem geht ohne jetzt eine ewig lange vergleichstour zu beginnen so in etwa:
ausblenden Delphi-Quelltext
1:
if REGISTRY.ReadString('Foreground Color New') = 'clBlack' then SynPasSyn1.AsmAttri.Foreground := clBalck;					

:?

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Di 08.02.05 23:08 
TColor ist ein Zahlenwert. Dann benutze zum Speichern WriteInteger und zum Lesen ReadInteger.

_________________
Ciao, Sprint.
Harry M. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: So 13.02.05 04:56 
geht leider nicht. delphi speichert die werte in string. deshalb hat auch der debugger gesgagt:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
---------------------------
Benachrichtigung über Debugger-Exception
---------------------------
Im Projekt Codeview.exe ist eine Exception der Klasse ERegistryException aufgetreten. Meldung: 'Fehler beim Holen der Daten für 'Foreground Color New''. Prozess wurde angehalten. Mit Einzelne Anweisung oder Start fortsetzen.
---------------------------
OK   Hilfe   
---------------------------
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: So 13.02.05 05:26 
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:
procedure TForm1.FormCreate(Sender: TObject);

  function _StringToColor(const S: string): TColor;
  begin
    try
      Result := StringToColor(S);
    except
      Result := clNone;
    end;
  end;

begin

  with TRegistry.Create do
  begin
    try
      RootKey := HKEY_CURRENT_USER;
      if OpenKey('Software\Borland\Delphi\7.0\Editor\Highlight\Assembler', False) then
      begin
        SynPasSyn1.AsmAttri.Foreground := _StringToColor(ReadString('Foreground Color New'));
        // usw.
      end;
    finally
      Free;
    end;
  end;

end;


Die _StringToColor Funktion ist dafür da, wenn du mehrere Werte auslesen willst und ein Fehler auftritt.

_________________
Ciao, Sprint.
Harry M. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: So 13.02.05 05:41 
wenn man folgendes berichtig:
ausblenden Quelltext
1:
_StringToColor(Registry.ReadString('Foreground Color New'))					


kann man es comilieren. aber es funzt trotzdem nicht. die werte werden nicht übernommen durch SynEdit
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: So 13.02.05 05:50 
User-Xy2004 hat folgendes geschrieben:
wenn man folgendes berichtig

In meinem Beispiel brauchst du nichts berichtigen! Jetzt poste mal deine komplette Funktion.

_________________
Ciao, Sprint.
Harry M. Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: So 13.02.05 07:16 
probelem erkannt und gebannt...
ich habe meinen code nach deinem muster umgebaut und was soll ich sagen... thx

gruß