annas
asked on
form with anywhere drag properties
How can I create a form that I can click and drag anywhere on it's surface, not just on the caption bar?
Thanks,
Paul
Thanks,
Paul
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
well, my version
unit moving_whole_form_u;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
CheckBox1: TCheckBox;
private
procedure WMNCHitTest(var Message : TWMNCHitTest); message WM_NCHITTEST;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.WMNCHitTest(var Message : TWMNCHitTest);
begin
inherited;
if checkbox1.checked then //Moving Toggle on/off check
if message.result = HTCLIENT then //client-area
message.result := HTCAPTION; //do so if the caption is clicked
end;
end.
meikl ;-)
unit moving_whole_form_u;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
CheckBox1: TCheckBox;
private
procedure WMNCHitTest(var Message : TWMNCHitTest); message WM_NCHITTEST;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.WMNCHitTest(var Message : TWMNCHitTest);
begin
inherited;
if checkbox1.checked then //Moving Toggle on/off check
if message.result = HTCLIENT then //client-area
message.result := HTCAPTION; //do so if the caption is clicked
end;
end.
meikl ;-)
gwena's second link is a good one :-)
ASKER
Yes that Worked Thanks Gwena and thanx for the search sitre!
Paul :)
Paul :)
Your welcome annas :-)
That search site has helped me out a lot!
That search site has helped me out a lot!
procedure TForm1.MouseDown(...);
begin
ReleaseCapture;
SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
end;
the idea is to 'trick' the window we're holding it by it's caption bar