I am looking for a way to trap the specific event when a user clicks the 'X' (close button) on the upper right of the form.
I know about the Sub Form_qureryUnload(Cancel as Integer, UnloadMode as Integer) , however this returns the same UnloadMode of 0(zero) for;
1. clicking 'Close' in the control menu.
3. Clicking the 'X' in the upper right corner.
which is how its suppose to work.
However I want to trap for the "X" click *only* and leave the other two close methods as is.
Any ideas on how to determine a click specifically on the 'X'?
I am subclassing the form to add items to the form's control menu and also to send the App. to the system tray.
I found that 61536 is the system command for the close event but as with the above Sub, it reports this same number for any of the 3 events listed.
I'm sure the wHandle of the "X" can be ID'd and determine if its been click but I can't figure out how.
I've tried some heavy web searches and couldn't find this exact answer I need.
I have seen plenty of examples of disabling and/or removing the 'X'. (Not what I want to do).
I want to leave the "X" on the form, and leave it enabled so when a user clicks it, instead of closing the form it will send my App to the SysTray. If the user clicks 'Close' on the control menu or Alt-F4 then the App should close as normal.
I already have the Systray code working just fine, I just need to know how to trap the 'X' click.
Thanks in advance,