刷新Windows CE - 任务栏

时间:2011-12-20 08:57:26

标签: c# refresh c#-2.0 windows-ce

是否有可能通过C#刷新Windows CE中的任务栏?

在我的软件中,我通过OpenNETCF.ToolHelp.ProcessEntry.Kill()杀死了一些进程 这工作正常,图标从任务栏中删除,但图标的空间仍然保留。经过一些测试后,我杀死了大约20个进程,现在它从任务栏中推出了启动按钮。

通过单击删除空白区域。

如何从C#程序中刷新任务栏?

编辑:我目前正在研究CE 4.2

2 个答案:

答案 0 :(得分:1)

尝试获取任务栏窗口的句柄P /调用FindWindow,查找" HHTaskBar"作为班级名称。然后使窗口无效。

答案 1 :(得分:0)

根据Damon8or的建议,以下示例代码可以满足您的需求:

[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));
    }
}

希望有所帮助。