From: Steve Teixeira <steixeir@borland.com>
Subject: Delphi Tricks & Tips
Date: Sun, 14 May 95 15:41:28 -0700

Mark,

The Delphi Tricks & Tips page look cool! It's a great idea!

I have one comment on the FloatWin sample, though: it's *much* more 
complicated than it needs to be.  All you have to do is handle 
Windows' wm_NCHitTest message.  Here is some code I wrote for a Borland 
Tech Info document that does the same thing.

     -steve

unit Dragmain;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    procedure WMNCHitTest(var M: TWMNCHitTest); message wm_NCHitTest;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.WMNCHitTest(var M: TWMNCHitTest);
begin
  inherited;                    { call the inherited message handler }
  if  M.Result = htClient then  { is the click in the client area?   }
    M.Result := htCaption;      { if so, make Windows think it's     }
                                { on the caption bar.                }
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Close;
end;

end.
