On Fri, Nov 13, 2009 at 22:22, Rich Cooper <r...@englishlogickernel.com> wrote:
> Hi All,
>
> Is there a really simple way to let the user drag a Panel around a Form at
> runtime?
>
> I'm reading the tutorials on how to do it, and they get fully into drag and
> drop stuff I don't want to spend learning time on.  I just want to do the
> dragging around the form.  Is there a quick and dirty answer to that?
>
> -Rich

Hi, you can create your own TPanel descendant to do this easily:

type
  TDragMovePanel = class(TPanel)
  protected
    procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X,
Y: Integer); override;
  end;

procedure TDragMovePanel.MouseDown(Button: TMouseButton; Shift:
TShiftState; X, Y: Integer);
begin
  if (Button = mbLeft) then begin
    ReleaseCapture;
    Perform(WM_SYSCOMMAND, SC_DRAGMOVE, 0);
  end else begin
    inherited MouseDown(Button, Shift, X, Y);
  end;
end;

Maybe this also works inside a TPanel's OnMouseDown event, but I
haven't tested that.

HTH,
Markus
_______________________________________________
Delphi mailing list -> Delphi@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

Reply via email to