: I'm new to programming the Windows shell. I'm trying to simply get my
: dialog based application to display an icon in the system tray.
: Unfortunately, all it ever does it create the empty space for the icon and
: the icon never gets displayed.
Your code looks OK, except for the following (some may not be relevant
though they caught my eye):
: pTrayIcon.uID = NULL;
uID shouldn't be NULL, although it's not stated in the docs:
Application-defined identifier of the taskbar icon. The shell uses hWnd and
uID to identify which icon is to be operated on when Shell_NotifyIcon is
invoked. You can have multiple icons associated with a single hWnd by
assigning each a diffent uID.
: pTrayIcon.uFlags = NIF_ICON || NIF_TIP || NIF_MESSAGE;
I think you meant to use | here, not ||, unless this is a typo...
: pTrayIcon.uCallbackMessage = NULL;
If uCallbackMessage is NULL, exactly how is the shell going to notify you?
Application-defined message identifier. The system uses this identifier to
send notifications to the window identified in hWnd. These notifications are
sent when a mouse or event occurs in the bounding rectangle of the icon or
the icon is selected or activated with the keyboard. The wParam parameter of
the message contains the identifier of the taskbar icon in which the event
occurred. The lParam parameter holds the mouse or keyboard message
associated with the event. For example, when the mouse cursor moves over a
taskbar icon, lParam is set to WM_MOUSEMOVE. See the Taskbar guide chapter
for further discussion.
-- also --
Receiving status area callback messages
Applications commonly put icons in the status area of the taskbar to serve
as status indicators. You can provide additional information when the user
performs mouse actions, such as moving the mouse pointer over the icon or
clicking the icon.
The system notifies you of mouse and keyboard events by sending an
application-defined callback message that is associated with a particular
icon. In this way, the system can notify an application when the user, for
instance, clicks the icon or selects it by pressing a key.
You define an icon's callback message when you add the icon to the taskbar.
The callback message identifier is specified in the uCallbackMessage member
of the NOTIFYICONDATA structure passed with NIM_ADD. When an event occurs,
the system sends the callback message to the window procedure of the window
specified by the hWnd member. The wParam parameter of the message contains
the identifier of the taskbar icon in which the event occurred. The lParam
parameter holds the mouse or keyboard message associated with the event. For
example, when the mouse pointer moves onto a taskbar icon, lParam contains
The results of various mouse events can be summarized as follows:
a.. When the user moves the mouse pointer over the icon, the system
displays the tooltip text that was specified in NOTIFYICONDATA.
b.. When the user clicks the icon, your application receives a
c.. When the user right-clicks the icon, your application receives a
d.. When the user double-clicks the icon, your application receives a
Typically, clicking the icon causes the application to display a window with
additional information, right-clicking displays a shortcut menu, and
double-clicking executes the default shortcut menu command.
For an example of how to change the tooltip text associated with a status
area icon, see Balloon Tooltips for Status Bar Icons.
Versions 5.0 and later of the shell handle Shell_NotifyIcon mouse and
keyboard events differently than earlier shell versions, found on Windows NT
4.0, Windows 95, and Windows 98. The differences are:
a.. If a user requests a notify icon's context menu with the keyboard, the
version 5.0 shell sends the associated application a WM_CONTEXTMENU message.
Earlier versions send WM_RBUTTONDOWN and WM_RBUTTONUP messages.
b.. If a user selects a notify icon with the keyboard and activates it
with the space bar or ENTER key, the version 5.0 shell sends the associated
application an NIN_KEYSELECT notification. Earlier versions send
WM_RBUTTONDOWN and WM_RBUTTONUP messages.
c.. If a user selects a notify icon with the mouse and activates it with
the ENTER key, the version 5.0 shell sends the associated application an
NIN_SELECT notification. Earlier versions send WM_RBUTTONDOWN and
You can select which way the shell should behave by calling Shell_NotifyIcon
with dwMessage set to NIM_SETVERSION. Set the uVersion member of the
NOTIFYICONDATA structure to indicate whether you want version 5.0 or
pre-version 5.0 behavior.
Please reply to newsgroups, not by e-mail. | ICQ: 6930718