Application.EnableMenuItems
From Xojo Documentation
Event
Called when the user clicks in the menubar to give you the opportunity to determine which menu items to enable.
Notes
It also is called when the app opens if no default window is selected for the project and when the last window is closed.