How can I hide the Windows CE Taskbar through managed code?
Below is code in both C# and VB.NET for hiding the Taskbar.
Keep in mind that once you run the code the taskbar will still be "visible" until your application does something to paint over it, as the desktop window does not cover this area.
If your goal is to prevent users from accessing the Windows CE system itself, you might also consider removing the CE Desktop altogether.
For the unmanaged version of this code, see Topic 39
C#using System.Runtime.InteropServices;
[DllImport("coredll.dll", EntryPoint="FindWindowW", SetLastError=true)] private static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport("coredll.dll", EntryPoint="ShowWindow", SetLastError=true)] private static int ShowWindow(IntPtr hwnd, int nCmdShow);
[DllImport("coredll.dll", EntryPoint="EnableWindow", SetLastError=true)] private static int EnableWindow(IntPtr hwnd, int bEnable);
public void HideTaskBar() { private const int SW_HIDE = 0;
IntPtr hTaskBar = FindWindow("HHTaskBar", null); if(hTaskBar != IntPtr.Zero) { EnableWindow(hTaskBar, 0); ShowWindow(hTaskBar, SW_HIDE); } }
VB.NETImports System.Runtime.InteropServices
_ Public Function FindWindow(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr End Function
_ Public Function ShowWindow(ByVal hWnd As IntPtr, ByVal nCmdShow As Integer) As Integer End Function
_ Public Function EnableWindow(ByVal hWnd As IntPtr, ByVal bEnable As Integer) As Integer End Function
Public Sub HideTaskBar() Const SW_HIDE As Integer = 0 Dim hTaskBar As IntPtr hTaskBar = FindWindow("HHTaskBar", Nothing) If hTaskBar.ToInt32 <> 0 Then EnableWindow(hTaskBar, 0) ShowWindow(hTaskBar, SW_HIDE) End If End Sub
|