Win7 Taskbar AutoHide not toggling

FClas

New member
Joined
Jun 18, 2019
Messages
1
Programming Experience
10+
I am trying to use some code found -- It switches from AutoHide (1) to Show (0), but cannot AutoHide (1) again: 0-value does not change.
Would appreciate help why SHAppBarMessage only responds one-way...

Setting Taskbar State:
public void SetTaskbarState(AppBarStates option)
        {
            APPBARDATA msgData = new APPBARDATA();
            msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);
            msgData.hWnd = FindWindow("System_TrayWnd", null);
            msgData.lParam = (Int32)(option);
            SHAppBarMessage((UInt32)AppBarMessages.SetState, ref msgData);
        }

Thanks!
 
What is appbardata and why do you want to hide the taskbar?

Post the relative code so we can see how its intended function is constructed. Or you can use this tested and kinda working. Source :: how to hide the task bar in c# ???? ::
C#:
        private const int SWP_HIDEWINDOW = 0x80;
        private const int SWP_SHOWWINDOW = 0x40;
        [DllImport("user32.dll")]

        public static extern bool SetWindowPos(

        int hWnd,                 //   handle to window   
        int hWndInsertAfter,  //   placement-order handle   
        short X,                  //   horizontal position   
        short Y,                  //   vertical position   
        short cx,                 //   width   
        short cy,                //    height   
        uint uFlags             //    window-positioning options   
        );
        [DllImport("user32.dll")]
        public static extern int FindWindow(string lpClassName, /* class name */ string lpWindowName /* window name */ );
        bool hidden = false;
        private void Click()
        {
            int TaskBarHwnd;
            TaskBarHwnd = FindWindow("Shell_traywnd", "");
            if (hidden == false)
            {
                SetWindowPos(TaskBarHwnd, 0, 0, 0, 0, 0, SWP_HIDEWINDOW);
                hidden = true;
            }
            else
            {
                SetWindowPos(TaskBarHwnd, 0, 0, 0, 0, 0, SWP_SHOWWINDOW);
                hidden = false;
            }
        }
 
Back
Top Bottom