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
  #3  
Antiguo 17-06-2008
[coso] coso is offline
Miembro Premium
 
Registrado: may 2008
Ubicación: Girona
Posts: 1.678
Poder: 0
coso Va por buen camino
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
        if Carried = nil then exit;

        m := (Width - ClientWidth ) div 2;
        dh := Height - ClientHeight - m;

        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.

Última edición por coso fecha: 18-06-2008 a las 11:16:12.
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 08:54:24.


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