Autor Beitrag
Mr. Hunt
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25



BeitragVerfasst: So 21.09.08 11:30 
Halli Hallo

Wenn man auf Panel1 klickt, soll an der Stelle ein shape erscheinen, davon soll es unendlich viele geben, ich hab erst so angefangen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
Shape3.Left:=X-Round(Shape3.Width/2);
Shape3.Top:=Y-Round(Shape3.Height/2);
end;


aber hier wird natürlich nur shape 3 bewegt, ich möchte aber das jedesmal ein neues shape entsteht!

Wie könnte ich das machen??

MfG


Moderiert von user profile iconNarses: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am So 21.09.2008 um 13:43
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: Mo 22.09.08 00:03 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
 myShape: TShape;
begin
 myShape:= TShape.Create(Self);
 myShape.Left:= X-Round(myShape.Width/2);
 myShape.Top:= Y-Round(myShape.Height/2);
end;
Mr. Hunt Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25



BeitragVerfasst: Mo 22.09.08 15:04 
Bei mir erscheint kein Shape!!!
aber delphi sagt, er würde es 100% ausführen.
Kann es damit zu tun haben, das das ganze auf einem panel stattfindet?

Vielen Dank für weitere Antworten!

MfG
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: Mo 22.09.08 15:07 
Da fehlt noch ein MyShape.Parent := Panel1; nach dem Create. ;-)

_________________
We are, we were and will not be.
Mr. Hunt Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25



BeitragVerfasst: Di 23.09.08 14:23 
Vielen Dank estmal
Aber ich hab nochmal dazu ne Frage:

Das hat jez soweit geklappt, jez möchte ich aber eine MouseDOwn funktion für myShape erstellen, hab folgendes gemacht:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.MyShapeMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
Label8.Caption:=IntToStr(StrToInt(Label8.Caption) + 1);
Label10.Caption:=IntToStr(StrToInt(Label10.Caption) - 1);
end;
//Das steht ganz am Ende;


und oben:
ausblenden Delphi-Quelltext
1:
2:
3:
 private
      procedure MyShapeMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);

Aber es passiert nicht das was passieren soll, warum nicht??

MfG

PS: Es kommt ne Meldung:
ausblenden Delphi-Quelltext
1:
[Hinweis] Unit1.pas(50): Das private-Symbol 'MyShapeMouseDown' wurde deklariert, aber nie verwendet					


MfG
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: Di 23.09.08 14:48 
Da fehlt dann ein MyShape.OnMouseDown := MyShapeMouseDown; ;-)

_________________
We are, we were and will not be.
Mr. Hunt Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25



BeitragVerfasst: Di 23.09.08 15:37 
vielen dank

MfG
Mr. Hunt Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25



BeitragVerfasst: Di 23.09.08 16:35 
Tut mir Leid noch ne Frage zu stellen, aber wie Lösche oder Visible = False ich ALLE MyShapes mit einem ButtonCLick?

BzW wie spreche ich alle myShapes auf einmal an?

MfG
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: Di 23.09.08 17:17 
Hallo,

kurz gesagt: garnicht.

Dazu musst du dir eine eigene Lösung basteln. Z.b. könntest du dir eine Liste erstellen, in der du dir alle erstellten Shapes merkst. Diese Liste kannst du dann abarbeiten.

Oder aber du gehst alle Komponenten deiner Form durch und überprüfst, ob es ein Objekt vom Typ TShape ist. Falls ja, dann entsprechend behandeln...
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 23.09.08 17:23 
Moin!

user profile iconMr. Hunt hat folgendes geschrieben:
Tut mir Leid noch ne Frage zu stellen,
Bitte stelle nur eine Frage pro Thread; es hat sich herausgestellt, das mehrere (thematisch nicht zusammengehörige) Fragen in einem Thread zu Chaos führen. :? Deshalb schließen wir solche Topics in der Regel. ;)

Wenn du noch ein Problem mit dem Zugriff auf mehrere Komponenten hast, erstelle bitte ein neues Topic. :idea:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.