Autor Beitrag
Calyptus
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 386

Win Xp Prof
D3, D6 Pers, D7 Ent
BeitragVerfasst: Fr 29.10.04 16:07 
Ich habe in meinen Programm 50 Panels. Beim Klick auf ein Panel soll diesem eine Farbe zugewiesen werden, die in einer Var ist. Meine Frage: Geht das irgendwie einfacher/schneller als das hier:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TForm1.Panel1Click(Sender: TObject);
begin
Panel1.Color := Col;
end;

procedure TForm1.Panel2Click(Sender: TObject);
begin
Panel2.Color := Col;
end;

usw...


ps: Hab echt keinen besseren titel gefunden!

_________________
Luft- und Raumfahrtechnik an der Uni Stuttgart
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Fr 29.10.04 16:15 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
    procedure FormCreate(Sender: TObject);
    procedure myClick(Sender: TObject);
//....


procedure TForm1.myClick(Sender: TObject);
begin
  TPanel(Sender).Color := clred;
end;

procedure TForm1.FormCreate(Sender: TObject);
var i: integer;
begin
  for i := 1 to 4 do
    TPanel(FindComponent('Panel'+inttostr(i))).OnClick := myClick;
end;
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6393
Erhaltene Danke: 147

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Fr 29.10.04 16:15 
Du kannst im OI auch aussuchen, welche Ereignis-Routine genommen werden soll.
Du brauchst das also nur für ein Panel machen und bei den anderen im OI darauf verweisen. Dafür ist im OI beim Ereignis (OnClick) rechts so ein kleines Symbol.