Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
Hi everyone,

C#
private static void SetVisibility(bool show)
        {
            // get taskbar window
            IntPtr taskBarWnd = FindWindow("Shell_TrayWnd", null);

            // try it the WinXP way first...
            IntPtr startWnd = FindWindowEx(taskBarWnd, IntPtr.Zero, "Button", "Start");
            if (startWnd == IntPtr.Zero)
            {
                // ok, let's try the Vista easy way...
                startWnd = FindWindow("Button", null);

                if (startWnd == IntPtr.Zero)
                {
                    // no chance, we need to to it the hard way...
                    startWnd = GetVistaStartMenuWnd(taskBarWnd);
                }
            }

            ShowWindow(taskBarWnd, show ? SW_SHOW : SW_HIDE);
            ShowWindow(startWnd, show ? SW_SHOW : SW_HIDE);
        }


With that function, I can hide Taskbar, but it isn't showing again.
For Hide Taskbar I'm using Form DeActive Event, and for Show Taskbar I'm using Form_Closing Event. But it is not work..

What is the problem? How can I solve?

Thanks for answers, have a good day...
Posted

1 solution

Long time I used .net Forms, but as I remember there was an built in option to show/hide windown in taskbar somethink like: this.ShowInTaskbar = false;

As you already got into WinAPI for doing that. I strongly suggest to double think and research if it's needed. If you still think winapi is the best approach, read this: https://msdn.microsoft.com/en-us/library/windows/desktop/ff700543(v=vs.85).aspx[^] you somethink like this should do the trick:
C#
SetWindowLong(handle, GWL_EXSTYLE, GetWindowLong(handle, GWL_EXSTYLE) | WS_EX_APPWINDOW);

SetWindowLong(handle, GWL_EXSTYLE, GetWindowLong(handle, GWL_EXSTYLE) & ~WS_EX_APPWINDOW);

The idea is to get the current window style and add or remove flags you want (also read about bitwise operations and how adding/removing flags works).
 
Share this answer
 
Comments
Umut Comlekcioglu 30-Aug-15 9:33am    
Thanks for answer but I wanna hide Taskbar, not Form. You remember right. For hide form in taskbar, we just use "ShownInTaskbar" properties.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900