加个ApplicationEvents,添加以下代码procedure TfrmMain.ApplicationEvents1Message(var Msg: tagMSG;
  var Handled: Boolean);
begin
 if (Msg.message = WM_SYSCOMMAND) and
      (Msg.wParam = SC_RESTORE) then //还原
  begin
    ShowMessage(inttostr(msg.wParam)+'  '+inttostr(WM_SYSCOMMAND));
    //做你想做的事
Handled := True;
  end
  else if (Msg.message = WM_SYSCOMMAND) and
      (Msg.wParam = SC_CLOSE) then //关闭
  begin
    ShowMessage(inttostr(msg.wParam)+'  '+inttostr(WM_SYSCOMMAND));
    //做你想做的事
Handled := True;
  end
  else if (Msg.message = WM_SYSCOMMAND) and
      (Msg.wParam = SC_MINIMIZE) then //最小化
  begin
    //ShowMessage(inttostr(msg.wParam)+'  '+inttostr(WM_SYSCOMMAND));
  //做你想做的事
    Handled := True;
  end;
end;