Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2005 Aug : how to drag the form to move through drag the panel on the form but not drag the

www.cryer.info
Managed Newsgroup Archive

how to drag the form to move through drag the panel on the form but not drag the

Subject:how to drag the form to move through drag the panel on the form but not drag the
Posted by:"dark_wei" (dark_w..@163.com)
Date:Mon, 15 Aug 2005 14:06:55 +0800

how to drag the form to move through drag the panel on the form but not drag
the title bar of the form?
I write a simple program but has problem,why?Please see the detail on the
comments below.
----------------------------------------------------------------------------
---------------
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls;

type
  Tpanel1 = class(Tpanel)
  private
    procedure WMNCHitTest(var Message: TWMNCHitTest); message WM_NCHITTEST;
  end;

  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
    pnl:Tpanel1;
    procedure WMNCHitTest(var Message: TWMNCHitTest); message WM_NCHITTEST;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
procedure Tpanel1.WMNCHitTest(var Message: TWMNCHitTest);
begin
  message.Result:=HTTRANSPARENT;
  //let the message to it's parent form
  inherited;
end;

procedure TForm1.WMNCHitTest(var Message: TWMNCHitTest);
begin
  with message do
  begin
    if (xpos>=0)and(xpos<=100)and(ypos>=0)and(ypos<=200) then
      result:=HTCAPTION;
      //if on the panel,send message to the form,but it doesn't run
correctly,why?
  end;
  inherited;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  pnl:=Tpanel1.Create(self);
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  pnl.Parent:=self;
  pnl.Top:=0;
  pnl.Left:=0;
  pnl.Width:=100;
  pnl.Height:=200;
end;

end.

Glossary

File Types

Replies:

www.cryer.info
Managed Newsgroup Archive