Shell_notifyicon& NOTIFYICONDATA [英] Shell_notifyicon & NOTIFYICONDATA
问题描述
我们正在尝试将Shell_NotifyIcon与NOTIFYICONDATA结构一起使用。在Window 10上,我们看到如果我们尝试显示气球通知区域以及Title ICON,ICON会在每次显示时复制到temp文件夹。有可能避免这种情况吗?我们有一些用例,因为我们不希望在显示通知时触发任何文件复制操作。
我们尝试的示例代码如下:
We are trying to use Shell_NotifyIcon along with NOTIFYICONDATA structure. On Window 10, We are seeing that if we try to display the balloon notification area along with Title ICON , the ICON gets copied to temp folder everytime it is displayed. It is possible to avoid this ? We have certain use case due to which we do not want any file copy operation triggered while displaying the notifications.
Sample code we tried is as follows:
void CTrayIconTestDlg::AddIconToSysTray()
{
HICON m_hIconInfo = NULL;//(HICON)::LoadImage(), MAKEINTRESOURCE(IDI_ICON_INFO), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR | LR_LOADTRANSPARENT);
// TODO: Add your control notification handler code here
NOTIFYICONDATA NID;
memset(&NID, 0, sizeof(NID));
//on main function:
NID.cbSize = sizeof(NID);
NID.hIcon = this->m_hIcon;
NID.hWnd = this->m_hWnd;
NID.uID = WM_USER + 2;
StrCpyW(NID.szTip, L"System Tray Icon: Hello World");
//in a timer:
NID.uFlags = NID.uFlags | NIF_ICON | NIF_TIP ;
Shell_NotifyIcon(NIM_ADD, &NID);
//CDialogEx::OnOK();
}
void CTrayIconTestDlg::DisplayNotification()
{
// TODO: Add your control notification handler code here
NOTIFYICONDATA NID;
memset(&NID, 0, sizeof(NID));
//on main function:
NID.cbSize = sizeof(NID);
NID.hIcon = this->m_hIcon;
NID.hWnd = this->m_hWnd;
NID.uID = WM_USER + 2;
StrCpyW(NID.szTip, L"System Tray Icon: Hello World");
//in a timer:
NID.uFlags = NID.uFlags | NIF_ICON | NIF_INFO | NIF_TIP ;
StrCpyW(NID.szInfoTitle, L"This is balloon title");
StrCpyW(NID.szInfo, L"This is balloon Information detailed");
NID.uTimeout = 5000;
NID.dwInfoFlags = NID.dwInfoFlags | NIIF_INFO;
//NID.dwInfoFlags = NID.dwInfoFlags | NIIF_USER;
//NID.hBalloonIcon = this->m_hIcon;
BOOL res = Shell_NotifyIcon(NIM_MODIFY, &NID);
if( res == FALSE )
MessageBoxA(NULL, "False", "", MB_OK);
}
我的尝试:
1)MSDN文档
2)在Windows 7上尝试相同的代码,它不会将ICON复制到临时文件夹
What I have tried:
1) MSDN documentation
2) Tried same code on Windows 7, it does not copy the ICON to temp folder
推荐答案
在Windows 10上无法避免这种情况。如果您使用其中一种产品接受错误报告,可能需要提交错误信息:
[ Microsoft Connect ]
准备好将你的bug关闭为按设计。
你也可以使用反馈中心 [ ^ ]提交有关此功能的反馈。
祝福,
-David Delaune
Hi,
It is not possible to avoid this on Windows 10. You may want to file a bug if you are using one of these products accepting bug reports:
[Microsoft Connect]
Be prepared for your bug to be closed as "By Design".
You can also use the Feedback Hub[^] to submit feedback about this feature.
Best Wishes,
-David Delaune
这篇关于Shell_notifyicon& NOTIFYICONDATA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!