Reputation: 2437
Is there any possibility to refresh the Taskbar in Windows-CE by C#?
In my software I kill some processes by OpenNETCF.ToolHelp.ProcessEntry.Kill()
. This works fine, the Icon is removed from the taskbar, but the space for the icon is still left. After some tests I killed about 20 processes, and now it pushed out the start-button from the taskbar.
The empty space is removed by clicking on it.
How can I refresh the taskbar from my C#-program?
EDIT: I'm currently working on Windows-CE 4.2.
Upvotes: 1
Views: 580
Reputation: 6587
Based on the suggestion by Damon8or
, here is sample code that does what you need:
[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));
}
}
Hope that helps.
Upvotes: 1
Reputation: 527
Try to get the handle to the taskbar window P/Invoking FindWindow, look for "HHTaskBar" as class name. Then invalidate the window.
Upvotes: 1