2011-12-20 60 views
1

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

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

通过单击它可以删除空白区域。

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

编辑:我目前正在CE 4.2

+0

您试图以错误的方式解决问题。为什么你首先要杀死所有这些进程? – 2011-12-20 09:00:58

+0

我正在通过rasmanager断开我的gprs连接,但该进程仍在运行,尽管没有任何连接。 所以我必须杀死rnaapp进程关闭窗口 这工作正常,但图标的空间不会被删除 – Karl 2011-12-20 09:02:10

回答

1

尝试获取句柄到任务栏窗口P /调用FindWindow函数,寻找“HHTaskBar”作为类名称。然后使窗口无效。

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

希望有所帮助。

+0

谢谢,我希望这可以帮助别人! 但由于这个问题是从2011年,我不需要一个答案了:) – Karl 2017-06-06 14:46:32