Autor Beitrag
Schnuppe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Mi 18.04.07 20:56 
Hallo!

Ich habe da mal eine (für Euch) sicher simple Frage. Habe kaum Erfahrung mit Delphi und nachdem ich mich stundenlang gequält habe versuche ich es auf diesem Wege.

Ich möchte auf einem Image mit der Maus punkte setzen (irgendwo). Durch klicken auf einen Button soll das Programm mir diese Punkte markieren.

Ich hoffe Ihr lacht Euch nicht krumm über meine ersten Versuche. Ich fürchte es klemmt an allen Ecken und Enden.

Aber vielleicht findet sich eine helfende Hand unter Euch die mir das mal "berichtigt"?:

Das wäre super!!!!

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
var
i,xi,yi,x,y:integer;

procedure TForm1.Button1Click(Sender: TObject);


begin
image1.Canvas.MoveTo(xi,yi);
image1.canvas.Pen.color:=clblack;
image1.Canvas.Rectangle(x-7,y-7,x+7,y+7);


end;
procedure TForm1.Image1Click(Sender: TObject);
begin

end;

end.


Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 18.04.07 21:05 
Moin und :welcome: im Forum!

Dein Problem lässt sich nur mit einem "Zwischenspeicher" für die angeklickten Punkte lösen. :? Habt ihr denn schon Felder (array) und Schleifen gehabt? Wenn nicht, dann kannst du immer nur den gerade angeklickten Punkt markieren. :|

PS: Du solltest deinen Code mit Delphi-Tags formatieren, einfach den Code markieren und auf das "+" neben "Delphi" im Editor klicken. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Dragonclaw
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 196

Windows Vista
Delphi 7 Prof.
BeitragVerfasst: Mi 18.04.07 21:08 
Wenn du direkt mit dem Mouseklick den Punkt makieren willst, kannst du das MouseDownEvent von dem Image benutzen.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Form1.Canvas.Rectangle(x-7,y-7,x+7,y+7);
end;
Schnuppe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Mi 18.04.07 21:18 
Titel: Mouse Down, wie
....danke für die fixen antworten.

wie komme ich denn auf dieses "maousedown" event? diese arraygeschichte haben wir auch mal kurz angerissen.

ich habe leider so gut wie keine ahnung.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 18.04.07 21:25 
Moin!

user profile iconSchnuppe hat folgendes geschrieben:
wie komme ich denn auf dieses "maousedown" event?

Markier das Image und schau mal im ObjectInspector auf der Seite "Ereignisse", dann bei OnMouseDown einen Doppelklicken machen. ;)

user profile iconSchnuppe hat folgendes geschrieben:
diese arraygeschichte haben wir auch mal kurz angerissen.

Die ist für das Markieren mehrerer Punkte allerdings unerlässlich... :? Was genau hast du denn davon noch in Erinnerung (auch auf die Schleifen bezogen)?

user profile iconSchnuppe hat folgendes geschrieben:
ich habe leider so gut wie keine ahnung.

In diesem Fall rate ich mal zum Standard-Tut: Crash-Kurs von user profile iconChristian S.

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Schnuppe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Mi 18.04.07 21:36 
...es GEHT (so einigermaßen)! ich kipp vom stuhl.

man ey.....

ich will doch nur bauingenieurin werden und kein programmierer....

habs jetzt so gelöst. wäre nett wenn ihr/du mal was dazu sagen würdet:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
var
n: integer;
xp, yp: array [1..30] of integer;



procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
if button=mbleft    then
begin
n:=n+1;
xp[n]:=x;
yp[n]:=y;
image1.Canvas.Rectangle(x-7,y-7,x+7,y+7);
end;

end;
end.


Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt
Schnuppe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Mi 18.04.07 21:37 
...hm, es sollen ja normalerweise erst über den button die punkte angezeigt werden....
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 18.04.07 21:38 
Moin!

user profile iconSchnuppe hat folgendes geschrieben:
...hm, es sollen ja normalerweise erst über den button die punkte angezeigt werden....

Hehe... ;) genau! :P

Du musst also das Zeichnen der Markierungen in den Button-Handler verlagern; aber sonst ist das schon OK. :zustimm:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Schnuppe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Mi 18.04.07 21:43 
...und wieso muß ich eigentlich dieses xp, yp array dingsbums da machen? warum ist das so wichtig und was sagt es aus??
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 18.04.07 21:45 
Moin!

user profile iconSchnuppe hat folgendes geschrieben:
und wieso muß ich eigentlich dieses xp, yp array dingsbums da machen? warum ist das so wichtig und was sagt es aus??

Aaalso, nochmal den Ansatz gaaanz von vorne... ;)

Aufgabe: Punkte merken und auf Klick markieren

Lösung:
- Speicher für die Punkte anlegen (-> das array :idea:)
- bei einem Klick im Image die Koordinaten in den Speicher packen
- dabei die Anzahl merken
- auf den Buttonklick hin den Speicher durchgehen und die Markierungen setzen

cu
Narses

PS: bitte setze deinen Delphi-Code in den Delphi-Tags hier rein, sonst ist das so schlecht zu lesen! :mahn: Danke. ;)

_________________
There are 10 types of people - those who understand binary and those who don´t.
Schnuppe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Mi 18.04.07 22:00 
Titel: das Zeichnen der Markierungen in den Button-Handler verlager
...hab ich gerade versucht...geht nicht *jammer*

du meinst doch sicher mit "zeichen der markierung" diese geschichte:

image1.Canvas.Rectangle(x-7,y-7,x+7,y+7)

dickes sorry, dass ich dich hier am abend so beschäftige
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 18.04.07 22:02 
Moin!

user profile iconSchnuppe hat folgendes geschrieben:
...hab ich gerade versucht...geht nicht *jammer*

[sing tune=schräg]Zeigt her, eure Versuche, zeigt her euren Code...[/sing] :P

user profile iconSchnuppe hat folgendes geschrieben:
du meinst doch sicher mit "zeichen der markierung" diese geschichte:
image1.Canvas.Rectangle(x-7,y-7,x+7,y+7)

Yip. ;)

user profile iconSchnuppe hat folgendes geschrieben:
dickes sorry, dass ich dich hier am abend so beschäftige

Ist schon OK, dazu ist das Forum ja da. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Schnuppe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Mi 18.04.07 22:08 
Titel: @narses
...hab das mal auf die "private" schiene verlagert. hast eine nachricht.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mi 18.04.07 22:11 
Titel: Re: @narses
user profile iconSchnuppe hat folgendes geschrieben:
...hab das mal auf die "private" schiene verlagert. hast eine nachricht.
Dieses Forum lebt davon, dass Probleme öffentlich besprochen werden! Ich möchte Dich bitten, Antworten immer im Forum zu posten und Probleme nur öffentlich zu besprechen. Wir sind keine Kontaktbörse, sondern ein Diskussionsforum.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Schnuppe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Mi 18.04.07 22:13 
GUT, dann wird das "ding" hier platzen. :o)
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 18.04.07 22:15 
Moin!

user profile iconSchnuppe hat folgendes geschrieben:
GUT, dann wird das "ding" hier platzen. :o)

Das ist aber schade... :(

user profile iconChristian S. hat schon recht, ich sehe das auch so; und du hast ebenfalls Post (mit genau diesem Inhalt)... ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Schnuppe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Mi 18.04.07 22:22 
...und wie bitte kann ich die ganze geschichte auf den button verlagern?
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 18.04.07 22:24 
Moin!

Du machst im Button-Handler eine Schleife, die alle bisher aufgezeichneten Koordinaten im array durchläuft und zeichnest die Markierungen. :idea:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
Schnuppe Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Mi 18.04.07 22:26 
hm, ich weiß im moment nicht wie genau diese schleife aussehen soll.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mi 18.04.07 22:27 
Moin!

Welche Schleifen kennst du denn? ;) Zähl mal auf.

cu
Narses

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