一般需要处理的消息都会和一个特定的事件挂钩
比如 cm-textchanged => OnChange事件等
另外的一些消息由Delphi自动完成,不需要特别处理,
假如你一定要截获它自己处理,则可以这样做:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons;type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
FOldWndProc: TWndMethod;
procedure ButtonWindowProc(var Message: TMessage);
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.ButtonWindowProc(var Message: TMessage);
begin
FWndProc( Message );
//Do your things...
end;procedure TForm1.FormCreate(Sender: TObject);
begin
FOldWndProc := Button1.WindowProc;
Button1.WindowProc := ButtonWindowProc;
end;end.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货