从现有控件中派生新的控件。举个例子吧。
TNewCompont = class(TComponent)
private
{ Private declarations }
FWndHandle:THandle;
......
public
{ Public declarations }
constructor Create(AOwner:TComponent);override;
destructor Destroy;override;
procedure WndProc(var Msg:TMessage);
constructor TNewCompont .Create(AOwner: TComponent);
begin
inherited;
FWndHandle:=AllocateHWnd(WndProc);
end;
destructor TNewCompont.Destroy;
begin
DeallocateHWnd(FWndHandle);
inherited;
end;
procedure TNewCompont.WndProc(var Msg: TMessage);
begin
if Msg.Msg=WM_MouseMove then
begin
..........//在此处理消息
end
else
Dispatch(Msg);
end;