Author: Tomas Rutkauskas
Floating toolbar
Answer:
All you have to do is handle Windows' wm_NCHitTest message.
(Compare to the tip how to drag a window without a caption bar. It's the same
technique.)
1 unit Dragmain;
2 3 interface4 5 uses6 SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
7 Forms, Dialogs, StdCtrls;
8 9 type10 TForm1 = class(TForm)
11 Button1: TButton;
12 procedure Button1Click(Sender: TObject);
13 private14 procedure WMNCHitTest(var M: TWMNCHitTest); message wm_NCHitTest;
15 end;
16 17 var18 Form1: TForm1;
19 20 implementation21 22 {$R *.DFM}23 24 procedure TForm1.WMNCHitTest(var M: TWMNCHitTest);
25 begin26 inherited; { call the inherited message handler }27 if M.Result = htClient then{ is the click in the client area? }28 M.Result := htCaption; { if so, make Windows think it's }29 { on the caption bar. }30 end;
31 32 procedure TForm1.Button1Click(Sender: TObject);
33 begin34 Close;
35 end;
36 37 end.