Autor Beitrag
StefanH
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: Mi 28.05.03 15:15 
Hallo zusammen!
Ich möchte einen schwarzen Strich (Shape oder so) auf einer Fläche verschieben. Ich habs mit MouseMove versucht:
ausblenden Delphi-Quelltext
1:
2:
3:
...
if ssLeft in shift then Shape1.Left:= x
...


Geht aber nur einmal :(

Stefan

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)
Pascal
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 155

Win 98, Win XP
Delphi 2005, Delphi 5
BeitragVerfasst: Mi 28.05.03 17:19 
Was meinst du mit das geht nur einmal? wenn man onMousemoufe dem shape.left x zweist sollte sich das shape immer wenn man die Maus über das Formular(nicht Shape) bewegt verschieben. Bei mir tut es das auch.
Dein Code verschiebt es eben nur bei gedrückter Maustaste.
ErnestoChe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 528

Win 2000 pro, CRUX 2.0
Delphi 6 Pers, Open K3
BeitragVerfasst: Mi 28.05.03 17:23 
Hallo,

erstmal im Objektinspektor die Eigenschaft DragMode deines Shapes auf dmAutomatic stellen.
Wenn Du den shape auf der Form bewegen willst, dann schreibe in das OnDragOver-Ereignis der Form folgenden Code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.FormDragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
  accept := Source is TShape;
end;


Damit darfst du auf der Form verschieben. Dass beim loslassen an der entsprechenden Stelle bleiben soll, schreibst du folgenden code in das OnDragDrop-Ereignis deiner Form:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TForm1.FormDragDrop(Sender, Source: TObject; X, Y: Integer);
begin
  if (Sender is TForm) and (Source is TShape) then
  begin
    with Sender as TForm do
    begin
      shape1.Left := X;
      shape1.Top := Y;
    end;
  end;
end;


MFG

- Ernesto -