Einzelnen Beitrag anzeigen

Sidewinder
(Gast)

n/a Beiträge
 
#11

Re: Objekt an Mausposition binden

  Alt 26. Aug 2008, 03:18
wie ist es damit.....
Delphi-Quellcode:
var
dragged : boolean;

procedure TForm1.FormCreate(Sender: TObject);
begin
  application.OnMessage := MSGevent;
end;

Procedure Tform1.MSGevent(var Msg: tagMSG; var Handled: Boolean);
var mousepos : Tpoint;
begin
  if (Msg.message = WM_LBUTTONDOWN) then
  begin
    dragged := true;
  end;
  if (Msg.message = WM_LBUTTONUP) then
  begin
    dragged := false;
  end;
  if dragged then
  begin
    mousepos := form1.ScreenToClient(mouse.CursorPos);
    Shape1.Left := mousepos.X - (Shape1.Width div 2);
    Shape1.Top := mousepos.Y - (Shape1.Height div 2);
  end;
end;
  Mit Zitat antworten Zitat