Search This Blog

15 February, 2010

Hide and Show TaskBar

Make this file as separate HandleTaskBar.cs and call the public method

using System;
using System.Runtime.InteropServices;

namespace FullScreenMode
{
internal class HandleTaskBar
{
private const int SWP_HIDEWINDOW = 0x0080;
private const int SWP_SHOWWINDOW = 0x0040;

public HandleTaskBar()
{
}

[DllImport("User32.dll", EntryPoint="FindWindow")]
private static extern int FindWindow(string lpClassName, string lpWindowName);

[DllImport("User32.dll")]
private static extern int SetWindowPos(int hWnd, int hWndInsertAfter, int x, int y, int cx, int cy, int wFlags);

public static void showTaskBar()
{
int hWnd = FindWindow("Shell_TrayWnd", "");
SetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_SHOWWINDOW);
}

public static void hideTaskBar()
{
int hWnd = FindWindow("Shell_TrayWnd", "");
SetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_HIDEWINDOW);
}
}
}

No comments:

Post a Comment