Ok, I've found this example http://www.codeproject.com/useritems...ndowToTray.asp
And I've modified this part, it intercepts all command messages so I can process my own.
Code:
LRESULT CALLBACK MenuCommandHookProc(int nCode, WPARAM wParam, LPARAM lParam)
{
// return immediately if system required
if (nCode < 0){
return CallNextHookEx(g_hMenuCommandHook, nCode, wParam, lParam);
}
// process the arrival message
MSG *msg = (MSG*)lParam;
switch (msg->message) {
case WM_SYSCOMMAND:
//Steve's Editing.
if(LOWORD(msg->wParam) == SC_CLOSE){
if(FindWindow("MozillaUIWindowClass","Mozilla Sunbird")==(HWND)msg->hwnd)
{
//Change message to minimize instead of close
msg->wParam=SC_MINIMIZE;
}
}
break;
}
// call next hook
return CallNextHookEx(g_hMenuCommandHook, nCode, wParam, lParam);
}
And this works for when close is selected in the system menu, well for now its just changed to minimize, but that works. But I'm not sure what the message is for clicking on the close symbol.
For the system menu its, WM_SYSCOMMAND, with wParam=SC_CLOSE
Can anybody tell me?