procedure TForm1.WMSYSCOMMAND(var MSG: TWMSYSCOMAND);
begin
if MSG.CmdType = SC_Close then
begin
ShowWindow(Self.Handle, SW_Hide); //hide current window
//ShowWindow(Application.Handle, Show_Hide); //hide the whole application
MSG.Result := 0;
end;
end;