size : 754
uploaded_on : Wed Jul 7 00:00:00 1999
modified_on : Wed Dec 8 14:02:50 1999
title : Drag form
org_filename : DragForm.txt
author : Zlatko Petkov
authoremail : z-petkov@bgnet.bg
description : How to drag-and-drop a form
keywords :
tested : not tested yet
submitted_by : The CKB Crew
submitted_by_email : ckb@netalive.org
uploaded_by : nobody
modified_by : nobody
owner : nobody
lang : plain
file-type : text/plain
category : delphi-components
__END_OF_HEADER__
> How can I drag and drop a form, dragging, not only the caption of the
> form, but also the "body"?
The most common way to move an application window is to drag it by its
title (or caption) bar. If you want to give your users the ability to move
your application by dragging it by clicking anywhere on your application
window, here's what you can do:
Insert following line into your form's "Private declarations" section:
procedure WMNCHitTest(var Msg: TWMNCHitTest); message wm_NCHitTest;
Add following code into the "implementation" section of your form's unit
(assuming that your form is named Form1):
procedure TForm1.WMNCHitTest(var Msg:TWMNCHitTest);
begin
inherited;
if (htClient = Msg.Result) then Msg.Result := htCaption;
end;