type
TForm1 = class(TForm)
Shape1: TShape;
Shape2: TShape;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
OldProc: TWndMethod;
public
{ Public declarations }
procedure NewWinProc(var Message: TMessage);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
OldProc:=Shape1.WindowProc;
Shape1.WindowProc:=NewWinProc;
end;
procedure TForm1.NewWinProc(var Message: TMessage);
begin
if Message.Msg=WM_PAINT then
begin
Shape1.Shape:=stCircle;
Shape2.Invalidate;//重绘
end;
OldProc(Message);
end;