Why always drag a window by its title bar?
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 two lines 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;
{ fool windows by telling it
that it's in our caption area
although it's in our client area }
if( htClient = Msg.Result )then
Msg.Result := htCaption;
end;
|
Applicable Keywords : Delphi, Delphi 1.x, Delphi 2.x, Functions, Win32