Autor Beitrag
hansg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 168

Win XP Professional SP3, Vista Ultimate 32 SP1
Delphi 6 Professional
BeitragVerfasst: Do 17.05.07 10:35 
Hallo zusammen,

ich habe folgendes Problem:

Ich möchte aus einem ColorDialog die ausgewählte Farbe (color) in einen String abspeichern.
Wie mache ich so was:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.Button1Click(Sender: TObject);
begin
  if colordialog1.Execute then
  begin
    panel1.Color:=colordialog1.Color;
    mycolor:=colordialog1.Color; // das geht nicht !!
  end;
end;

_________________
Gruß Hans
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Do 17.05.07 11:03 
Auf Anhieb würde ich die Funktion ColorToString probieren. ;-)

_________________
We are, we were and will not be.
tolosonic
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 36



BeitragVerfasst: Fr 25.05.07 16:05 
und wenn ich eine mit colortostring erzeugten string dann später wieder der eigenschaft zuweisen will, quasi
xxx.color := colorstring; (was ja nicht funktionieren wird)? strtocolor gibts ja leider nicht.
Jann1k
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 866
Erhaltene Danke: 43

Win 7
TurboDelphi, Visual Studio 2010
BeitragVerfasst: Fr 25.05.07 16:13 
also, ich weiß nicht wie dein Programm aussieht, aber wäre es möglich, die Farben als Integer zu speichern? Dann könntest du der property einfach den Integerwert der Farbe zuweisen
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Fr 25.05.07 16:13 
Wenn die eine Richtung ColorToString heisst, wie könnte dann die andere Richtung sinnvoll heißen? :roll:

_________________
We are, we were and will not be.
Nilan
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 29

Win VistaSP1

BeitragVerfasst: Sa 26.05.07 11:29 
StringToColor? könnte sein :P
hansg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 168

Win XP Professional SP3, Vista Ultimate 32 SP1
Delphi 6 Professional
BeitragVerfasst: Di 29.05.07 17:33 
Hallo,
habe es so gelöst:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.Button1Click(Sender: TObject);  
begin  
  if colordialog1.Execute then  
  begin  
    mycolor:=ColorToString(colordialog1.color);  
  end;  
end; 

procedure TForm1.FormActivate(Sender: TObject);
begin
  panel1.Color:=StringToColor(mycolor);
end;

_________________
Gruß Hans