Put this

procedure WMSysCommand(var Msg : TWMSysCommand); message WM_SYSCOMMAND;

in your form private - add the routine and bob's your uncle.

Works for us - and we have this code used in hundreds of programs