How to programmatically display the Windows taskbar using C#

Thad T 26 Reputation points
2024-05-16T13:35:04.7966667+00:00

I would like to know what C# code/instructions are necessary to make the Windows taskbar appear so that I can use a specific item on it. Can someone provide a concise example or resource to help me accomplish this? Thank you.

Windows Forms
Windows Forms
A set of .NET Framework managed libraries for developing graphical user interfaces.
1,858 questions
Windows 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,862 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,722 questions
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,455 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,417 questions
{count} votes

Accepted answer
  1. Castorix31 82,206 Reputation points
    2024-05-16T15:33:32.97+00:00

    On Windows 10, this test shows the Taskbar when it is hidden (AutoHide)

                IntPtr hWndTray = FindWindow("Shell_TrayWnd", null);
                SetWindowPos(hWndTray, IntPtr.Zero, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED | SWP_SHOWWINDOW);
    
    
      with :
    
            [DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
            public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
    
            [DllImport("User32.dll", SetLastError = true, CharSet = CharSet.Auto)]
            public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
    
            public const int SWP_NOSIZE = 0x0001;
            public const int SWP_NOMOVE = 0x0002;
            public const int SWP_NOZORDER = 0x0004;
            public const int SWP_NOREDRAW = 0x0008;
            public const int SWP_NOACTIVATE = 0x0010;
            public const int SWP_FRAMECHANGED = 0x0020;  /* The frame changed: send WM_NCCALCSIZE */
            public const int SWP_SHOWWINDOW = 0x0040;
            public const int SWP_HIDEWINDOW = 0x0080;
            public const int SWP_NOCOPYBITS = 0x0100;
            public const int SWP_NOOWNERZORDER = 0x0200;  /* Don't do owner Z ordering */
            public const int SWP_NOSENDCHANGING = 0x0400;  /* Don't send WM_WINDOWPOSCHANGING */
            public const int SWP_DRAWFRAME = SWP_FRAMECHANGED;
            public const int SWP_NOREPOSITION = SWP_NOOWNERZORDER;
            public const int SWP_DEFERERASE = 0x2000;
            public const int SWP_ASYNCWINDOWPOS = 0x4000;
    
    
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful