Preventing an application exit from the task bar's right click Close
menu
Hello gentlemen,
I am developping an application that uses the system tray (I want it to
behave like MSN Messenger)
That being said, I am almost there.
There is one issue I could not solve and it is how to distinguish and
prevent my application to quit when the user right-clicks on the
application's entry on the task bar and selects close when the UI is
visible. I want the application to only minimize when this action is
performed. I was able to prevent this in a way but it is not the proper
way I beleive because when I try to kill the application from the Task
Manager, the "Application not responding" window appears.
I prevented my application to quit from the taskbar's close menu by
overriding the WindowProc method from the main frame.
LRESULT TMainFrame::WindowProc(UINT Message, WPARAM wparam, LPARAM lparam)
{
if(Message == WM_QUERYENDSESSION )
canClose = TRUE;
return CFrameWnd::WindowProc(Message, wparam, lparam);
}
and in the OnClose() method I only close if canClose is TRUE otherwise I
hide the window ShowWindow(SW_HIDE);
Is there a parameter in wparam or lparam of the WindowProc that allows
me to find out if the WM_CLOSE message received is from the task bar?
MSN Messenger can handle all those situation very well.
Thank you for any suggestions.
Simon