A manufacturer specializing in plastic products

A use of the system tray

by:Qusheng     2020-11-11
A member of the set type NOTIFYICONDATA structure of variable the value of a variable: cbSize the size of the structure. The HWND of the window handle. When the mouse slip the small icon, the window will receive the message. UID target ID picture. You can take any value, just when your application has more than a small icon, you must be able to distinguish between what is a small icon that receive the mouse message, namely ID must be unique. UFlags specify the structure variables of those members effectively. NIF_ICON effectively. NIF_MESSAGE effectively. NIF_TIP effectively. The news of the uCallbackMessage custom. When the mouse movements of small ICONS, WINDOWS shell will send the message to your application. The news value, you can define your own. HIcon is put in the system tray icon in the handle. The szTip 64 bytes of buffer, it is used to in the prompt string, when the mouse stay on the small icon, will display the string. Call Shell_NotifyIcon function. The function in the shell32. Inc is defined, and its prototype is as follows:
Shell_NotifyIcon PROTO dwMessage: DWORD, pnid: DWORD dwMessage is sent to the WINDOWS shell message:
NIM_ADD add ICONS to the system tray.
NIM_DELETE deleted from the system tray icon.
NIM_MODIFY modify the small icon.
pnid is a pointer to the variable type NOTIFYICONDATA structure.
if you want to add a small icon will use NIM_ADD, delete use NIM_DELETE.
basically the message is that these. But most of the cases, you will not only meet the put a small icon in there. You also have to respond properly to mouse events. You can type in the NOTIFYICONDATA structure variables uCallbackMessage member variables in the Settings you have to deal with the message, and then the shell will notify your application when the incident. As the messaging wParam and lParam parameters are as follows:
wParam target ID picture. It and you type in the NOTIFYICONDATA structure members of the variables in the uID value set. LParam low word contains the mouse message. For example, when users click the right click on the small icon, lParam will contain WM_RBUTTONDOWN message. Most of the little icon in the system tray, when the user right click with the mouse will pop up a menu for the user to select. We can create the menu first, and then call TrackPopupMenu function to display it. Steps are as follows:
call CreatePopupMenu function to create a menu. This function creates an empty menu. If successful, will be returned in the eax handle to the menu. Call, AppendMenu, InsertMenu or InsertMenuItem to menu to add menu items. When you want to in the current mouse position according to the menu, invoked GetCursorPosition function to get the current mouse position screen, and then call TrackPopupMenu to display the menu. When a user from the pop-up menu select a menu item, WINDOWS will send WM_COMMAND messages to your application's process, and this usually is the same menu choices.
Custom message
Chat Online 编辑模式下无法使用
Chat Online inputting...