Ver Mensaje Individual
  #4  
Antiguo 17-06-2008
Avatar de Nomad
Nomad Nomad is offline
Miembro
 
Registrado: abr 2007
Ubicación: Sarchi,Costa Rica
Posts: 107
Reputación: 18
Nomad Va por buen camino
Cita:
Empezado por coso Ver Mensaje
Te pongo aqui codigo de ejemplo para hacer un drag&drop

Código Delphi [-]unit carried; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls; type TForm1 = class(TForm) Shape1: TShape; Shape2: TShape; Shape3: TShape; Label1: TLabel; procedure Shape1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure Shape1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); procedure Shape1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); private { Private declarations } public { Public declarations } Carried : TControl; X_c : integer; Y_c : integer; end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.Shape1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if carried <> nil then exit; Label1.Caption := inttostr(X_c) + ' ' + inttostr(Y_c); Carried := (sender as TControl); Carried.BringToFront; X_c := X; Y_c := Y; end; procedure TForm1.Shape1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); var m, dh : integer; begin m := ( Width - ClientWidth ) div 2; dh := ( Height - ClientHeight) - m; if Carried = nil then exit; Carried.Left := Mouse.CursorPos.x - Left - m - X_c; Carried.Top := Mouse.CursorPos.y - Top - dh - Y_c; end; procedure TForm1.Shape1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin Carried := nil; end; end.


Los eventos tienen q estar ligados a todos los shapes.

saludos.

Este truco esta excelente! gracias! pero aun me faltan varias cosas.... por "pensar"
__________________
Quisiera cambiar el mundo, pero no me dan el código fuente.
Responder Con Cita