Autor Beitrag
Takeshi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64



BeitragVerfasst: Mi 02.04.03 13:33 
Hallo!

Ich habe eine Karte gemacht, einfach nur ein Raster und möchte nun bei Klick an den Koordinaten des Mauszeigers einen Punkt erstellen. Dieser soll später beim drüberfahren als 'Link' funktionieren.

Also etwas ähnliches wie <area shape=" in einer HTML, nur dass der Radius ruhig immer der selbe sein kann.

Leider habe ich keine Ahnung, wie ich so ein Shape dahinzauber, und diesem dann auch noch Ereignisse zuordne. Habe bisher nur Komponenten aus der Liste eingefügt.

Vielen Dank schonmal! greez, Takeshi
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Mi 02.04.03 14:26 
Hi,

wär ganz hilfreich zu wissen auf was für eine Komponente du da klickst.. also auf was du deine Karte zeichnest. ;)

Au'revoir,
Aya~

_________________
Aya
I aim for my endless dreams and I know they will come true!
Takeshi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64



BeitragVerfasst: Mi 02.04.03 14:43 
ich klicke auf ein Image (Bitmap), da ja hier eine Karte eingefügt werden soll.
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Mi 02.04.03 14:48 
huhu,

also versteh ich das jetzt richtig das die Karte ein einziges großes TImage ist, oder sind es mehrere kleine??

Au'revoir,
Aya

_________________
Aya
I aim for my endless dreams and I know they will come true!
Takeshi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64



BeitragVerfasst: Mi 02.04.03 15:10 
jaja, ist ein ganzes. ist soll auch keine besonders große karte sein.
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Mi 02.04.03 15:36 
Hi,

dann nimm einfach das OnMouseDown-Event vom TImage.. da hast du dann die X und Y Koordinate wo auf das Bild geklickt wurde :)

Au'revoir,
Aya

_________________
Aya
I aim for my endless dreams and I know they will come true!
Takeshi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64



BeitragVerfasst: Mi 02.04.03 17:33 
Das weiß ich auch.

wenn du aber meinen ersten post nochmal durchliest - ich möchte dann an dieser stelle eine Markierung einfügen, wo geklickt wurde. Und wie DAS geht möchte ich gern wissen.

Ich habe nun ein Fake-Programm geschrieben, das die Funktionen simuliert. Nur wird dabei ein Punkt verschoben und nicht wie gewünscht neue Punkte erstellt. Vielleicht wird damit deutlicher, was ich vorhabe.

rudel-clanpage.de.vu/map.zip

gruß, takeshi
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Mi 02.04.03 18:04 
Hi,

achsoooo.... nu hab ich's kapiert *gg*

Na ja, du speicherst ja die Koordinaten der Punkte immer in der ListBox da am rand..

Speicher sie einfach zusätzlich noch in nen Array:

ausblenden Quelltext
1:
FeldArray: Array of Array[1..2] of Integer;					


und ne neue Koordinate hinzufügen:

ausblenden Quelltext
1:
2:
3:
SetLength(FeldArray,Length(FeldArray)+1);
FeldArray[High(FeldArray),1]:=X;
FeldArray[High(FeldArray),2]:=Y;


Soo... und dann halt jedesmal wenn du die punkte zeichnest mit ner For-Schleife durch den Array gehen:

ausblenden Quelltext
1:
2:
for i:=Low(FeldArray) to High(FeldArray) do
  ZeichnePunkt(FeldArray[i,1],FeldArray[i,2]);


so in der Art halt.. ;)

War's das was du meintest?? :roll:

Au'revoir,
Aya~

_________________
Aya
I aim for my endless dreams and I know they will come true!
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Mi 02.04.03 18:06 
ach halt...

ich seh grad dein Punkt is ja nen Shape.. nich per Canvas draufgezeichnet... :oops:

mach halt nen Array of TShape ;)

und beim neuen hinzufügen:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
var
  Shapes: Array of TShape;

procedure OnMouseDown(...);
begin
  SetLength(Shapes,Length(Shapes)+1);
  Shapes[High(Shapes)]:=TShape.Create(self);
  Shapes[High(Shapes)].Parent:=self;
  Shapes[High(Shapes)].Left:=X;
  Shapes[High(Shapes)].Top:=Y;
end;


Au'revoir,
Aya~

_________________
Aya
I aim for my endless dreams and I know they will come true!
Takeshi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64



BeitragVerfasst: Mi 02.04.03 20:41 
danke!!!
das zieh ich mir erstmal morgen nach meiner physik klausur rein :D
dann habe ich bestimmt wieder ne frage ;)
greez, Take
Takeshi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64



BeitragVerfasst: Do 03.04.03 16:19 
OK, das mit dem Array hab ich jetzt alles verstanden *freu*
sowas in der art hab ich mich schon öfters gefragt. Jedenfalls kann ich jetzt prima überall Punkte hinpflanzen.

wie kann ich denn dem Objekt 'Shapes' jetzt ein Ereignis (MouseDown) zuweisen, bzw wie komme ich an den Index des beklickten Shapes ?
[witzige Formulierung...] egal ich bin sicher, du weißt, was ich meine

vielen thx + greez Takeshi
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Do 03.04.03 16:28 
huhu,

einfach so:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
var 
  Shapes: Array of TShape; 

procedure OnMouseDown(...); 
begin 
  SetLength(Shapes,Length(Shapes)+1); 
  Shapes[High(Shapes)]:=TShape.Create(self); 
  Shapes[High(Shapes)].Parent:=self; 
  Shapes[High(Shapes)].Left:=X; 
  Shapes[High(Shapes)].Top:=Y; 

  Shapes[High(Shapes)].Tag:=High(Shapes); 
  Shapes[High(Shapes)].OnMouseDown:=MyMouseDown; 
end;


und in der Procedur MyMouseDown dann:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.MyMouseDown(...);
var
  ShapeID: Integer;
begin
  ShapeID:=TShape(Sender).Tag;
  Shapes[ShapeID]....
end;


Au'revoir,
Aya~

_________________
Aya
I aim for my endless dreams and I know they will come true!
Takeshi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64



BeitragVerfasst: Do 03.04.03 18:14 
mhh.
ich habe nun
ausblenden Quelltext
1:
Shapes[High(Shapes)].OnMouseDown:=MyMouseDown;					

eingefügt und per Hand die procedure
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TfrmMap.MyMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
  ShapeID: Integer;
begin
  ShapeID:=TShape(Sender).Tag;
  edtShapeID.Text:=FloatToStr(ShapeID);
end;

eingefügt.
Das ist wohl falsch, denn der Index ist immer 0. Leider blicke ich auch noch nicht ganz durch, wo 'Sender' herkommen soll..
gruß, Takeshi
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Do 03.04.03 18:26 
Hi,

hast du daran gedacht den "Tag" der Shape festzulegen???
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
var 
  Shapes: Array of TShape; 

procedure OnMouseDown(...); 
begin 
  SetLength(Shapes,Length(Shapes)+1); 
  Shapes[High(Shapes)]:=TShape.Create(self); 
  Shapes[High(Shapes)].Parent:=self; 
  Shapes[High(Shapes)].Left:=X; 
  Shapes[High(Shapes)].Top:=Y; 

  Shapes[High(Shapes)].Tag:=High(Shapes);  // <-- DAAA :)
  Shapes[High(Shapes)].OnMouseDown:=MyMouseDown; 
end;


Sender ist einfach das Objekt welches den Event (in dem fall also den OnMouseDown Event) ausgelöst hat.

Au'revoir,
Aya~

_________________
Aya
I aim for my endless dreams and I know they will come true!
Takeshi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 64



BeitragVerfasst: Do 03.04.03 18:54 
ok es klappt :)
ausblenden Quelltext
1:
(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer)					

das muss alles der procedure MyMouseDown übergeben werden oder ?
Aya
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1964
Erhaltene Danke: 15

MacOSX 10.6.7
Xcode / C++
BeitragVerfasst: Do 03.04.03 19:26 
Jep :)

_________________
Aya
I aim for my endless dreams and I know they will come true!