The last line of AppEventHandlerProc() [line 205] should be changed from
return errAEEventNotHandled;
to
return eventNotHandledErr;
as this is a Carbon Event handler, not an AE handler. This will allow the Menu Manager to automatically handle commands like Hide Application, Hide Others, etc.