[shell-coding] Vista System tray implementation
- From: "Shaun Barlow" <shaun.barlow@xxxxxxxx>
- To: shell-coding@xxxxxxxxxxxxx
- Date: Tue, 13 Jan 2009 23:59:57 +0200
Hi,
I've been doing a bit of work on the vista system tray implementation
for bb4win and I would just like to share what I have so far, for
those interested. If you would like more information on a specific
section of this I would be happy to provide it.
Handling of COPYDATA messages sent to Shell_NotifyWnd
================================================
Messages with dwData = 1 (generated by Shell_NotifyIcon) need
basically the same handling for NIM_ADD, NIM_MODIFY and NIM_DELETE as
before. The vista struct has some new members used for large icons in
balloon tooltips, but is otherwise the same.
It is important to handle NIM_SETVERSION when running under Vista.
Returning false will cause the network icon not to update. Icons which
set the version to 4 (Vista behavior) will expect special treatment
for mouse messages (see below). Version 4 icons also expect their
tooltip not to be shown by default.
Message with dwData = 0 (generate by SHAppBarMessage) are not
required, but should be handled to allow proper positioning of the
interfaces for the new vista icons. The minimum needed for correct
positioning is to handle ABM_GETTASKBARPOS and to have the returned
rectangle and edge correspond to the location of the interface
containing the tray.
Handling of mouse message
======================
Icon which have NOT set the version to 4 expect their messages in the form
SendNotifyMessage(hWnd, uCallbackMessage, uID, <message here> )
these are handled correctly by every shell I know of :)
Icons which have called NIM_SETVERSION and set it to 4 expect their
messages in the form:
SendNotifyMessage(hWnd, uCallbackMessage, MAKEWPARAM(<mouse x>,<mouse
y>), MAKELPARAM(<message here>, uID))
<mouse x> and <mouse y> should be the location of the mouse at the
time of the message in screen coordinates. These will be used for the
positioning of popup interfaces (along with some other information)
The messages you send to the icon also require some translation from
raw mouse messages. Translations I currently use are:
WM_RBUTTONUP becomes WM_CONTEXT, for correct display of the right click menu
WM_MOUSEMOVE becomes NIN_POPUPOPEN, so that the vista icons can
display their mouseover interfaces which replace the tooltip. It is
important to only send NIN_POPUPOPEN once, and then block it until you
have sent NIN_POPUPCLOSE. The vista network icon does not track the
state of its popup and will attempt to show it repeatedly if you don't
do this
WM_MOUSELEAVE becomes NIN_POPUPCLOSE, to get icons to close their
popup interaces. You need to register for WM_MOUSELEAVE using
TrackMouseEvent
All other messages are passed on as is.
How icons position their popup interfaces
=================================
This applies both to the interfaces shown for NIN_POPUPOPEN and to
those shown when you left click the icon.
There are two approaches to this used by vista own icons.
The volume icon uses SHAppBarMessage with ABM_GETTASKBARPOS to get the
rectangle and edge of the taskbar. For bottom and top bars it will
then use the rectangle and the <mouse x> value it received to position
its interface just above or below the bar, in line with the icon. For
left and right bars it uses the rectangle and <mouse y> to position
itself inline with the icon to the left or right of the bar. It will
always position itself as expected if it recieves the proper values
for its ABM_GETTASKBARPOS call.
The network icon use GetWindowRect to fetch the rectangle of
Shell_NotifyWnd. It then guesses the edge based on that rectangle.
Positioning after its guesses the edge the follows the same idea as
for the volume icon. This approach will cause cases where
Shell_NotifyWnd is at the bottom, but is only as large as the tray to
be falsely detected as right or left aligned, causing a popup to
display on its side rather than above it
That basically describes everything I know on the vista tray and how
its icons behave a the moment.
I'd be interested in knowing if anyone else has any other infomration on this.
Regards,
Carsomyr
__________________________________________________
Subscription options and archive:
http://www.freelists.org/list/shell-coding
Other related posts: