刷新通知区域中的图标 (Windows CE)
Refresh icons in notification area (Windows CE)
网络搜索找到几篇带有示例代码的文章,这些文章展示了当应用程序被终止时如何清除 Windows 托盘通知区域中遗留的杂散图标(例如,被 Task Manager
或更新程序应用程序终止) .例如 this CodeProject example or this blog post.
以上两个示例都使用了类似的技术,据报道可以在 Windows XP、7、8.1 和 10 上运行。
但是如何让他们使用 .NET Compact Framework 在 Windows CE 上工作?一个问题是 FindWindowEx
是必需的...但在 coredll.dll
.
中不可用
根据问题中链接的问题,我终于找到了一个有效的解决方案。我希望这对将来在 Windows CE / Mobile 上遇到类似问题的其他人有所帮助。
[DllImport("coredll.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("coredll.dll")]
public static extern IntPtr SendMessage(IntPtr hWnd, int nMsg, IntPtr wParam, IntPtr lParam);
private const int WM_MOUSEMOVE = 0x0200;
public static void RefreshTrayArea()
{
// The client rectangle can be determined using "GetClientRect" (from coredll.dll) but
// does require the taskbar to be visible. The values used in the loop below were
// determined empirically.
IntPtr hTrayWnd = FindWindow("HHTaskBar", null);
if (hTrayWnd != IntPtr.Zero)
{
int nStartX = (Screen.PrimaryScreen.Bounds.Width / 2);
int nStopX = Screen.PrimaryScreen.Bounds.Width;
int nStartY = 0;
int nStopY = 26; // From experimentation...
for (int nX = nStartX; nX < nStopX; nX += 10)
for (int nY = nStartY; nY < nStopY; nY += 5)
SendMessage(hTrayWnd,
WM_MOUSEMOVE, IntPtr.Zero, (IntPtr)((nY << 16) + nX));
}
}
网络搜索找到几篇带有示例代码的文章,这些文章展示了当应用程序被终止时如何清除 Windows 托盘通知区域中遗留的杂散图标(例如,被 Task Manager
或更新程序应用程序终止) .例如 this CodeProject example or this blog post.
以上两个示例都使用了类似的技术,据报道可以在 Windows XP、7、8.1 和 10 上运行。
但是如何让他们使用 .NET Compact Framework 在 Windows CE 上工作?一个问题是 FindWindowEx
是必需的...但在 coredll.dll
.
根据问题中链接的问题,我终于找到了一个有效的解决方案。我希望这对将来在 Windows CE / Mobile 上遇到类似问题的其他人有所帮助。
[DllImport("coredll.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("coredll.dll")]
public static extern IntPtr SendMessage(IntPtr hWnd, int nMsg, IntPtr wParam, IntPtr lParam);
private const int WM_MOUSEMOVE = 0x0200;
public static void RefreshTrayArea()
{
// The client rectangle can be determined using "GetClientRect" (from coredll.dll) but
// does require the taskbar to be visible. The values used in the loop below were
// determined empirically.
IntPtr hTrayWnd = FindWindow("HHTaskBar", null);
if (hTrayWnd != IntPtr.Zero)
{
int nStartX = (Screen.PrimaryScreen.Bounds.Width / 2);
int nStopX = Screen.PrimaryScreen.Bounds.Width;
int nStartY = 0;
int nStopY = 26; // From experimentation...
for (int nX = nStartX; nX < nStopX; nX += 10)
for (int nY = nStartY; nY < nStopY; nY += 5)
SendMessage(hTrayWnd,
WM_MOUSEMOVE, IntPtr.Zero, (IntPtr)((nY << 16) + nX));
}
}