Exemplo n.º 1
0
 /// <summary>
 /// Gets the current Taskbar state
 /// </summary>
 /// <returns>current Taskbar state</returns>
 public AppBarStates GetTaskbarState()
 {
     APPBARDATA msgData = new APPBARDATA();
     msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);
     msgData.hWnd = FindWindow("System_TrayWnd", null);
     return (AppBarStates)SHAppBarMessage((UInt32)AppBarMessages.GetState, ref msgData);
 }
Exemplo n.º 2
0
			public Taskbar(bool secondary)
			{
				Handle = User32.FindWindow(!secondary ? ClassName : SecondaryClassName, null);

				if (Handle == IntPtr.Zero)
					return;

				var data = new APPBARDATA { cbSize = (uint)Marshal.SizeOf(typeof(APPBARDATA)), hWnd = Handle };
				IntPtr result = Shell32.SHAppBarMessage(ABM.GetTaskbarPos, ref data);

				if (result == IntPtr.Zero)
					throw new InvalidOperationException();

				Position = (TaskbarPosition)data.uEdge;
				Bounds = Rectangle.FromLTRB(data.rc.left, data.rc.top, data.rc.right, data.rc.bottom);

				data.cbSize = (uint)Marshal.SizeOf(typeof(APPBARDATA));
				result = Shell32.SHAppBarMessage(ABM.GetState, ref data);
				int state = result.ToInt32();
				AlwaysOnTop = (state & ABS.AlwaysOnTop) == ABS.AlwaysOnTop;
				AutoHide = (state & ABS.Autohide) == ABS.Autohide;

				var lpRect = new RECT();
				User32.GetWindowRect(Handle, ref lpRect);
				VisibleBounds = Rectangle.FromLTRB(lpRect.left, lpRect.top, lpRect.right, lpRect.bottom);

				/*Debug.WriteLine(this.Bounds);
                Debug.WriteLine(lpRect.top + "-------------------");*/
			}
Exemplo n.º 3
0
        public static void SetAppBar(Window appbarWindow, ABEdge edge)
        {
            RegisterInfo info = GetRegisterInfo(appbarWindow);
            info.Edge = edge;

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

            if (edge == ABEdge.None) {
                if (info.IsRegistered) {
                    SHAppBarMessage((int)ABMsg.ABM_REMOVE, ref abd);
                    info.IsRegistered = false;
                }
                RestoreWindow(appbarWindow);
                return;
            }

            if (!info.IsRegistered) {
                info.IsRegistered = true;
                info.CallbackId = RegisterWindowMessage("AppBarMessage");
                abd.uCallbackMessage = info.CallbackId;

                uint ret = SHAppBarMessage((int)ABMsg.ABM_NEW, ref abd);

                HwndSource source = HwndSource.FromHwnd(abd.hWnd);
                source.AddHook(new HwndSourceHook(info.WndProc));
            }

            appbarWindow.WindowStyle = WindowStyle.None;
            appbarWindow.ResizeMode = ResizeMode.NoResize;
            appbarWindow.Topmost = true;

            ABSetPos(info.Edge, appbarWindow);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns information for the Windows taskbar (type, location, size)
        /// </summary>
        public static Rectangle GetTaskbar(out AppBarLocation location)
        {
            var data = new APPBARDATA();
            var res = SHAppBarMessage(ABM_GETTASKBARPOS, ref data);

            location = data.uEdge;
            return Rectangle.FromLTRB(data.rc.left, data.rc.top, data.rc.right, data.rc.bottom);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Set the Taskbar State option
 /// </summary>
 /// <param name="option">AppBarState to activate</param>
 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);
 }
Exemplo n.º 6
0
        public static void GetTaskBarInfo(out AppBarEdge taskBarEdge, out Rectangle region)
        {
            APPBARDATA appData = new APPBARDATA();

            uint ret = SHAppBarMessage(AppBarMessage.GetTaskBarPos, ref appData);

            taskBarEdge = appData.uEdge;
            region = appData.rc.ToRectangle();
        }
Exemplo n.º 7
0
        public static int GetScreenHeight(Window appbarWindow)
        {
            APPBARDATA barData = new APPBARDATA();
            barData.cbSize = Marshal.SizeOf(barData);
            barData.hWnd = new WindowInteropHelper(appbarWindow).Handle;

            SHAppBarMessage((int)ABMsg.ABM_GETTASKBARPOS, ref barData);

            return barData.rc.top;
        }
Exemplo n.º 8
0
        public static void ABSetPos(Window appbarWindow, ABEdge edge)
        {
            APPBARDATA barData = new APPBARDATA();
            barData.cbSize = Marshal.SizeOf(barData);
            barData.hWnd = new WindowInteropHelper(appbarWindow).Handle;
            barData.uEdge = (int)edge;

            int leftOffset = 0;
            int topOffset = 0;
            int actualScreenWidth = (int)SystemParameters.PrimaryScreenWidth;
            int actualScreenHeight = (int)SystemParameters.PrimaryScreenHeight;

            GetActualScreenData(edge, appbarWindow, ref leftOffset, ref topOffset, ref actualScreenWidth, ref actualScreenHeight);

            if (barData.uEdge == (int)ABEdge.Left || barData.uEdge == (int)ABEdge.Right)
            {
                barData.rc.top = topOffset;
                barData.rc.bottom = actualScreenHeight;
                if (barData.uEdge == (int)ABEdge.Left)
                {
                    barData.rc.left = leftOffset;
                    barData.rc.right = (int)Math.Round(appbarWindow.ActualWidth) + leftOffset;
                }
                else
                {
                    barData.rc.right = actualScreenWidth + leftOffset;
                    barData.rc.left = barData.rc.right - (int)Math.Round(appbarWindow.ActualWidth);
                }
            }
            else
            {
                barData.rc.left = leftOffset;
                barData.rc.right = actualScreenWidth + leftOffset;
                if (barData.uEdge == (int)ABEdge.Top)
                {
                    barData.rc.top = topOffset;
                    barData.rc.bottom = (int)Math.Round(appbarWindow.ActualHeight) + topOffset;
                }
                else
                {
                    barData.rc.bottom = actualScreenHeight + topOffset;
                    barData.rc.top = barData.rc.bottom - (int)Math.Round(appbarWindow.ActualHeight);
                }
            }

            SHAppBarMessage((int)ABMsg.ABM_QUERYPOS, ref barData);
            SHAppBarMessage((int)ABMsg.ABM_SETPOS, ref barData);

            Rect rect = new Rect((double)barData.rc.left, (double)barData.rc.top,
                (double)(barData.rc.right - barData.rc.left), (double)(barData.rc.bottom - barData.rc.top));
            //This is done async, because WPF will send a resize after a new appbar is added.
            //if we size right away, WPFs resize comes last and overrides us.
            appbarWindow.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle,
                new ResizeDelegate(DoResize), appbarWindow, rect);
        }
Exemplo n.º 9
0
        static void show()
        {
            // タスクバーを常に表示
            APPBARDATA abd = new APPBARDATA();
            abd.cbSize = Marshal.SizeOf(abd);
            abd.lParam = ABS_ALWAYSONTOP;
            SHAppBarMessage(ABM_SETSTATE, ref abd);

            // タスクバーを表示
            ShowWindow(FindWindow("Shell_TrayWnd", IntPtr.Zero), SW_NORMAL);
        }
Exemplo n.º 10
0
        private static TaskbarPosition GetTaskbarPosition(out Rectangle bounds)
        {
            var taskbarHandle = FindWindow("Shell_TrayWnd", null);

            var data = new APPBARDATA { cbSize = (uint)Marshal.SizeOf(typeof(APPBARDATA)), hWnd = taskbarHandle };
            var result = SHAppBarMessage(ABM.GetTaskbarPos, ref data);
            if (result == IntPtr.Zero)
                throw new InvalidOperationException();

            bounds = Rectangle.FromLTRB(data.rc.left, data.rc.top, data.rc.right, data.rc.bottom);
            return (TaskbarPosition)data.uEdge;
        }
Exemplo n.º 11
0
 public void GetPosition(string strClassName, string strWindowName)
 {
     this.m_data = new APPBARDATA();
     this.m_data.cbSize = (uint) Marshal.SizeOf(this.m_data.GetType());
     if (!(FindWindow(strClassName, strWindowName) != IntPtr.Zero))
     {
         throw new Exception("Failed to find an AppBar that matched the given criteria");
     }
     if (SHAppBarMessage(5, ref this.m_data) != 1)
     {
         throw new Exception("Failed to communicate with the given AppBar");
     }
 }
Exemplo n.º 12
0
        static void hide()
        {
            // 「タスクバーを自動的に隠す」
            APPBARDATA abd = new APPBARDATA();
            abd.cbSize = Marshal.SizeOf(abd);
            abd.lParam = ABS_AUTOHIDE;
            SHAppBarMessage(ABM_SETSTATE, ref abd);

            System.Threading.Thread.Sleep(100);

            // タスクバーを非表示
            ShowWindow(FindWindow("Shell_TrayWnd", IntPtr.Zero), SW_HIDE);
        }
Exemplo n.º 13
0
        private void button2_Click(object sender, EventArgs e)
        {
            //タスクバーを自動的に隠す
            APPBARDATA abd = new APPBARDATA();
            abd.cbSize = Marshal.SizeOf(abd);
            abd.lParam = ABS_AUTOHIDE;
            SHAppBarMessage(ABM_SETSTATE, ref abd);

            // タスクバーを非表示
            ShowWindow(FindWindow("Shell_TrayWnd", IntPtr.Zero), SW_HIDE);

            // フォームを閉じる
            //this.Close();
        }
Exemplo n.º 14
0
        private void button1_Click(object sender, EventArgs e)
        {
            // タスクバーを常に表示
            APPBARDATA abd = new APPBARDATA();
            abd.cbSize = Marshal.SizeOf(abd);
            abd.lParam = ABS_ALWAYSONTOP;
            SHAppBarMessage(ABM_SETSTATE, ref abd);

            // タスクバーを表示
            ShowWindow(FindWindow("Shell_TrayWnd", IntPtr.Zero), SW_NORMAL);

            // フォームを閉じる
            //this.Close();
        }
Exemplo n.º 15
0
 /// 
 /// 设置系统任务栏是否自动隐藏
 /// 
 ///  True 设置为自动隐藏,False 取消自动隐藏
 public static void SetAppBarAutoDisplay(bool IsAuto)
 {
     APPBARDATA abd = new APPBARDATA();
     abd.hwnd = FindWindow("Shell_TrayWnd", "");
     //abd.lParam = ABS_ALWAYSONTOP Or ABS_AUTOHIDE   '自动隐藏,且位于窗口前
     //abd.lParam = ABS_ALWAYSONTOP                   '不自动隐藏,且位于窗口前
     //abd.lParam = ABS_AUTOHIDE                       '自动隐藏,且不位于窗口前
     if (IsAuto)
     {
         abd.lParam = ABS_AUTOHIDE;
         SHAppBarMessage(ABM_SETSTATE, ref abd);
     }
     else
     {
         abd.lParam = ABS_ALWAYSONTOP;
         SHAppBarMessage(ABM_SETSTATE, ref abd);
     }
 }
Exemplo n.º 16
0
        private static MINMAXINFO AdjustWorkingAreaForAutoHide(IntPtr monitorContainingApplication, MINMAXINFO mmi)
        {
            IntPtr hwnd = FindWindow("Shell_TrayWnd", null);
            if (hwnd == null) return mmi;
            IntPtr monitorWithTaskbarOnIt = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
            if (!monitorContainingApplication.Equals(monitorWithTaskbarOnIt)) return mmi;
            APPBARDATA abd = new APPBARDATA();
            abd.cbSize = Marshal.SizeOf(abd);
            abd.hWnd = hwnd;
            SHAppBarMessage((int)ABMsg.ABM_GETTASKBARPOS, ref abd);
            int uEdge = GetEdge(abd.rc);
            bool autoHide = System.Convert.ToBoolean(SHAppBarMessage((int)ABMsg.ABM_GETSTATE, ref abd));

            if (!autoHide) return mmi;

            switch (uEdge)
            {
                case (int)ABEdge.ABE_LEFT:
                    mmi.ptMaxPosition.x += 2;
                    mmi.ptMaxTrackSize.x -= 2;
                    mmi.ptMaxSize.x -= 2;
                    break;
                case (int)ABEdge.ABE_RIGHT:
                    mmi.ptMaxSize.x -= 2;
                    mmi.ptMaxTrackSize.x -= 2;
                    break;
                case (int)ABEdge.ABE_TOP:
                    mmi.ptMaxPosition.y += 2;
                    mmi.ptMaxTrackSize.y -= 2;
                    mmi.ptMaxSize.y -= 2;
                    break;
                case (int)ABEdge.ABE_BOTTOM:
                    mmi.ptMaxSize.y -= 2;
                    mmi.ptMaxTrackSize.y -= 2;
                    break;
                default:
                    return mmi;
            }
            return mmi;
        }
Exemplo n.º 17
0
 private static extern IntPtr _SHAppBarMessage([MarshalAs(UnmanagedType.U4)] int dwMessage, [In][Out] ref APPBARDATA pData);
Exemplo n.º 18
0
 public static extern IntPtr SHAppBarMessage(uint dwMessage, [In] ref APPBARDATA pData);
Exemplo n.º 19
0
        private void ABSetPos()
        {
            APPBARDATA abd = new APPBARDATA();

            abd.cbSize = Marshal.SizeOf(abd);
            abd.hWnd   = this.Handle;
            switch (direction)
            {
            case BarPosition.Top:
                abd.uEdge = (int)ABEdge.ABE_TOP;
                break;

            case BarPosition.Bottom:
                abd.uEdge = (int)ABEdge.ABE_BOTTOM;
                break;

            case BarPosition.Left:
                abd.uEdge = (int)ABEdge.ABE_LEFT;
                break;

            case BarPosition.Right:
                abd.uEdge = (int)ABEdge.ABE_RIGHT;
                break;
            }

            if (abd.uEdge == (int)ABEdge.ABE_LEFT || abd.uEdge == (int)ABEdge.ABE_RIGHT)
            {
                abd.rc.Top    = 0;
                abd.rc.Bottom = SystemInformation.PrimaryMonitorSize.Height;
                if (abd.uEdge == (int)ABEdge.ABE_LEFT)
                {
                    abd.rc.Left  = 0;
                    abd.rc.Right = Size.Width;
                }
                else
                {
                    abd.rc.Right = SystemInformation.PrimaryMonitorSize.Width;
                    abd.rc.Left  = abd.rc.Right - Size.Width;
                }
            }
            else
            {
                abd.rc.Left  = 0;
                abd.rc.Right = SystemInformation.PrimaryMonitorSize.Width;
                if (abd.uEdge == (int)ABEdge.ABE_TOP)
                {
                    abd.rc.Top    = 0;
                    abd.rc.Bottom = Size.Height;
                }
                else
                {
                    abd.rc.Bottom = SystemInformation.PrimaryMonitorSize.Height;
                    abd.rc.Top    = abd.rc.Bottom - Size.Height;
                }
            }

            // Query the system for an approved size and position.
            pinvokeHandler.SHAppBarMessage((int)ABMsg.ABM_QUERYPOS, ref abd);

            // Adjust the rectangle, depending on the edge to which the
            // appbar is anchored.
            switch (abd.uEdge)
            {
            case (int)ABEdge.ABE_LEFT:
                abd.rc.Right = abd.rc.Left + Size.Width;
                break;

            case (int)ABEdge.ABE_RIGHT:
                abd.rc.Left = abd.rc.Right - Size.Width;
                break;

            case (int)ABEdge.ABE_TOP:
                abd.rc.Bottom = abd.rc.Top + Size.Height;
                break;

            case (int)ABEdge.ABE_BOTTOM:
                abd.rc.Top = abd.rc.Bottom - Size.Height;
                break;
            }

            // Pass the final bounding rectangle to the system.
            pinvokeHandler.SHAppBarMessage((int)ABMsg.ABM_SETPOS, ref abd);

            // Move and size the appbar so that it conforms to the
            // bounding rectangle passed to the system.
            pinvokeHandler.MoveWindow(abd.hWnd, abd.rc.Left, abd.rc.Top,
                                      abd.rc.Right - abd.rc.Left, abd.rc.Bottom - abd.rc.Top, true);
        }
Exemplo n.º 20
0
        public static void ABSetPos(Window abWindow, Screen screen, double width, double height, ABEdge edge)
        {
            lock (appBarLock)
            {
                APPBARDATA abd = new APPBARDATA();
                abd.cbSize = Marshal.SizeOf(typeof(APPBARDATA));
                IntPtr handle = new WindowInteropHelper(abWindow).Handle;
                abd.hWnd  = handle;
                abd.uEdge = (int)edge;
                int sWidth  = (int)width;
                int sHeight = (int)height;

                int top    = 0;
                int left   = SystemInformation.PrimaryMonitorSize.Width;  //TODO
                int right  = SystemInformation.PrimaryMonitorSize.Height; //TODO
                int bottom = (int)Math.Floor(42 * App.DPI);               //BIGTODO TODO

                if (screen != null)
                {
                    top    = screen.Bounds.Y;
                    left   = screen.Bounds.Left;
                    right  = screen.Bounds.Right;
                    bottom = screen.Bounds.Bottom;
                }

                if (abd.uEdge == (int)ABEdge.ABE_LEFT || abd.uEdge == (int)ABEdge.ABE_RIGHT)
                {
                    abd.rc.Top    = top;
                    abd.rc.Bottom = bottom;
                    if (abd.uEdge == (int)ABEdge.ABE_LEFT)
                    {
                        abd.rc.Left  = left;
                        abd.rc.Right = abd.rc.Left + sWidth;
                    }
                    else
                    {
                        abd.rc.Right = right;
                        abd.rc.Left  = abd.rc.Right - sWidth;
                    }
                }
                else
                {
                    abd.rc.Left  = left;
                    abd.rc.Right = right;
                    if (abd.uEdge == (int)ABEdge.ABE_TOP)
                    {
                        if (abWindow is TaskbarWindow)
                        {
                            abd.rc.Top = top + Convert.ToInt32(24 * App.DPI); //BIGTODO TODO
                        }
                        else
                        {
                            abd.rc.Top = top;
                        }
                        abd.rc.Bottom = abd.rc.Top + sHeight;
                    }
                    else
                    {
                        abd.rc.Bottom = bottom;
                        abd.rc.Top    = abd.rc.Bottom - sHeight;
                    }
                }

                SHAppBarMessage((int)ABMsg.ABM_SETPOS, ref abd);

                int h = abd.rc.Bottom - abd.rc.Top;

                abWindow.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle,
                                                new ResizeDelegate(DoResize), abd.hWnd, abd.rc.Left, abd.rc.Top,
                                                abd.rc.Right - abd.rc.Left, abd.rc.Bottom - abd.rc.Top);

                if (h < sHeight)
                {
                    ABSetPos(abWindow, screen, width, height, edge);
                }
            }
        }
Exemplo n.º 21
0
        public static void Unregister(Form form)
        {
            _appBars.Remove(form);
            if (form.IsDisposed)
                return;

            APPBARDATA appData = new APPBARDATA();
            appData.cbSize = (uint)Marshal.SizeOf(appData);
            appData.hWnd = form.Handle;
            SHAppBarMessage(AppBarMessage.Remove, ref appData);
        }
Exemplo n.º 22
0
        public static void ABSetPos(AppBarWindow abWindow, double width, double height, ABEdge edge, bool isCreate = false)
        {
            lock (appBarLock)
            {
                APPBARDATA abd = new APPBARDATA();
                abd.cbSize = Marshal.SizeOf(typeof(APPBARDATA));
                abd.hWnd   = abWindow.Handle;
                abd.uEdge  = (int)edge;
                int sWidth  = (int)width;
                int sHeight = (int)height;

                int top    = 0;
                int left   = 0;
                int right  = WindowManager.PrimaryMonitorDeviceSize.Width;
                int bottom = WindowManager.PrimaryMonitorDeviceSize.Height;

                if (abWindow.Screen != null)
                {
                    top    = abWindow.Screen.Bounds.Y;
                    left   = abWindow.Screen.Bounds.X;
                    right  = abWindow.Screen.Bounds.Right;
                    bottom = abWindow.Screen.Bounds.Bottom;
                }

                if (abd.uEdge == (int)ABEdge.ABE_LEFT || abd.uEdge == (int)ABEdge.ABE_RIGHT)
                {
                    abd.rc.Top    = top;
                    abd.rc.Bottom = bottom;
                    if (abd.uEdge == (int)ABEdge.ABE_LEFT)
                    {
                        abd.rc.Left  = left;
                        abd.rc.Right = abd.rc.Left + sWidth;
                    }
                    else
                    {
                        abd.rc.Right = right;
                        abd.rc.Left  = abd.rc.Right - sWidth;
                    }
                }
                else
                {
                    abd.rc.Left  = left;
                    abd.rc.Right = right;
                    if (abd.uEdge == (int)ABEdge.ABE_TOP)
                    {
                        if (!abWindow.requiresScreenEdge)
                        {
                            abd.rc.Top = top + Convert.ToInt32(GetAppBarEdgeWindowsHeight((ABEdge)abd.uEdge, abWindow.Screen));
                        }
                        else
                        {
                            abd.rc.Top = top;
                        }
                        abd.rc.Bottom = abd.rc.Top + sHeight;
                    }
                    else
                    {
                        if (!abWindow.requiresScreenEdge)
                        {
                            abd.rc.Bottom = bottom - Convert.ToInt32(GetAppBarEdgeWindowsHeight((ABEdge)abd.uEdge, abWindow.Screen));
                        }
                        else
                        {
                            abd.rc.Bottom = bottom;
                        }
                        abd.rc.Top = abd.rc.Bottom - sHeight;
                    }
                }

                prepareForInterop();
                SHAppBarMessage((int)ABMsg.ABM_QUERYPOS, ref abd);
                interopDone();

                // system doesn't adjust all edges for us, do some adjustments
                switch (abd.uEdge)
                {
                case (int)ABEdge.ABE_LEFT:
                    abd.rc.Right = abd.rc.Left + sWidth;
                    break;

                case (int)ABEdge.ABE_RIGHT:
                    abd.rc.Left = abd.rc.Right - sWidth;
                    break;

                case (int)ABEdge.ABE_TOP:
                    abd.rc.Bottom = abd.rc.Top + sHeight;
                    break;

                case (int)ABEdge.ABE_BOTTOM:
                    abd.rc.Top = abd.rc.Bottom - sHeight;
                    break;
                }

                prepareForInterop();
                SHAppBarMessage((int)ABMsg.ABM_SETPOS, ref abd);
                interopDone();

                // check if new coords
                bool isSameCoords = false;
                if (!isCreate)
                {
                    isSameCoords = abd.rc.Top == (abWindow.Top * abWindow.dpiScale) && abd.rc.Left == (abWindow.Left * abWindow.dpiScale) && abd.rc.Bottom == (abWindow.Top * abWindow.dpiScale) + sHeight && abd.rc.Right == (abWindow.Left * abWindow.dpiScale) + sWidth;
                }

                if (!isSameCoords)
                {
                    CairoLogger.Instance.Debug(string.Format("AppBarHelper: {0} changing position (TxLxBxR) to {1}x{2}x{3}x{4} from {5}x{6}x{7}x{8}", abWindow.Name, abd.rc.Top, abd.rc.Left, abd.rc.Bottom, abd.rc.Right, (abWindow.Top * abWindow.dpiScale), (abWindow.Left * abWindow.dpiScale), (abWindow.Top * abWindow.dpiScale) + sHeight, (abWindow.Left * abWindow.dpiScale) + sWidth));
                    abWindow.setAppBarPosition(abd.rc);
                }

                abWindow.afterAppBarPos(isSameCoords, abd.rc);

                if (abd.rc.Bottom - abd.rc.Top < sHeight)
                {
                    ABSetPos(abWindow, width, height, edge);
                }
            }
        }
Exemplo n.º 23
0
 public static extern UInt32 SHAppBarMessage(
     UInt32 dwMessage, // Appbar message value to send.
     ref APPBARDATA pData);
Exemplo n.º 24
0
 private static extern bool SHAppBarMessage(
     uint dwMessage,             // ABM_GETTASKBARPOS
     ref APPBARDATA pData);
Exemplo n.º 25
0
        public void SetAppBar(int screen, DockEdge edge, WorkArea windowWA, WorkArea appbarWA, Action callback)
        {
            if (edge == DockEdge.None)
            {
                throw new ArgumentException("This parameter cannot be set to 'none'.", "edge");
            }

            bool _init = false;

            APPBARDATA _data = NewData();

            if (!IsAppBar)
            {
                IsAppBar = _init = true;

                _callbackID = _data.uCallbackMessage = NativeMethods.RegisterWindowMessage("AppBarMessage");

                NativeMethods.SHAppBarMessage(APPBARMSG.ABM_NEW, ref _data);
            }

            Screen   = screen;
            DockEdge = edge;

            _data.uEdge = (int)edge;
            _data.rc    = new RECT()
            {
                Left   = (int)Math.Round(appbarWA.Left),
                Top    = (int)Math.Round(appbarWA.Top),
                Right  = (int)Math.Round(appbarWA.Right),
                Bottom = (int)Math.Round(appbarWA.Bottom)
            };

            NativeMethods.SHAppBarMessage(APPBARMSG.ABM_QUERYPOS, ref _data);

            NativeMethods.SHAppBarMessage(APPBARMSG.ABM_SETPOS, ref _data);

            appbarWA.Left   = _data.rc.Left;
            appbarWA.Top    = _data.rc.Top;
            appbarWA.Right  = _data.rc.Right;
            appbarWA.Bottom = _data.rc.Bottom;

            AppBarWidth = appbarWA.Width;

            Move(windowWA);

            if (_init)
            {
                Task.Delay(500).ContinueWith(_ =>
                {
                    Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (Action)(() =>
                    {
                        HwndSource.AddHook(AppBarHook);

                        if (callback != null)
                        {
                            callback();
                        }
                    }));
                });
            }
            else if (callback != null)
            {
                callback();
            }
        }
Exemplo n.º 26
0
 public static extern int SHAppBarMessage(int dwmsg, ref APPBARDATA app);
Exemplo n.º 27
0
 public static extern uint SHAppBarMessage(ABMsg dwMessage, [In] ref APPBARDATA pData);
Exemplo n.º 28
0
 public static extern int SHAppBarMessage(int dwMessage, [MarshalAs(UnmanagedType.Struct)] ref APPBARDATA pData);
 static extern UInt32 SHAppBarMessage(UInt32 dwMessage, ref APPBARDATA data);
Exemplo n.º 30
0
 internal static extern uint SHAppBarMessage(uint dwMessage, ref APPBARDATA data);
Exemplo n.º 31
0
 private static extern uint SHAppBarMessage(AppBarMessage dwMessage, ref APPBARDATA pData);
Exemplo n.º 32
0
        private static void AppBarSetPosition(AppBarEdge edge, Form appBarForm)
        {
            var regInfo    = GetRegisterInfo(appBarForm);
            var screenRect = GetScreenBounds(appBarForm);

            APPBARDATA barData = new APPBARDATA();

            barData.cbSize = Marshal.SizeOf(barData);
            barData.hWnd   = appBarForm.Handle;
            barData.uEdge  = (int)edge;

            DebugLog("AppBarSetPosition()", "Starting...");

            if (edge == AppBarEdge.Left || edge == AppBarEdge.Right)
            {
                // Bar should be the full available height of the screen
                barData.rc.top    = 0;
                barData.rc.bottom = screenRect.Height;

                if (edge == AppBarEdge.Left)
                {
                    // Setup proposed location
                    barData.rc.left  = 0;
                    barData.rc.right = barData.rc.left + regInfo.OrigSize.Width;
                }
                else if (edge == AppBarEdge.Right)
                {
                    // Setup proposed location
                    barData.rc.right = screenRect.Width;
                    barData.rc.left  = barData.rc.right - regInfo.OrigSize.Width;
                }
            }
            else
            {
                // Bar should be the full available width of the screen
                barData.rc.left  = 0;
                barData.rc.right = screenRect.Width;

                if (edge == AppBarEdge.Top)
                {
                    // Setup proposed location
                    barData.rc.top    = 0;
                    barData.rc.bottom = barData.rc.top + regInfo.OrigSize.Height;
                }
                else if (edge == AppBarEdge.Bottom)
                {
                    // Setup proposed location
                    barData.rc.bottom = screenRect.Height;
                    barData.rc.top    = barData.rc.bottom - regInfo.OrigSize.Height;
                }
            }

            // Send the query message to find out the other bars on the screen at that edge...
            DebugLog("AppBarSetPosition()", "barData.rc before ABM_QUERYPOS: " + barData.rc.ToString());
            SHAppBarMessage((int)AppBarMsg.ABM_QUERYPOS, ref barData);
            DebugLog("AppBarSetPosition()", "barData.rc after ABM_QUERYPOS: " + barData.rc.ToString());

            // Now we need to use that returned info and resize the barData.rc structure...
            if (edge == AppBarEdge.Top)
            {
                barData.rc.bottom = barData.rc.top + regInfo.OrigSize.Height;
            }
            else if (edge == AppBarEdge.Bottom)
            {
                barData.rc.top = barData.rc.bottom - regInfo.OrigSize.Height;
            }
            else if (edge == AppBarEdge.Left)
            {
                barData.rc.right = barData.rc.left + regInfo.OrigSize.Width;
            }
            else if (edge == AppBarEdge.Right)
            {
                barData.rc.left = barData.rc.right - regInfo.OrigSize.Width;
            }

            // Send the set position message...
            DebugLog("AppBarSetPosition()", "barData.rc before ABM_SETPOS: " + barData.rc.ToString());
            SHAppBarMessage((int)AppBarMsg.ABM_SETPOS, ref barData);
            DebugLog("AppBarSetPosition()", "barData.rc after ABM_SETPOS: " + barData.rc.ToString());

            // Sleep 0.5 seconds
            System.Threading.Thread.Sleep(500);

            // Finally move the window into mosition...
            appBarForm.BeginInvoke(new MoveAndResizeWindowDelegate(MoveAndResizeWindow), barData.hWnd, barData.rc);
        }
Exemplo n.º 33
0
 private static extern UInt32 SHAppBarMessage(UInt32 dwMessage, ref APPBARDATA data);
Exemplo n.º 34
0
 public static extern IntPtr SHAppBarMessage(AppBarMessages dwMessage, ref APPBARDATA pData);
Exemplo n.º 35
0
 public static extern UInt32 SHAppBarMessage(UInt32 dwMessage, ref APPBARDATA pData);
Exemplo n.º 36
0
 /// <summary>
 /// Sends an appbar message to the system.
 /// </summary>
 /// <param name="dwMessage">Appbar message value to send.</param>
 /// <param name="pData">A pointer to an APPBARDATA structure. The content of the structure on entry and on exit depends on the value set in the dwMessage parameter. See the individual message pages for specifics.</param>
 /// <returns></returns>
 public static UIntPtr SHAppBarMessage(AppBarMessage dwMessage, ref APPBARDATA pData)
 {
     return(NativeMethods.SHAppBarMessage(dwMessage, ref pData));
 }
Exemplo n.º 37
0
 public static IntPtr SHAppBarMessage(uint dwMessage, [In] ref APPBARDATA pData)
 {
     // TODO
     NotImplemented(MethodBase.GetCurrentMethod());
     return(IntPtr.Zero);
 }
Exemplo n.º 38
0
        /// <summary>
        /// Creats an APPBARDATA struct with its hWnd member set to the task bar window.
        /// </summary>
        /// <returns></returns>
        private static APPBARDATA CreateAppBarData()
        {
            APPBARDATA appBar = new APPBARDATA();

            appBar.hWnd = FindWindow("Shell_TrayWnd", "");
            appBar.cbSize = Marshal.SizeOf(appBar);

            return appBar;
        }
Exemplo n.º 39
0
 private static extern uint SHAppBarMessage(int dwMessage, ref APPBARDATA pData);
Exemplo n.º 40
0
 public static extern uint SHAppBarMessage(int dwMessage, out APPBARDATA pData);
Exemplo n.º 41
0
 public TaskbarLocation(APPBARDATA data)
 {
     Set(data);
 }
Exemplo n.º 42
0
 public static extern UInt32 SHAppBarMessage(
     UInt32 dwMessage,					// Appbar message value to send.
     ref APPBARDATA pData);
Exemplo n.º 43
0
        //It is hardcoded to set to the right side
        private void ABSetPos()
        {
            Rectangle screenSize = ScreenPixelHelper.GetScreenSize();

            try
            {
                APPBARDATA abd = new APPBARDATA();
                abd.cbSize = Marshal.SizeOf(abd);
                abd.hWnd   = this.Handle;
                abd.uEdge  = (int)ABEdge.ABE_RIGHT;

                if (abd.uEdge == (int)ABEdge.ABE_LEFT || abd.uEdge == (int)ABEdge.ABE_RIGHT)
                {
                    abd.rc.top    = 0;
                    abd.rc.bottom = screenSize.Height;
                    if (abd.uEdge == (int)ABEdge.ABE_LEFT)
                    {
                        abd.rc.left  = 0;
                        abd.rc.right = Size.Width;
                    }
                    else
                    {
                        abd.rc.right = screenSize.Width;
                        abd.rc.left  = abd.rc.right - Size.Width;
                    }
                }
                else
                {
                    abd.rc.left  = 0;
                    abd.rc.right = screenSize.Width;
                    if (abd.uEdge == (int)ABEdge.ABE_TOP)
                    {
                        abd.rc.top    = 0;
                        abd.rc.bottom = Size.Height;
                    }
                    else
                    {
                        abd.rc.bottom = screenSize.Height;
                        abd.rc.top    = abd.rc.bottom - Size.Height;
                    }
                }

                // Query the system for an approved size and position.
                SHAppBarMessage((int)ABMsg.ABM_QUERYPOS, ref abd);

                // Adjust the rectangle, depending on the edge to which the
                // appbar is anchored.
                switch (abd.uEdge)
                {
                case (int)ABEdge.ABE_LEFT:
                    abd.rc.right = abd.rc.left + Size.Width;
                    break;

                case (int)ABEdge.ABE_RIGHT:
                    abd.rc.left = abd.rc.right - Size.Width;
                    break;

                case (int)ABEdge.ABE_TOP:
                    abd.rc.bottom = abd.rc.top + Size.Height;
                    break;

                case (int)ABEdge.ABE_BOTTOM:
                    abd.rc.top = abd.rc.bottom - Size.Height;
                    break;
                }

                // Pass the final bounding rectangle to the system.
                SHAppBarMessage((int)ABMsg.ABM_SETPOS, ref abd);

                // Move and size the appbar so that it conforms to the
                // bounding rectangle passed to the system.
                MoveWindow(abd.hWnd, abd.rc.left, abd.rc.top,
                           abd.rc.right - abd.rc.left, abd.rc.bottom - abd.rc.top, true);
            }
            catch (Exception ex)
            {
                Logger.WriteError(ex.ToString());
            }
        }
Exemplo n.º 44
0
        public void ABSetPos(AppBarWindow abWindow, double width, double height, AppBarEdge edge, bool isCreate = false)
        {
            lock (appBarLock)
            {
                APPBARDATA abd = new APPBARDATA
                {
                    cbSize = Marshal.SizeOf(typeof(APPBARDATA)),
                    hWnd   = abWindow.Handle,
                    uEdge  = (int)edge
                };

                int sWidth  = (int)width;
                int sHeight = (int)height;

                int top    = 0;
                int left   = 0;
                int right  = ScreenHelper.PrimaryMonitorDeviceSize.Width;
                int bottom = ScreenHelper.PrimaryMonitorDeviceSize.Height;

                int edgeOffset = 0;

                if (abWindow.Screen != null)
                {
                    top    = abWindow.Screen.Bounds.Y;
                    left   = abWindow.Screen.Bounds.X;
                    right  = abWindow.Screen.Bounds.Right;
                    bottom = abWindow.Screen.Bounds.Bottom;
                }

                if (!abWindow.RequiresScreenEdge)
                {
                    edgeOffset = Convert.ToInt32(GetAppBarEdgeWindowsHeight((AppBarEdge)abd.uEdge, abWindow.Screen));
                }

                if (abd.uEdge == (int)AppBarEdge.Left || abd.uEdge == (int)AppBarEdge.Right)
                {
                    abd.rc.Top    = top;
                    abd.rc.Bottom = bottom;
                    if (abd.uEdge == (int)AppBarEdge.Left)
                    {
                        abd.rc.Left  = left + edgeOffset;
                        abd.rc.Right = abd.rc.Left + sWidth;
                    }
                    else
                    {
                        abd.rc.Right = right - edgeOffset;
                        abd.rc.Left  = abd.rc.Right - sWidth;
                    }
                }
                else
                {
                    abd.rc.Left  = left;
                    abd.rc.Right = right;
                    if (abd.uEdge == (int)AppBarEdge.Top)
                    {
                        abd.rc.Top    = top + edgeOffset;
                        abd.rc.Bottom = abd.rc.Top + sHeight;
                    }
                    else
                    {
                        abd.rc.Bottom = bottom - edgeOffset;
                        abd.rc.Top    = abd.rc.Bottom - sHeight;
                    }
                }

                SHAppBarMessage((int)ABMsg.ABM_QUERYPOS, ref abd);

                // system doesn't adjust all edges for us, do some adjustments
                switch (abd.uEdge)
                {
                case (int)AppBarEdge.Left:
                    abd.rc.Right = abd.rc.Left + sWidth;
                    break;

                case (int)AppBarEdge.Right:
                    abd.rc.Left = abd.rc.Right - sWidth;
                    break;

                case (int)AppBarEdge.Top:
                    abd.rc.Bottom = abd.rc.Top + sHeight;
                    break;

                case (int)AppBarEdge.Bottom:
                    abd.rc.Top = abd.rc.Bottom - sHeight;
                    break;
                }

                SHAppBarMessage((int)ABMsg.ABM_SETPOS, ref abd);

                // check if new coords
                bool isSameCoords = false;
                if (!isCreate)
                {
                    bool topUnchanged    = abd.rc.Top == (abWindow.Top * abWindow.DpiScale);
                    bool leftUnchanged   = abd.rc.Left == (abWindow.Left * abWindow.DpiScale);
                    bool bottomUnchanged = abd.rc.Bottom == (abWindow.Top * abWindow.DpiScale) + sHeight;
                    bool rightUnchanged  = abd.rc.Right == (abWindow.Left * abWindow.DpiScale) + sWidth;

                    isSameCoords = topUnchanged &&
                                   leftUnchanged &&
                                   bottomUnchanged &&
                                   rightUnchanged;
                }

                if (!isSameCoords)
                {
                    ShellLogger.Debug($"AppBarManager: {abWindow.Name} changing position (TxLxBxR) to {abd.rc.Top}x{abd.rc.Left}x{abd.rc.Bottom}x{abd.rc.Right} from {abWindow.Top * abWindow.DpiScale}x{abWindow.Left * abWindow.DpiScale}x{(abWindow.Top * abWindow.DpiScale) + sHeight}x{ (abWindow.Left * abWindow.DpiScale) + sWidth}");
                    abWindow.SetAppBarPosition(abd.rc);
                }

                abWindow.AfterAppBarPos(isSameCoords, abd.rc);

                if (((abd.uEdge == (int)AppBarEdge.Top || abd.uEdge == (int)AppBarEdge.Bottom) && abd.rc.Bottom - abd.rc.Top < sHeight) ||
                    ((abd.uEdge == (int)AppBarEdge.Left || abd.uEdge == (int)AppBarEdge.Right) && abd.rc.Right - abd.rc.Left < sWidth))
                {
                    ABSetPos(abWindow, width, height, edge);
                }
            }
        }
Exemplo n.º 45
0
 void RegisterAppBar(bool registered)
 {
     APPBARDATA abd = new APPBARDATA();
     abd.cbSize = Marshal.SizeOf(abd);
        // abd.hWnd = Application.;
     if (!registered) {
         //register
         uCallBackMsg = RegisterWindowMessage("APPBARMSG_CSDN_HELPER");
         abd.uCallbackMessage = uCallBackMsg;
         uint ret = SHAppBarMessage((int)ABMsg.ABM_NEW, ref abd);
     } else {
         SHAppBarMessage((int)ABMsg.ABM_REMOVE, ref abd);
     }
 }
Exemplo n.º 46
0
 private static extern int SHAppBarMessage(ABMsg dwMessage, ref APPBARDATA pData);
Exemplo n.º 47
0
 public static Rectangle GetTaskbarRectangle()
 {
     APPBARDATA abd = new APPBARDATA();
     SHAppBarMessage((int)ABMsg.ABM_GETTASKBARPOS, out abd);
     return abd.rc.ToRectangle();
 }
Exemplo n.º 48
0
 protected static extern uint SHAppBarMessage(int dwMessage, ref APPBARDATA pData);
Exemplo n.º 49
0
        /// <summary>
        /// Method returns information about the Window's TaskBar.
        /// </summary>
        /// <param name="taskBarEdge">Location of the TaskBar(Top,Bottom,Left,Right).</param>
        /// <param name="height">Height of the TaskBar.</param>
        /// <param name="autoHide">AutoHide property of the TaskBar.</param>
        private static void GetTaskBarInfo(out TaskBarEdge taskBarEdge, out int height, out bool autoHide)
        {
            APPBARDATA abd = new APPBARDATA();

            height = 0;
            taskBarEdge = TaskBarEdge.Bottom;
            autoHide = false;

            uint ret = SHAppBarMessage((int)ABMsg.ABM_GETTASKBARPOS, out abd);
            switch (abd.uEdge)
            {
                case (int)ABEdge.ABE_BOTTOM:
                    taskBarEdge = TaskBarEdge.Bottom;
                    height = abd.rc.Height;
                    break;
                case (int)ABEdge.ABE_TOP:
                    taskBarEdge = TaskBarEdge.Top;
                    height = abd.rc.Bottom;
                    break;
                case (int)ABEdge.ABE_LEFT:
                    taskBarEdge = TaskBarEdge.Left;
                    height = abd.rc.Width;
                    break;
                case (int)ABEdge.ABE_RIGHT:
                    taskBarEdge = TaskBarEdge.Right;
                    height = abd.rc.Width;
                    break;
            }

            abd = new APPBARDATA();
            uint uState = SHAppBarMessage((int)ABMsg.ABM_GETSTATE, out abd);
            switch (uState)
            {
                case (int)ABState.ABS_ALWAYSONTOP:
                    autoHide = false;
                    break;
                case (int)ABState.ABS_AUTOHIDE:
                    autoHide = true;
                    break;
                case (int)ABState.ABS_AUTOHIDEANDONTOP:
                    autoHide = true;
                    break;
                case (int)ABState.ABS_MANUAL:
                    autoHide = false;
                    break;
            }
        }
Exemplo n.º 50
0
        protected void UpdateWindow()
        {
            if (this.ResizeMode == ResizeMode.CanResize || this.ResizeMode == ResizeMode.CanResizeWithGrip)
            {
                this.windowChrome.ResizeBorderThickness = new Thickness(6);
            }
            else
            {
                this.windowChrome.ResizeBorderThickness = new Thickness(0);
            }

            if (this.WindowState == WindowState.Maximized)
            {
                var mHwnd   = new WindowInteropHelper(this).Handle;
                var monitor = NativeMethods.MonitorFromWindow(mHwnd, Native.Constants.MONITOR_DEFAULTTONEAREST);

                var pData = new APPBARDATA();
                pData.cbSize = Marshal.SizeOf(pData);
                pData.hWnd   = mHwnd;

                if (Convert.ToBoolean(NativeMethods.SHAppBarMessage((int)ABMsg.ABM_GETSTATE, ref pData)))
                {
                    if (monitor != IntPtr.Zero)
                    {
                        var monitorInfo = new MONITORINFO();
                        NativeMethods.GetMonitorInfo(monitor, monitorInfo);
                        int x  = monitorInfo.rcWork.left;
                        int y  = monitorInfo.rcWork.top;
                        int cx = monitorInfo.rcWork.right - x;
                        int cy = monitorInfo.rcWork.bottom - y;

                        NativeMethods.SHAppBarMessage((int)ABMsg.ABM_GETTASKBARPOS, ref pData);
                        var uEdge = GetEdge(pData.rc);

                        switch (uEdge)
                        {
                        case ABEdge.ABE_TOP: y++;
                            break;

                        case ABEdge.ABE_BOTTOM: cy--;
                            break;

                        case ABEdge.ABE_LEFT: x++;
                            break;

                        case ABEdge.ABE_RIGHT: cx--;
                            break;
                        }

                        NativeMethods.SetWindowPos(mHwnd, new IntPtr(Native.Constants.HWND_NOTOPMOST), x, y, cx, cy,
                                                   Native.Constants.SWP_SHOWWINDOW);
                    }
                }
                else
                {
                    this.windowBorder.BorderThickness = new Thickness(6);
                }

                this.windowChrome.GlassFrameThickness   = new Thickness(0);
                this.windowChrome.ResizeBorderThickness = new Thickness(0);
                this.maximizeButton.ToolTip             = RestoreToolTip;
            }
            else
            {
                this.windowChrome.GlassFrameThickness = new Thickness(1, 0, 0, 0);
                this.windowBorder.BorderThickness     = this.previousBorderThickness;
                this.maximizeButton.ToolTip           = MaximizeToolTip;
            }
        }
Exemplo n.º 51
0
    public Taskbar()
    {
        IntPtr taskbarHandle = User32.FindWindow(Taskbar.ClassName, null);

        APPBARDATA data = new APPBARDATA();
        data.cbSize = (uint)Marshal.SizeOf(typeof(APPBARDATA));
        data.hWnd = taskbarHandle;
        IntPtr result = Shell32.SHAppBarMessage(ABM.GetTaskbarPos, ref data);
        if (result == IntPtr.Zero)
            throw new InvalidOperationException();

        this.Position = (TaskbarPosition)data.uEdge;
        this.Bounds = Rectangle.FromLTRB(
            data.rc.left,
            data.rc.top,
            data.rc.right,
            data.rc.bottom
        );

        data.cbSize = (uint)Marshal.SizeOf(typeof(APPBARDATA));
        result = Shell32.SHAppBarMessage(ABM.GetState, ref data);
        int state = result.ToInt32();
        this.AlwaysOnTop = (state & ABS.AlwaysOnTop) == ABS.AlwaysOnTop;
        this.AutoHide = (state & ABS.Autohide) == ABS.Autohide;
    }
Exemplo n.º 52
0
        public static void Register(Form form, AppBarEdge edge, Screen screen)
        {
            Rectangle screenArea = screen.WorkingArea;
            if (edge == AppBarEdge.Top || edge == AppBarEdge.Bottom)
            {
                form.Left = screenArea.Left;
                form.Width = screenArea.Width;
                form.Top = edge == AppBarEdge.Top ? screenArea.Top : screenArea.Bottom - form.Height;
            }
            else
            {
                form.Left = edge == AppBarEdge.Left ? screenArea.Left : screenArea.Right - form.Width;
                form.Height = screenArea.Height;
                form.Top = screenArea.Top;
            }
            form.FormBorderStyle = FormBorderStyle.None;
            uint callbackId = RegisterWindowMessage(form.GetHashCode().ToString("x"));

            APPBARDATA appData = new APPBARDATA();
            appData.cbSize = (uint)Marshal.SizeOf(appData);
            appData.uCallbackMessage = callbackId;
            appData.hWnd = form.Handle;

            uint ret = SHAppBarMessage(AppBarMessage.New, ref appData);
            if (ret != 0)
            {
                _appBars.Add(form);
                form.FormClosing += (s, e) => Unregister(form);
                AppBarPosition(form, edge, AppBarMessage.QueryPos);
                AppBarPosition(form, edge, AppBarMessage.SetPos);
            }
        }
        public void GetPosition(string strClassName, string strWindowName)
        {
            m_data = new APPBARDATA();
            m_data.cbSize = (UInt32) Marshal.SizeOf(m_data.GetType());

            IntPtr hWnd = FindWindow(strClassName, strWindowName);

            if (hWnd != IntPtr.Zero)
            {
                UInt32 uResult = SHAppBarMessage(ABM_GETTASKBARPOS, ref m_data);

                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");
            }
        }
Exemplo n.º 54
0
 protected static extern IntPtr SHAppBarMessage(uint dwMessage, ref APPBARDATA pData);
Exemplo n.º 55
0
        private static void AppBarPosition(Form form, AppBarEdge edge, AppBarMessage appBarMessage)
        {
            APPBARDATA appData = new APPBARDATA();
            appData.cbSize = (uint)Marshal.SizeOf(appData);
            appData.uEdge = edge;
            appData.rc = Win32.RECT.FromRectangle(form.Bounds);
            appData.hWnd = form.Handle;

            SHAppBarMessage(appBarMessage, ref appData);
            //let the application handle some events first
            //if we dont do this (especially for SetPos)
            //the position will be off and the bar jumps around
            Application.DoEvents();
            form.Bounds = appData.rc.ToRectangle();
        }
Exemplo n.º 56
0
 public static extern int SHAppBarMessage(int dwMessage, ref APPBARDATA pData);
Exemplo n.º 57
0
 public static extern System.UInt32 SHAppBarMessage(System.UInt32 dwMessage, ref APPBARDATA data);
Exemplo n.º 58
0
 private static extern IntPtr SHAppBarMessage(
     ABM dwMessage,
     ref APPBARDATA pData);
Exemplo n.º 59
0
 internal static extern uint SHAppBarMessage(int dwMessage, ref APPBARDATA pData);
Exemplo n.º 60
0
 public static extern uint SHAppBarMessage(int dwMessage, out APPBARDATA pData);