The reason behind this is the mechanism Shell_NotifyIcon function uses to send callback notifications.
I believe you are talking in context of the following MSDN article.
How To Manipulate Icons in the System Tray with Visual Basic
In this article all mouse-related messages are interpreted from the X argument in MouseMove event, like this...
___
[tt]
msg = X / Screen.TwipsPerPixelX
Select Case msg
Case WM_LBUTTONDOWN
Case WM_LBUTTONUP
Case WM_LBUTTONDBLCLK
Case WM_RBUTTONDOWN
Case WM_RBUTTONUP
Case WM_RBUTTONDBLCLK
End Select[/tt]
___
Note that Shell_NotifyIcon sends all these (and many more) messages as a single callback message. This callback message is specified by the caller at the time Shell_NotifyIcon function is called. This fact is stated in the documentation of
NOTIFYICONDATA Structure.
MSDN said:
uCallbackMessage
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 event occurs in the bounding rectangle of the icon, or when 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 pointer moves over a taskbar icon, lParam is set to WM_MOUSEMOVE. See the Taskbar guide chapter for further discussion.
The above fact is also mentioned in the documentation of
Shell_NotifyIcon Function.
MSDN said:
Note The messages discussed above are not conventional Windows messages. They are sent as the lParam value of the application-defined message that is specified when the icon is added with NIM_ADD.
In the VB example code mentioned above, WM_MOUSEMOVE message is used as the callback message idendifier.
[tt]
nid.uCallBackMessage = WM_MOUSEMOVE
[/tt]
This means that all messages are sent in the form of WM_MOUSEMOVE message, with lParam parameter specifying the actual mouse (or other) event. Note that using WM_MOUSEMOVE for this purpose is not necessary. You can use some other message as well, even a user-defined message identifier, which is not used as a standard window message.
When VB receives this message (in the form of WM_MOUSEMOVE) it treat it like regular windows message and translate it into VB MouseMove event.
Now take a look at the documentation of
WM_MOUSEMOVE Notification.
MSDN said:
lParam
The low-order word specifies the x-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
The high-order word specifies the y-coordinate of the cursor. The coordinate is relative to the upper-left corner of the client area.
When VB receives the WM_MOUSEMOVE message, it translate it to MouseMove event and X and Y arguments of the event are interpreted according to the above description.
In our case, the lParam parameter is holding the "actual" mouse event that occurs in the system tray. As the high-order word of the lParam parameter is absent in this case, Y is set to 0. The low-order word, which is holding the actual mouse event is assigned to the X argument after converting from Pixel-to-Twip scale.
Suppose you pressed the left mouse button in the tray. The value of WM_LBUTTONDOWN is &H201 = 513. Thus X parameter is assigned the value of 513 x Screen.TwipsPerPixelX = 513 x 15 = 7695 (assuming Screen.TwipsPerPixelX = 15).
Now VB code again converts this parameter to pixel scale to obtain the original message identifier that was sent by Shell.
___
[tt]
msg = X / Screen.TwipsPerPixelX
Select Case msg
...[/tt]
___
Note that these callback messages received in MouseMove events are not actually mouse move events. These are in fact callback messages sent by shell with actual event information embedded in X argument, as mentioned above. That is the reason you receive all mouse-related events (like double-click event) through MouseMove event.
The main reason for using WM_MOUSEMOVE message as callback message is that you do not need to subclass your window in order to get callback notifications, which would be, otherwise required if you use some other user-defined callback message identifier instead of WM_MOUSEMOVE.
Hope it all makes some sense.