Joe Klebau
April 23rd, 1999, 03:49 PM
I have written a VC++ 6.0 app wizard .exe dialog based app that has to have an icon in the system tray. I am using the Shell_NotifyIcon() call, which creates a place for the icon in the system tray, but no icon is displayed. If I double click the spot where the icon would be displayed, I get the MYWM_NOTIFYICON message that I specified (and lParam is WM_LBUTTONDBLCLK). The call I am using is:
BOOL CTrayIconDlg::OnInitDialog()
{
CDialog::OnInitDialog();
HICON my_icon = AfxGetApp()->LoadIcon(IDI_ICON1);
NOTIFYICONDATA tray_icon_struct;
tray_icon_struct.cbSize = sizeof(NOTIFYICONDATA);
tray_icon_struct.uID = TRAY_ICON_UID;
tray_icon_struct.hWnd = m_hWnd;
tray_icon_struct.uFlags = NIF_ICON | NIF_MESSAGE;
tray_icon_struct.uCallbackMessage = MYWM_NOTIFYICON;
tray_icon_struct.hIcon = my_icon;
tray_icon_struct.szTip[0] = 0;
res = Shell_NotifyIcon(NIM_ADD, &tray_icon_struct);
return TRUE; // return TRUE unless you set the focus to a control
}
IDI_ICON1 has both 32x32 and 16x16 icons (both 16 and 4 color), and my_icon is a valid HICON (non-null). Any tricks that I am missing?
- jmk...
BOOL CTrayIconDlg::OnInitDialog()
{
CDialog::OnInitDialog();
HICON my_icon = AfxGetApp()->LoadIcon(IDI_ICON1);
NOTIFYICONDATA tray_icon_struct;
tray_icon_struct.cbSize = sizeof(NOTIFYICONDATA);
tray_icon_struct.uID = TRAY_ICON_UID;
tray_icon_struct.hWnd = m_hWnd;
tray_icon_struct.uFlags = NIF_ICON | NIF_MESSAGE;
tray_icon_struct.uCallbackMessage = MYWM_NOTIFYICON;
tray_icon_struct.hIcon = my_icon;
tray_icon_struct.szTip[0] = 0;
res = Shell_NotifyIcon(NIM_ADD, &tray_icon_struct);
return TRUE; // return TRUE unless you set the focus to a control
}
IDI_ICON1 has both 32x32 and 16x16 icons (both 16 and 4 color), and my_icon is a valid HICON (non-null). Any tricks that I am missing?
- jmk...