Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Gráficos
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

 
 
Herramientas Buscar en Tema Desplegado
  #4  
Antiguo 17-06-2008
Avatar de Nomad
Nomad Nomad is offline
Miembro
 
Registrado: abr 2007
Ubicación: Sarchi,Costa Rica
Posts: 107
Poder: 20
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
 


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Drag and Drop... dvlt .NET 0 07-02-2008 09:42:59
Drag & Drop DanForever Varios 2 01-06-2006 14:24:25
Drag&Drop !!! rafstyle OOP 6 27-07-2004 04:39:41
Drag&Drop xflo Lazarus, FreePascal, Kylix, etc. 0 13-10-2003 19:31:22
Drag & Drop cone220 Varios 1 26-05-2003 19:06:34


La franja horaria es GMT +2. Ahora son las 04:13:29.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi