Shell_NotifyIcon function

Sends a message to the taskbar's status area.向任务栏状态区发送消息。

Syntax

C++
BOOL Shell_NotifyIcon(_In_  DWORD dwMessage,_In_  PNOTIFYICONDATA lpdata
);

Parameters

dwMessage [in]

Type: DWORD

A value that specifies the action to be taken by this function. It can have one of the following values:这个函数可以执行的动作。可以是下面一个或几个值:(所谓NIM就是Notify Icon Message)

NIM_ADD (0x00000000)

0x00000000. Adds an icon to the status area. The icon is given an identifier in theNOTIFYICONDATA structure pointed to by lpdata—either through itsuID or guidItem member. This identifier is used in subsequent calls toShell_NotifyIcon to perform later actions on the icon.向状态区域添加图标。给图标指定一个由名为lpdata的NOTIFYICONDATA结构指向的标识符,这个标识符可以由uID或者guidItem给定。一旦函数Shell_NotifyIcon被调用,这个标识符就作用于图标了。

NIM_MODIFY (0x00000001)

0x00000001. Modifies an icon in the status area. NOTIFYICONDATA structure pointed to by lpdata uses the ID originally assigned to the icon when it was added to the notification area (NIM_ADD) to identify the icon to be modified.修改状态区域的图标。当(使用NIM_ADD)添加到通知区域的图标被修改时,NOTIFYICONDATA类型的lpdata使用原始的图标ID。

NIM_DELETE (0x00000002)

0x00000002. Deletes an icon from the status area. NOTIFYICONDATA structure pointed to by lpdata uses the ID originally assigned to the icon when it was added to the notification area (NIM_ADD) to identify the icon to be deleted.删除状态区域的图标。当(使用NIM_ADD)添加到通知区域的图标被删除时,名为lpdata的NOTIFYICONDATA结构体使用原始的图标ID。

NIM_SETFOCUS (0x00000003)

0x00000003. Shell32.dll version 5.0 and later only. Returns focus to the taskbar notification area. Notification area icons should use this message when they have completed their UI operation. For example, if the icon displays a shortcut menu, but the user presses ESC to cancel it, use NIM_SETFOCUS to return focus to the notification area.使通知区域获得焦点。当通知区域图标完成了UI操作后,应该使用这个消息。例如,如果图标显示了快捷菜单,但是用户按下了ESC取消操作,应当使用NIM_SETFOCUS消息以使焦点返回到通知区域。

NIM_SETVERSION (0x00000004)

0x00000004. Shell32.dll version 5.0 and later only. Instructs the notification area to behave according to the version number specified in theuVersion member of the structure pointed to by lpdata. The version number specifies which members are recognized.让通知区域按照lpdata的uVersion字段标识的版本值来执行。版本号指定了哪些成员是有效的。

NIM_SETVERSION must be called every time a notification area icon is added (NIM_ADD)>. It does not need to be called with NIM_MOFIDY. The version setting is not persisted once a user logs off.每当添加通知区域的时候,NIM_SETVERSION必须添加。不必使用NIM_MODIFY。当用户登出的时候,版本设置不会持久保留。

For details, see the Remarks section.

lpdata [in]

Type: PNOTIFYICONDATA

A pointer to a NOTIFYICONDATA structure. The content of the structure depends on the value ofdwMessage. It can define an icon to add to the notification area, cause that icon to display a notification, or identify an icon to modify or delete.指向NOTIFYICONDATA结构体。这个结构体的数据取决于dwMessage的值。它可以定义一个图标、添加到通知区域并显示通知,也可以修改或删除一个图标。

Return value

Type: BOOL

Returns TRUE if successful, or FALSE otherwise. IfdwMessage is set to NIM_SETVERSION, the function returns TRUE if the version was successfully changed, orFALSE if the requested version is not supported.

Remarks

(这一段讲2000,不翻译了。)

As of Windows 2000 (Shell32.dll version 5.0), if you set theuVersion member of the NOTIFYICONDATA structure pointed to by lpdata to NOTIFYICON_VERSION_4 or higher,Shell_NotifyIcon mouse and keyboard events are handled differently than in earlier versions of Windows. The differences include the following:

  • If a user selects a notify icon's shortcut menu with the keyboard, the Shell now sends the associated application aWM_CONTEXTMENU message. Earlier versions send WM_RBUTTONDOWN and WM_RBUTTONUP messages.
  • If a user selects a notify icon with the keyboard and activates it with the SPACEBAR or ENTER key, the version 5.0 Shell sends the associated application an NIN_KEYSELECT notification. Earlier versions sendWM_RBUTTONDOWN and WM_RBUTTONUP messages.
  • If a user selects a notify icon with the mouse and activates it with the ENTER key, the Shell now sends the associated application an NIN_SELECT notification. Earlier versions sendWM_RBUTTONDOWN and WM_RBUTTONUP messages.

As of Windows XP (Shell32.dll version 6.0), if a user passes the mouse pointer over an icon with which a balloon notification is associated, the Shell sends the following messages:在XP下,如果用户的鼠标经过一个关联了气泡同志的图标,Shell会发送下面的消息:

  • NIN_BALLOONSHOW. Sent when the balloon is shown (balloons are queued).在气泡显示是发送。
  • NIN_BALLOONHIDE. Sent when the balloon disappears. For example, when the icon is deleted. This message is not sent if the balloon is dismissed because of a timeout or if the user clicks the mouse.在气泡消失时发送。例如,当删除图标的时候。当超时或者用户点击鼠标时,气泡消失的时候不会发这个消息。

    As of Windows 7, NIN_BALLOONHIDE is also sent when a notification with the NIIF_RESPECT_QUIET_TIME flag set attempts to display during quiet time (a user's first hour on a new computer). In that case, the balloon is never displayed at all.在Win7下,当使用了NIIF_RESPECT_QUIET_TIME标签的通知企图在退出的时候显示时,依旧会发送这个消息。这种情况下,气泡永远不会显示。

  • NIN_BALLOONTIMEOUT. Sent when the balloon is dismissed because of a timeout.当气泡因超时没有显示时。
  • NIN_BALLOONUSERCLICK. Sent when the balloon is dismissed because the user clicked the mouse.因为用户点击鼠标而导致气泡没有显示时。

(Vista的不翻译了)

In addition to those messages, as of Windows Vista (Shell32.dll version 6.0.6), if a user passes the mouse pointer over an icon with which a balloon notification is associated, the Windows Vista Shell also adds the following messages:

  • NIN_POPUPOPEN. Sent when the user hovers the cursor over an icon to indicate that the richer pop-up UI should be used in place of a standard textual tooltip.
  • NIN_POPUPCLOSE. Sent when a cursor no longer hovers over an icon to indicate that the rich pop-up UI should be closed.

Regardless of the operating system version, you can select which way the Shell should behave by callingShell_NotifyIcon with dwMessage set to NIM_SETVERSION. Set theuVersion member of the NOTIFYICONDATA structure pointed to by lpdata to indicate whether you want Windows 2000, Windows Vista, or pre-version 5.0 (Windows 95) behavior.无论什么系统版本,你可以通过将Shell_NotifyIcon的dwMessage设置为NIM_SETVERSION来选择。你可以通过NOTIFYICONDATA的uVersion来设置你想要的系统风格,例如2000风格、Vista风格,95风格等。

Note  The messages discussed above are not conventional Windows messages. They are sent as thelParam value of the application-defined message that is specified in theuCallbackMessage member of the NOTIFYICONDATA structure pointed to by lpdata, whenShell_NotifyIcon is called with the NIM_ADD flag set indwMessage.

As of Windows XP Service Pack 2 (SP2), a custom icon can be displayed in the notification balloon. This allows the calling process to customize the notification beyond the previously available options of info, warning, and error, and distinguish it from other types of notification for the user.

Requirements

Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Shellapi.h

Library

Shell32.lib

DLL

Shell32.dll (version 4.0 or later)

Unicode and ANSI names

Shell_NotifyIconW (Unicode) and Shell_NotifyIconA (ANSI)

See also

Notifications and the Notification Area

Shell_NotifyIcon相关推荐

  1. delphi如何让程序最小化到任务栏(使用Shell_NotifyIcon API函数)

    delphi如何让程序最小化到任务栏(使用Shell_NotifyIcon API函数) 转载于:https://www.cnblogs.com/LittleTiger/p/6519238.html

  2. c语言notify方法,【红烧小鲫鱼】关于在纯C语言中的Shell_NotifyIcon应用

    [红烧小鲫鱼]关于在纯C语言中的Shell_NotifyIcon应用 有如下代码,可以运行,但是程序会崩溃,有些地方我不会设置. 求如何设置,要用纯C语言的哦! // HELLO.cpp : Defi ...

  3. shell_notifyicon和NOTIFYICONDATA

    shell_notifyicon和NOTIFYICONDATA Shell_NotifyIcon函数,向任务栏的状态栏发送一个消息 函数原型 BOOL Shell_NotifIcon( DWORD d ...

  4. 【VS开发】最小化到托盘 shell_notifyicon和NOTIFYICONDATA

    shell_notifyicon和NOTIFYICONDATA Shell_NotifyIcon函数,向任务栏的状态栏发送一个消息 函数原型 BOOL Shell_NotifIcon( DWORD d ...

  5. linux脚本隐藏托盘,Shell_NotifyIcon实现任意托盘图标的隐藏与再现

    发TB_HIDEBUTTON消息来隐藏托盘图标并不完美,会留下一块空白 仔细看一下NOTIFYICONDATA结构,发现了dwState 如果dwStateMask为NIS_HIDDEN,则当dwSt ...

  6. MFC最小化到系统托盘

    在VC++中,想实现将MFC最小化到系统托盘,需要调用NOTIFYICONDATA类,并注册相应的消息,以下详细讲解如何实现: 第一步,声明一个NOTIFYICONDATA类,也就是NOTIFYICO ...

  7. 基于Dialog的MFC程序在启动时隐藏为托盘程序(四)

    这部分说一下如何加menu..如果做小气球.. mfc的menu确是不如C#活着java那么easy.. 首先在rc里添加menu资源..然后在ui界面里先设置一下你的菜单.. 在第(二)部分已经简单 ...

  8. MFC系统托盘的实现

    通常电脑里边的软件,当你打开后会在电脑最右下角的任务栏上生成一个系统托盘,当你点击最小化或者点击关闭按钮后,若想恢复窗口,可以左键双击或者单机这个系统图标,同时鼠标右键点击,又会有其他的菜单弹出,比如 ...

  9. 一种清除windows通知区域“僵尸”图标的方案——Windows7系统解决方案

    Windows7下"僵尸"图标的解决方案 从<一种清除windows通知区域"僵尸"图标的方案--问题分析>(以后简称<问题分析>)一文 ...

  10. 一种清除windows通知区域“僵尸”图标的方案——问题分析

    通知区域名称有趣的历史 假如说到windows通知区域,可能很多人还是不清楚它是什么.如果改称Tray区域,可能有人就懂了.如果再白话点,叫它"托盘"或者"系统托盘&qu ...

最新文章

  1. nokia 上的好玩应用(转载)
  2. Heartbeat+ipvsadm+ldirectord组建linux高可用集群
  3. 【Spark篇】---Spark中Master-HA和historyServer的搭建和应用
  4. 【水】对于算法的个人理解
  5. Android开发笔记(一百七十九)避免方法数过多的问题
  6. 验证Java编程环境是否成功时出现“'javac'不是内部或外部命令,也不是可运行的程序或批处理文件”
  7. 博文视点大讲堂第24期:PPT演示之道
  8. 浅谈单调队列优化dp
  9. 发那科机器人初始化步骤_发那科工业机器人如何进行初始化启动
  10. 桌面壁纸所放位置+魔镜壁纸的下载方法
  11. Cifar10数据集转换成jpg格式
  12. 51单片机(郭天祥版)——键盘检测原理及应用实现
  13. 企业微信一天最多可以加多少人? 企业微信加好友功能会被限制吗?
  14. 学而思python培训班
  15. 李帅燕山大学计算机,燕山大学第二十三届学生会复试结果
  16. 412:Cadence使用—— Padstack Editor焊盘设计
  17. LED技术50年秘史回顾:从指示灯到街灯
  18. 如何破坏Excel文件,让其显示文件已损坏方法
  19. 简单有趣,半小时漫画中国史
  20. 音视频开发中常见基础问题总结

热门文章

  1. 「AI」一文看懂“声纹识别VPR”
  2. 关于wireshark安装npcap不成功的问题
  3. 第一章 信息化与信息系统习题
  4. movielens数据集简述
  5. 数字人轻松学习Blender系列之八:建模-1
  6. mappedby 详解
  7. 视频编码格式 封装格式
  8. 如何将Oracle卸载干净
  9. lldp协议代码阅读_查看链路层发现协议(LLDP)关于交换机的端口状态信息
  10. 服务器系统 usb不识别u盘,无法识别的usb设备怎么办(实测成功解决U盘修复教程)...