Autor Beitrag
Pr0g3r
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 44

Win XP
Turbo Pascal, Delphi 5&7, Ti-Basic
BeitragVerfasst: Mi 08.09.10 11:13 
Hallo,

ich habe ein OOP-Programm mit Delphi geschrieben, welches Shapes erzeugt.
Nun würde ich gerne bei mausklick eine showmessage loswerden. Kann mir irgendwer dabei helfen?


Moderiert von user profile iconNarses: Topic aus Algorithmen, Optimierung und Assembler verschoben am Mi 08.09.2010 um 17:09
platzwart
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1054
Erhaltene Danke: 78

Win 7, Ubuntu 9.10
Delphi 2007 Pro, C++, Qt
BeitragVerfasst: Mi 08.09.10 11:20 
Was genau dabei ist das Problem? Eigentlich musst du im OnClick-Ereignis sowas wie ShowMessage('Hello World'); schreiben...

_________________
Wissenschaft schafft Wissenschaft, denn Wissenschaft ist Wissenschaft, die mit Wissen und Schaffen Wissen schafft. (myself)
Pr0g3r Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 44

Win XP
Turbo Pascal, Delphi 5&7, Ti-Basic
BeitragVerfasst: Mi 08.09.10 11:28 
Das problem ist ein OneClick Ereignis auf das Objekt zu erstellen.
Mir wäre auch schon geholfen, wenn ich wüsste wie man Mausklicks(oder Tastendrücke) auf jedes beliebige Objekt registriert
platzwart
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1054
Erhaltene Danke: 78

Win 7, Ubuntu 9.10
Delphi 2007 Pro, C++, Qt
BeitragVerfasst: Mi 08.09.10 11:32 
Wie meinst du das? Das Shape hat doch ein OnClick-Ereignis? Was willst du da "registrieren"?!?

_________________
Wissenschaft schafft Wissenschaft, denn Wissenschaft ist Wissenschaft, die mit Wissen und Schaffen Wissen schafft. (myself)
Stundenplan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 128
Erhaltene Danke: 32

Win 7
Delphi 7 Pers., C# (VS 2010 Express)
BeitragVerfasst: Mi 08.09.10 11:53 
user profile iconplatzwart: Ich glaub, er will wissen, wie man Shapes ein OnClick-Ereignis zuweist. :wink:
Dafür musst du eine Prozedur deklarieren, die folgende Parameterliste hat:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.MeinOnClick(Sender: TObject);
begin
  //...
end;

Sie muss aber einer Klasse gehören! Schreib sie dafür am Besten in die Deklaration deines Forms.
Dann weist du, wenn die Shapes erzeugt werden, dem OnClick-Ereignis deine Prozedur zu:
ausblenden Delphi-Quelltext
1:
MeinShape.OnClick := MeinOnClick;					


Viele Grüße,
Stundenplan.
Pr0g3r Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 44

Win XP
Turbo Pascal, Delphi 5&7, Ti-Basic
BeitragVerfasst: Di 14.09.10 10:23 
Wo soll ich
ausblenden Delphi-Quelltext
1:
MeinShape.OnClick := MeinOnClick;					

genau hinschreiben?
rd3
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 14.09.10 14:29 
evtl durch alle components durch iterieren...
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure AssignShapeOnMousedown;
var i: integer;
begin
  for i := Componentcount-1 downto 0 do
  begin
    if (components[i] is TShape) then
      with (components[i] as TShape) do
        OnMouseDown := ShapeOnMouseDown;  // in dieser proc ist das showmessage oder das, was du willst...
  end;
end;


die procedure AssignShapeOnMousedown; kannst du z.b. bei OnCreate der Form oder so aufrufen...

gruß
rd3