【问题标题】:Refresh Windows CE - Taskbar刷新 Windows CE - 任务栏
【发布时间】:2011-12-20 08:57:26
【问题描述】:

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

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

空白区域通过点击被移除。

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

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

【问题讨论】:

  • 您试图以错误的方式解决问题。为什么你首先要杀死所有这些进程?
  • 我正在通过 rasmanager 断开我的 gprs 连接,但进程仍在运行,尽管没有任何连接。所以我必须杀死 rnaapp 进程才能关闭窗口这工作正常,但图标的空间不会被删除

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


【解决方案1】:

尝试获取任务栏窗口的句柄 P/Invoking FindWindow,查找“HHTaskBar”作为类名。然后使窗口无效。

【讨论】:

    【解决方案2】:

    根据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));
        }
    }
    

    希望对您有所帮助。

    【讨论】:

    • 谢谢,我希望这对其他人有帮助!但由于这个问题是从 2011 年开始的,所以我不再需要答案了 :)
    猜你喜欢
    • 2011-01-09
    • 1970-01-01
    • 1970-01-01
    • 2011-03-24
    • 1970-01-01
    • 1970-01-01
    • 2010-12-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多