Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Windows Taskbar Wrapper Class - C#

RSS
Modified on Tue, Apr 24, 2012, 12:01 PM by Administrator Categorized as Windows API, ·Net Framework
using System.Runtime.InteropServices;

public static class Taskbar
{
    [DllImport("user32.dll")]
    private static extern int FindWindow(string className, string windowText);
    [DllImport("user32.dll")]
    private static extern int ShowWindow(int hwnd, int command);

    private const int SW_HIDE = 0;
    private const int SW_SHOW = 1;

    private static int _taskbarHandle;
    private static int _startButtonHandle;

    static Taskbar()
    {
        _taskbarHandle = FindWindow("Shell_TrayWnd", "");
        _startButtonHandle = FindWindow("Button", "Start");
    }

    public static void Show()
    {
        ShowWindow(_taskbarHandle, SW_SHOW);
        ShowWindow(_startButtonHandle, SW_SHOW);
    }

    public static void Hide()
    {
        ShowWindow(_taskbarHandle, SW_HIDE);
        ShowWindow(_startButtonHandle, SW_HIDE);
    }
}

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.