unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
WProc: Pointer = nil;
function NewWndProc(Handle: hWnd; Msg, WParam, lParam: Longint): Longint; stdcall;
begin
if Msg = WM_CLOSE then
begin
ShowMessage('I GET IT');
Msg := 0;
end;
Result := CallWindowProc(WProc, Handle, Msg, WParam, lParam);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
WProc := Pointer(SetWindowLong(Self.Handle,GWL_WNDPROC,Integer(@NewWndProc)));
end;
end.
这个是你想要的吗?