刚做的,可以完美的解决你的问题
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function HookMinimize(code: integer; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
var
Form1: TForm1;
HookMin: DWORD = 0;
implementation
{$R *.dfm}
function HookMinimize(code: integer; wParam: WPARAM; lParam: LPARAM): LRESULT;
begin
if (code=HCBT_MINMAX) and (lParam = SW_MINIMIZE) then Exit;
Result:=CallNextHookEx(HookMin, Code, wParam, lParam);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
HookMin:=SetWindowsHookEx(WH_CBT, HookMinimize,0, GetCurrentThreadID);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
if HookMin<>0 then UnhookWindowsHookEx(HookMin);
end;
end.