/// <summary>
        /// Gets the current Taskbar state
        /// </summary>
        /// <returns>current Taskbar state</returns>
        public static AppBarStates GetTaskbarState()
        {
            Appbardata msgData = new Appbardata();

            msgData.cbSize = Marshal.SizeOf(msgData);
            msgData.hWnd   = FindWindow("System_TrayWnd", null);
            return((AppBarStates)SHAppBarMessage((UInt32)AppBarMessages.GetState, ref msgData));
        }
        /// <summary>
        /// Set the Taskbar State option
        /// </summary>
        /// <param name="option">AppBarState to activate</param>
        public static void SetTaskbarState(AppBarStates option)
        {
            Appbardata msgData = new Appbardata();

            msgData.cbSize = Marshal.SizeOf(msgData);
            msgData.hWnd   = FindWindow("System_TrayWnd", null);
            msgData.lParam = (int)option;
            SHAppBarMessage((UInt32)AppBarMessages.SetState, ref msgData);
        }
        private static Minmaxinfo AdjustWorkingAreaForAutoHide(IntPtr monitor, Minmaxinfo mmi)
        {
            var hwnd = NativeMethods.FindWindow("Shell_TrayWnd", null);
            var monitorWithTaskBar = NativeMethods.MonitorFromWindow(hwnd, MonitorDefaulttonearest);

            if (!monitor.Equals(monitorWithTaskBar))
            {
                return(mmi);
            }
            var abd = new Appbardata();

            abd.cbSize = Marshal.SizeOf(abd);
            abd.hWnd   = hwnd;
            NativeMethods.SHAppBarMessage((int)AbMsg.AbmGettaskbarpos, ref abd);
            var uEdge    = GetEdge(abd.rc);
            var autoHide = Convert.ToBoolean(NativeMethods.SHAppBarMessage((int)AbMsg.AbmGetstate, ref abd));

            if (!autoHide)
            {
                return(mmi);
            }

            switch (uEdge)
            {
            case (int)AbEdge.AbeLeft:
                mmi.ptMaxPosition.X  += 2;
                mmi.ptMaxTrackSize.X -= 2;
                mmi.ptMaxSize.X      -= 2;
                break;

            case (int)AbEdge.AbeRight:
                mmi.ptMaxSize.X      -= 2;
                mmi.ptMaxTrackSize.X -= 2;
                break;

            case (int)AbEdge.AbeTop:
                mmi.ptMaxPosition.Y  += 2;
                mmi.ptMaxTrackSize.Y -= 2;
                mmi.ptMaxSize.Y      -= 2;
                break;

            case (int)AbEdge.AbeBottom:
                mmi.ptMaxSize.Y      -= 2;
                mmi.ptMaxTrackSize.Y -= 2;
                break;

            default:
                return(mmi);
            }
            return(mmi);
        }
Beispiel #4
0
        private void RegisterBar(bool register)
        {
            var abd = new Appbardata();

            abd.cbSize = Marshal.SizeOf(abd);
            abd.hWnd   = new WindowInteropHelper(this).Handle;

            if (register)
            {
                _appBarId            = RegisterWindowMessage("AppBarMessage");
                abd.uCallbackMessage = _appBarId;

                SHAppBarMessage((int)AbMsg.AbmNew, ref abd);
            }
            else
            {
                SHAppBarMessage((int)AbMsg.AbmRemove, ref abd);
            }
        }
Beispiel #5
0
        private void GetPosition(string strClassName, string strWindowName)
        {
            _mData        = new Appbardata();
            _mData.cbSize = (UInt32)Marshal.SizeOf(_mData.GetType());
            IntPtr hWnd = FindWindow(strClassName, strWindowName);

            if (hWnd != IntPtr.Zero)
            {
                UInt32 uResult = SHAppBarMessage(AbmGettaskbarpos, ref _mData);
                if (uResult != 1)
                {
                    throw new Exception("Failed to communicate with the given AppBar");
                }
            }
            else
            {
                throw new Exception("Failed to find an AppBar that matched the given criteria");
            }
        }
Beispiel #6
0
 internal static extern int SHAppBarMessage(int dwMessage, ref Appbardata pData);
 public static extern uint SHAppBarMessage(int dwMessage, ref Appbardata pData);
 private static extern UInt32 SHAppBarMessage(UInt32 dwMessage, ref Appbardata pData);
Beispiel #9
0
 public static extern uint SHAppBarMessage( int dwMessage, ref Appbardata pData );