title: Delphi drag and drop panels in container
body: <p>How can I catch the onDargDrop event when using this approach:</p>
  
  <pre><code>procedure TMain.layerRowMouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);
  begin
    ReleaseCapture;
    (Sender as TPanel).Perform(wm_nclbuttondown,HTCAPTION,0);
  // and now in order to preserve the nice alignment of panels...
    for i := 0 to Main.ComponentCount - 1 do
      begin
        if Main.Components[i] is TWinControl then
          if TWinControl(Main.Components[i]) is TPanel then
          if (TWinControl(Main.Components[i]) as TPanel).Parent=Main.ScrollBox1 then
            begin
              (TWinControl(Main.Components[i]) as TPanel).Align:=alTop;
            end;
      end;
    end;
  </code></pre>
  
  <p>I mean, the drag/drop works but being an OnMouseDown event... this fires everytime I click on the panel. I want to be able to differentiate between clicking and dragging.</p>
  
  <p>More specifically, I have a panel, inside it I have a scrollbox (alClient).
  Then at runtime, onButtonClick I create panels containing some stuff, and I align them alTop. So my panels align themselves to top, bellow the older ones just like in this picture:</p>
  
  <p><img src="https://i.stack.imgur.com/EieSx.jpg" alt="enter image description here"></p>
  
  <p>So, I add panel1, it adds itself to the top, then I add panel2 it adds itself bellow panel1, and so on (just like in the picture).</p>
  
  <p>Now, I want to be able to move panels around (change their order), so I use the above code that I attach to each panel to it's onMouseDown event.</p>
  
  <p>So it works ok, but I need to know when an actual drag/drop occurs because I need to be doing some code after the drag/drop happens, and I cannot have that code execute everytime a mouse click happens.</p>
  
  <p>So what do you suggest?
  This approach is nice, because looks simple and also shows the panel while dragging. So I need a similar solution or a way to differentiate in the onMouseDown: when it's just click and when it is drag/drop</p>
  
  <p>Thank you</p>