Wednesday, March 2, 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 );
  { 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;
Source : 

Twitter Delicious Facebook Digg Stumbleupon Favorites More

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