Click to See Complete Forum and Search --> : Tray icon in Pocket PC 2002


dallaz
June 14th, 2002, 07:24 AM
I cant get my icon to turn up in my app.
I have a dialog based app and in OnInitDialog() I do the following:

NOTIFYICONDATA tnd;
tnd.cbSize = sizeof(NOTIFYICONDATA);
tnd.hWnd = this->GetSafeHwnd();
tnd.uID = 133;
tnd.uFlags = NIF_ICON;
tnd.uCallbackMessage = WM_ICONMESS;
tnd.hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

int res = Shell_NotifyIcon(NIM_ADD, &tnd);

When the dialog is shown, It covers the system tray so you can't see any icons, but when I hide the dialog, using:
ShowWindow(SW_MINIMIZE);
ShowWindow(SW_HIDE);
my icon isn't there!
BUT! When I click in the area where is should be, my dialog is shown again...

Someone knows what's wrong here?
Regards
/Johan

dallaz
June 18th, 2002, 01:37 AM
Well, I managed to solve it by myself.. And since there was no reply, I thought that perhaps someother could be helped by an answer on this some time..
The answer is - the system tray doesn't seem to support LoadIcon().:confused:
You have to use LoadImage() instead (se below)
I Hope this can help someone to not get stuck... :)

tnd.cbSize = sizeof(NOTIFYICONDATA);
tnd.hWnd = this->GetSafeHwnd();
tnd.uID = 133;
tnd.uFlags = NIF_ICON|NIF_MESSAGE;
tnd.uCallbackMessage = WM_ICONMESS;
tnd.hIcon = (HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE (TRAY_ICON),IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);

Shell_NotifyIcon(NIM_ADD, &tnd);

/Johan