How can I create a tray icon

2008-04-09 04:21:54来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折

{*****************************************************
* 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
value will be used as the callback message.

NIF_TIP: Passing this flag indicates that the value of szTip will
be used as the ToolTip for the icon in the taskbar status area.

uCallBackMessage: Identifier of the notification message sent to the
window that is used to receive the messages.
Data Type: UINT.

hIcon: Handle of the icon that is displayed in the taskbar status area.
Data Type: HICON.

szTip: String to be used as the ToolTip text.
Data Type: Fixed-length AnsiChar 64 bytes long.

*****************************************************}

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:GetIdeDiskSerialNumber

下一篇:Delphi 函数参考