Thank-you anonytmouse for the reply, but I did try to play with the WM_CLOSE and it did not seem to work for me. Perhaps I was using the wrong coding.
Anyway, I did come up with a resolve. Since the program that I am building minimizes to the system tray, and it is a toolbar window, I accessed the WM_SYSCOMMAND. Here is the code that I came up with:
Code:
case WM_SYSCOMMAND:
if (LOWORD (wParam) == SC_CLOSE) {
SendMessage(hWnd,WM_SIZE,SIZE_MINIMIZED,NULL);
return 1;
}
break;
Now everytime the toolbar "x" is used the application minimizes to the system tray. Within the WM_SIZE I have a call to a procedure that sets up the icon.
Code:
case WM_SIZE:
if(wParam==SIZE_MINIMIZED) {
ShowWindow(hWnd,SW_HIDE);
NotifySysIcon(hWnd,IDI_ICON,ToolTip,NIM_MODIFY);
}
else if(wParam==SIZE_RESTORED) {
ShowWindow(hWnd,SW_NORMAL);
NotifySysIcon(hWnd,IDI_ICON1,ToolTipNew,NIM_MODIFY);
}
break;
And just for completion sake, here is the NotifySysIcon proc:
Code:
int NotifySysIcon (HWND hWnd,int IconNum,PSTR ToolTip,DWORD NimType)
{
Nicon.cbSize=sizeof(NOTIFYICONDATA);
Nicon.hIcon = LoadIcon(hInst,MAKEINTRESOURCE(IconNum));
Nicon.hWnd = hWnd;
Nicon.uFlags = NIF_ICON|NIF_MESSAGE|NIF_TIP;
Nicon.uCallbackMessage = WM_TRAYMESSAGE;
Nicon.uID = ICONIDENT;
strcpy(Nicon.szTip,ToolTip);
Shell_NotifyIcon(NimType,&Nicon);
return 0;
}
Hopefully this will be useful to someone.