How can I create a tray icon[1]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 safef8 的 blog

{*****************************************************
* how can i create a tray icon? *

fortunately, creating an application that runs in the system tray is pretty easy -
only one (api) function, shell_notifyicon, is needed to accomplish the task.
the function is defined in the shellapi unit and requires two parameters.

the first parameter (dwmessage) specifies the action to be taken.
this parameter can be one of the following values:

nim_add: adds an icon to the status area.
nim_delete: deletes an icon from the status area.
nim_modify: modifies an icon in the status area.

* to display an icon in the system tray, call shell_notifyicon with
the nim_add flag.

* any time you want to change the icon, tooltip text,
etc, you can call shell_notifyicon with nim_modify.

* before your program terminates, call shell_notifyicon with nim_delete
to clear your icon from the system tray.

the second parameter (pnid) is a pointer to a tnotifyicondata structure
holding the information about the icon.

the tnotifyicondata structure contains the following elements:

cbsize: passes the size of the notifyicondata data type.
data type: dword.

hwnd: handle of the window used to receive the notification message.
data type: hwnd.

uid: identifier of the icon in the status area.
data type: uint.

uflags: array of flags that indicate which of the other members contain
valid data.
data type: uint.
value: any combination of the following constants to indicate that
the member of this structure is valid and will be used:

nif_icon: passing this flag indicates that the value for the
hicon will be the icon that appears in the taskbar status area.

nif_message: passing this flag indicates that the ucallbackmessage

本文关键:How can I create a tray icon
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top