Tuesday, March 1, 2011

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;
 
Source : http://www.chami.com/tips/delphi/010397D.html 

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Kang Iwan K-sev | Thank's for your visit To My Site - Ridwan Mulyana | Cibeureum