To yeah:<br> 不是没有人回答,是已经回答了。<br> 你的控件应该继承 TComponent 类,放到窗体上之后,它的 Owner 默认就是 Form 。<br> TMyComponent = class (Component)<br> private<br> ...<br> OldWndProc: Pointer;<br> procedure WndProc(var Msg: TMessage);<br> ...<br> public<br> constructor Create(AOwner: TComponent);<br> end;<br>constructor TMyComponent.Create(AOwner: TComponent);<br>begin<br> Inherited;<br> OldWndProc=GetWindowLong(TForm(AOwner.Handle), GWL_WNDPROC);<br> SetWindowLong(TForm(AOwner.Handle), GWL_WNDPROC, Longint(MakeObjectInstance(WndProc)));<br>end;<br><br>procedure TMyComponent.WndProc(var Msg: TMessage);<br>begin<br> with Msg do<br> if Msg = (Messages you need) then (Do you operations)<br> else<br> Result := CallWindowProc(OldWndProc, TForm(AOwner.Handle), Msg, wParam, lParam);<br>end;<br>