What you can do is either

1/. (best)

  TMyPanel = class(TPanel)
  private
    procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;  
  end;

  TMyComp = class(TComponent)
  private
    FMyPanel : TMyPanel;
  public
    { Public declarations }
  end;

or you can hook into the WindowProc of a TPanel to trap the message

2/.

  TMyComp = class(TComponent)
  private
    FMyPanel : TMyPanel;
    FSaveWindowProc: TWndMethod;
    procedure PanelWindowProc(var Message: TMessage);
  public
    { Public declarations }
  end;

procedure TMyComp.PanelWindowProc(var Message: TMessage);
begin
  if Message.Msg = CM_MouseLeave then begin
// Your code
  end
  else FSaveWindowProc(Message);
end;

constructor TMyComp.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FMyPanel := TPanel.Create;
  FSaveWindowProc := FMyPanel.WindowProc;
  FMyPanel.WindowProc := PanelWindowProc;
end;

I talked recently about problems when more than one object try to hook the
same event, but here you're only hooking WindowProc once so it isn't an
issue.

Cheers,
Carl

-----Original Message-----
From: Donovan J. Edye [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 4 July 2000 11:36 AM
To: Multiple recipients of list delphi
Subject: [DUG]: Handling Messages....


G'Day.

I understand that by doning the following:

type
  TForm1 = class(TForm)
  private
    procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.CMMouseLeave(var Message: TMessage);
begin
end;

I can trap mouse leave messages. However what do I do if if I have:

type
  TMyComp = class(TComponent)
  private
    FMyPanel : TPanel;
  public
    { Public declarations }
  end;

- FMyPanel gets created in the contructor of the component and I want to
capture its mouse leave message? Any pointers, etc.

TIA

------------------------------------------------------------------------
--Donovan
Donovan J. Edye [www.edye.wattle.id.au]
Namadgi Systems, Delphi Developer
Web: www.namsys.com.au E-Mail: [EMAIL PROTECTED]
Voice: +61 2 6285-3460 Fax: +61 2 6285-3459
TVisualBasic = Class(None);
GExplorer [http://www.gexperts.com/gxexplorer/] Freeware Windows Explorer
replacement. Also includes freeware delphi windows explorer components.
------------------------------------------------------------------------

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to