Ver Mensaje Individual
  #5  
Antiguo 15-04-2013
Avatar de escafandra
[escafandra] escafandra is offline
Miembro Premium
 
Registrado: nov 2007
Posts: 2.195
Reputación: 20
escafandra Tiene un aura espectacularescafandra Tiene un aura espectacular
Como apunta ecfisa un TSpeedButton no es una ventana por lo que no tiene Handle. No se le pueden enviar mensajes de Windows (WM_XXX)

El movimiento lo debes hacer manual, como te indica ecfisa. Yo propongo el siguiente código simple:

Código Delphi [-]
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Buttons;

type
  TForm1 = class(TForm)
    SpeedButton1: TSpeedButton;
    procedure SpeedButton1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure SpeedButton1MouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
  private
    OldPoint: TPoint;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.SpeedButton1MouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  OldPoint.X:= X;
  OldPoint.Y:= Y;
end;

procedure TForm1.SpeedButton1MouseMove(Sender: TObject; Shift: TShiftState;
  X, Y: Integer);
begin
  if (ssLeft in Shift) and (ssCtrl in Shift) then
  begin
    SpeedButton1.Left:= SpeedButton1.Left +  X - OldPoint.X;
    SpeedButton1.Top:= SpeedButton1.Top + Y - OldPoint.Y;
  end;
end;

end.


Saludos.
Responder Con Cita