title: Drag and click on Delphi
body: <p>I made a simple form in Delphi, it contain a button.</p>
  
  <p>I want to when I click on button, a message was opened. And that button can be move by drag on it.</p>
  
  <p>This is my code</p>
  
  <pre><code>unit Unit1;
  
  interface
  
  uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
  
  type
    TForm1 = class(TForm)
      Button1: TButton;
      procedure Button1MouseDown(Sender: TObject; Button: TMouseButton;
        Shift: TShiftState; X, Y: Integer);
      procedure Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
        Y: Integer);
      procedure Button1MouseUp(Sender: TObject; Button: TMouseButton;
        Shift: TShiftState; X, Y: Integer);
      procedure Button1Click(Sender: TObject);
    private
      { Private declarations }
    public
      { Public declarations }
    end;
  
  var
    Form1: TForm1;
    xx,yy:integer;
    state:integer;
  
  implementation
  
  {$R *.dfm}
  
  procedure TForm1.Button1Click(Sender: TObject);
  begin
      showmessage('Clicked');
  end;
  
  procedure TForm1.Button1MouseDown(Sender: TObject; Button: TMouseButton;
    Shift: TShiftState; X, Y: Integer);
  begin
      state:=1;
      xx:=x;
      yy:=y;
  end;
  
  procedure TForm1.Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
    Y: Integer);
  begin
      case state of
          1:
              begin
                  button1.Left:=button1.Left+x-xx;
                  button1.Top:=button1.Top+y-yy;
              end;
      end;
  end;
  
  procedure TForm1.Button1MouseUp(Sender: TObject; Button: TMouseButton;
    Shift: TShiftState; X, Y: Integer);
  begin
      state:=0;
  end;
  
  end.
  </code></pre>
  
  <p>When I click on button, message showed. But when I drag it, it also show "Clicked" message.</p>
  
  <p>Please help me :(</p>
  
  <p>(Sorry about my English)</p>