windows 7 Shell_NotifyIcon 使用的问题
来源:互联网 发布:知乎药丸 编辑:程序博客网 时间:2024/06/07 13:01
在windows 7上,Visual Studio 2012,只想做一个ballon提示,从网上各种百度,效果都不会,最终微软sdk的example找到了完整的例子。
使用的工程是vs2005 升级到2012的,重定义宏,不然会有些定义不了
#ifdef NTDDI_VERSION
#undef NTDDI_VERSION
#endif
#define NTDDI_VERSION NTDDI_WIN7
剩下的就简单了
bool add_notification_icon();
bool del_notification_icon();
bool show_balloon_notification_icon(CString title, CString str);
开始的时候在程序内部缓存了结构,但是都没有成功,不知道为什么。sdk的例子都是在栈上分配出来的。
class __declspec(uuid("9D0B8B92-4E1C-488e-A1E1-2331AFCE2CB5")) quectel_guid;
bool CConnectionManagerDlg::add_notification_icon()
{
BOOL bRet;
DWORD dwError;
NOTIFYICONDATA nid = {sizeof(nid)};
nid.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE | NIF_GUID;
nid.guidItem = __uuidof(quectel_guid);
nid.uCallbackMessage = WM_TASKBAR_EVENT;
nid.hIcon = AfxGetApp()->LoadIcon(MAKEINTRESOURCE(IDI_BAR));
nid.hWnd = m_hWnd;
_tcscpy(nid.szTip, L"hello world");
bRet = Shell_NotifyIcon(NIM_ADD, &nid);
dwError = GetLastError();
nid.uVersion = NOTIFYICON_VERSION_4;
return bRet = Shell_NotifyIcon(NIM_SETVERSION, &nid);
}
bool CConnectionManagerDlg::show_balloon_notification_icon(CString title, CString msg)
{
NOTIFYICONDATA nid = {sizeof(nid)};
nid.uFlags = NIF_INFO | NIF_GUID;
nid.guidItem = __uuidof(quectel_guid);
// respect quiet time since this balloon did not come from a direct user action.
nid.dwInfoFlags = NIIF_WARNING | NIIF_RESPECT_QUIET_TIME;
//LoadString(g_hInst, IDS_LOWINK_TITLE, nid.szInfoTitle, ARRAYSIZE(nid.szInfoTitle));
//LoadString(g_hInst, IDS_LOWINK_TEXT, nid.szInfo, ARRAYSIZE(nid.szInfo));
_tcscpy(nid.szInfoTitle, title);
_tcscpy(nid.szInfo, msg);
return Shell_NotifyIcon(NIM_MODIFY, &nid);
}
bool CConnectionManagerDlg::del_notification_icon()
{
NOTIFYICONDATA nid = {sizeof(nid)};
nid.uFlags = NIF_GUID;
nid.guidItem = __uuidof(quectel_guid);
return Shell_NotifyIcon(NIM_DELETE, &nid);
}
剩下的就是用按钮测试一下吧,本地测试效果还行。
- windows 7 Shell_NotifyIcon 使用的问题
- windows下的托盘编程(Shell_NotifyIcon)
- windows下的托盘编程(Shell_NotifyIcon)
- Shell_NotifyIcon(NIM_MODIFY ,&nid)失败的问题
- Shell_NotifyIcon后tray退出的问题
- Shell_NotifyIcon 修改托盘图标失败的问题
- Windows 7删除任务栏Shell_NotifyIcon添加过的垃圾图标显示配置信息
- Windows TrayIcon (Shell_NotifyIcon)
- Shell_NotifyIcon
- Shell_NotifyIcon
- Shell_NotifyIcon
- Shell_NotifyIcon
- 系统托盘Shell_NotifyIcon函数的简单运用
- 《Windows API巡礼》のShell_NotifyIcon函数和NOTIFYICONDATA结构
- windows程序托盘图标以及消息提示--基本知识(Shell_NotifyIcon)
- Shell_NotifyIcon - Handling Shell_NotifyIcon failure
- 使用Shell_NotifyIcon 建一个标准气泡通知盒图标
- 使用Shell_NotifyIcon 建一个标准气泡通知盒图标
- AndroidStudio怎样导入library项目开源库
- linux用户&群组&权限
- Android Intent和Intent构造器
- Gulp开发教程(翻译)
- 简单DP HDOJ 1003 MAX SUM
- windows 7 Shell_NotifyIcon 使用的问题
- 安卓中控件跟随手指移动
- UIViewController view视图的加载
- unity3d : Failed to query D3D11 context for ID3DUserDefinedAnnotation interface (hr = 0x80004002)
- Android快速实现微信支付
- java 字符串匹配 删除 img 的width height属性
- css注意事项03
- hdu 2588(欧拉函数)
- oracle回滚机制深入研究