Autor Beitrag
Bodhi
Hält's aus hier
Beiträge: 3

Win XP, GNU/Debian Linux
Delphi 7, VS 6
BeitragVerfasst: Do 29.12.05 17:23 
Hi,
hoffe ihr könnt mir helfen.

Mein Problem ist folgendes:
Habe folgendes Array erstellt: newshp:array[1..10,1..10] of TShape;
und in Schleife initialisiert. Hat auch alles geklappt.
Doch nun möchte ich dem Array ein onMouseDown Ereignis zuordnen und
habe keine Ahnung wie ich das tun soll. (Alle 100 Elemente hätten den
selben code.)
Danke im Voraus.

MFG
Bodhi
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Do 29.12.05 17:43 
Du musst jedem einzelnen Shape das Ereignis zuweisen, am besten mit 2 geschchtelten for-schleifen.

_________________
Bravery calls my name in the sound of the wind in the night...
Bodhi Threadstarter
Hält's aus hier
Beiträge: 3

Win XP, GNU/Debian Linux
Delphi 7, VS 6
BeitragVerfasst: Do 29.12.05 18:13 
Und wie soll ich das Anstellen?
Folgende Schleife existiert bereits:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
/////////////////////////////////////////////
//Erzeugung der 10*10 TShapes //       
///////////////////////////////////////////       
FOR x:=1 TO 10 DO                      
BEGIN                                  
Top:=Top+31;                           
     Left:=50;                         
for y:=1 to 10 do                      
begin                                  
newshp[x][y]:=tshape.Create(form1);    
newshp[x][y].Parent:=form1;            
newshp[x][y].Height:=height;           
newshp[x][y].Width:=width;             
newshp[x][y].Left:=left;               
left:=left+31;                         
newshp[x][y].Top:=Top{*y};             
                                       
end;                                   
END;
/////////////////////////////////////////////


Doch wenn ich newshp[x][y].onmousedown(...)
benutze habe ich keine Ahnung, welche Parameter ich
übergeben soll und wo ich die Behandlungsrotine einzufügen
habe.
Bitte schreibt mir Codebeispiele.

Danke im Voraus.

Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt
Opa
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 22



BeitragVerfasst: Do 29.12.05 22:04 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
procedure TForm1.ShapeMouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);
begin
  with TShape(Sender) do
    case Tag of
      000:; // Ereignis  von Shape   1
      001:; // Ereignis  von Shape   2
      100:; // Ereignis  von Shape 100
    end;
end;
//-----------------------------------------
FOR x:=1 TO 10 DO                        
BEGIN                                    
Top:=Top+31;                             
     Left:=50;                           
for y:=1 to 10 do                        
begin                                    
  //...
  newshp[x][y].Tag:= Y-1+10*(X-1);
  newshp[x][y].OnMouseDown := ShapeMouseDown;                                         
end;                                     
END;

MFG

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt
Bodhi Threadstarter
Hält's aus hier
Beiträge: 3

Win XP, GNU/Debian Linux
Delphi 7, VS 6
BeitragVerfasst: Do 29.12.05 22:57 
Danke, funktioniert prima!

MFG
Bodhi