Exemple #1
0
            public override void InvokeTask()
            {
                AppBarPreference preference;
                bool             preferenceSuccess = managedAppBars.TryRemove(TargetWindow, out preference);
                AppBarData       data = new AppBarData(TargetWindow);

                SHAppBarMessage(AppBarMessage.Remove, ref data);
                uint style        = GetWindowLong(TargetWindow, WindowLongIndex.Style);
                bool isFullScreen = ((style & (uint)WindowStyle.Popup) != 0);

                if (!isFullScreen)
                {
                    style |= (uint)(WindowStyle.Caption | WindowStyle.ThickFrame | WindowStyle.SystemMenu);
                    SetWindowLong(TargetWindow, WindowLongIndex.Style, style);
                }
                style  = GetWindowLong(TargetWindow, WindowLongIndex.ExtendedStyle);
                style &= ~(uint)(WindowStyleExtended.WindowEdge | WindowStyleExtended.TopMost);
                SetWindowLong(TargetWindow, WindowLongIndex.ExtendedStyle, style);
                if (preferenceSuccess && !isFullScreen)
                {
                    SetWindowPos(TargetWindow, NoTopMostWindowHandle, 0, 0,
                                 (int)(GetSystemMetrics(SystemMetric.PrimaryScreenWidth) * preference.Width),
                                 (int)(GetSystemMetrics(SystemMetric.PrimaryScreenHeight) * preference.Height),
                                 SetWindowPosFlags.NoMove | SetWindowPosFlags.NoActivate);
                }
                else
                {
                    SetWindowPos(TargetWindow, NoTopMostWindowHandle, 0, 0, 0, 0,
                                 SetWindowPosFlags.NoMove | SetWindowPosFlags.NoSize | SetWindowPosFlags.NoActivate);
                }
            }
Exemple #2
0
        private void butTaskbar_Click(object sender, EventArgs e)
        {
            AppBarData bardata = new AppBarData();

            bardata.cbSize = Marshal.SizeOf(typeof(AppBarData));
            bardata.hWnd   = Handle;

            int retval = SHAppBarMessage(ABM_GETSTATE, ref bardata);

            switch (retval)
            {
            case ABS_AUTOHIDE:
                MessageBox.Show("Автоматически убирать с экрана");
                break;

            case ABS_ALWAYSONTOP:
                MessageBox.Show("Всегда на экране");
                break;

            case ABS_BOTH:
                MessageBox.Show("Включена опция Автоматически убирать с экрана и Показывать всегда поверх окон");
                break;
            }

            // Получим позицию Панели задач
            SHAppBarMessage(ABM_GETTASKBARPOS, ref bardata);

            // Получим координаты ограничивающего прямоугольника
            MessageBox.Show("Координаты Панели задач: (" +
                            bardata.rc.left + "," + bardata.rc.top + ")" +
                            "-" + "(" +
                            bardata.rc.right + "," + bardata.rc.bottom + ")");
        }
        public static void SetTaskBarState(TaskBarState state)
        {
            AppBarData appBar = CreateAppBarData();

            appBar.Parameter = (IntPtr)state;

            SHAppBarMessage(AbMsg.SetState, ref appBar);
        }
Exemple #4
0
            public static AppBarData Create()
            {
                AppBarData appBarData = new AppBarData {
                    cbSize = Marshal.SizeOf(typeof(AppBarData))
                };

                return(appBarData);
            }
Exemple #5
0
        /// <summary>
        /// Gets the current Taskbar state
        /// </summary>
        /// <returns>current Taskbar state</returns>
        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));
        }
        private static AppBarData CreateAppBarData()
        {
            AppBarData appBar = new AppBarData();

            appBar.Handle = FindWindow("Shell_TrayWnd", "");
            appBar.Size   = Marshal.SizeOf(appBar);

            return(appBar);
        }
Exemple #7
0
        /// <summary>
        /// Set the Taskbar State option
        /// </summary>
        /// <param name="option">AppBarState to activate</param>
        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);
        }
Exemple #8
0
		private static AppBarData GetTaskBarLocation()
		{
			var data = new AppBarData();
			data.cbSize = Marshal.SizeOf(data);
			IntPtr retval = SHAppBarMessage(ABM_GETTASKBARPOS, ref data);
			if (retval == IntPtr.Zero)
			{
				throw new Win32Exception("WinAPi Error: does'nt work api method SHAppBarMessage");
			}
			return data;
		}
        static AppBarData GetTaskBarLocation() {
            var data = new AppBarData();
            data.cbSize = Marshal.SizeOf(data);

            IntPtr retval = SHAppBarMessage(ABM_GETTASKBARPOS, ref data);

            if (retval == IntPtr.Zero)
                throw new Win32Exception("WinAPi Error: does'nt work api method SHAppBarMessage");

            return data;
        }
Exemple #10
0
        public static reBarInfo CalcAppPos(double height, double width, out AppPos pos)
        {
            System.Drawing.Rectangle screenRect = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;
            RECT      rcBar, rcTrayBtn, rcStart;
            reBarInfo rbInfo = new reBarInfo();

            try
            {
                #region
                IntPtr hTaskbar = API.FindWindow("Shell_TrayWnd", null);
                IntPtr hBar     = API.FindWindowEx(hTaskbar, IntPtr.Zero, "ReBarWindow32", null);
                IntPtr hTray    = API.FindWindowEx(hTaskbar, IntPtr.Zero, "TrayNotifyWnd", null);
                IntPtr hTrayBtn = API.FindWindowEx(hTray, IntPtr.Zero, "Button", null);
                IntPtr hStart   = API.FindWindowEx(hTaskbar, IntPtr.Zero, "Button", null);
                API.GetWindowRect(hStart, out rcStart);
                API.GetWindowRect(hBar, out rcBar);
                API.GetWindowRect(hTrayBtn, out rcTrayBtn);
                rbInfo.hreBar   = hBar;
                rbInfo.hTaskBar = hTaskbar;

                AppBarData taskbarInfo = new AppBarData();
                API.SHAppBarMessage(0x00000005, ref taskbarInfo);
                int max_size = 40;

                switch (taskbarInfo.uEdge)
                {
                    #region

                case 3:    ////任务栏在下边
                    pos.main_left = taskbarInfo.rc.Left + 30;
                    pos.main_top  = screenRect.Bottom - height - 3;
                    pos.btn_size  = rcBar.Bottom - rcBar.Top > max_size ? max_size : rcBar.Bottom - rcBar.Top;
                    pos.btn_x     = 40;
                    pos.btn_y     = (rcBar.Bottom - rcBar.Top - pos.btn_size) / 2;

                    rbInfo.x      = pos.btn_x + pos.btn_size;
                    rbInfo.y      = 0;
                    rbInfo.height = rcBar.Bottom - rcBar.Top;
                    rbInfo.width  = rcTrayBtn.Left - rbInfo.x;
                    break;

                default:
                    pos = new AppPos((screenRect.Width - width) / 2, (screenRect.Height - height) / 2);
                    break;
                    #endregion
                }
                #endregion
            }
            catch
            { pos = new AppPos((screenRect.Width - width) / 2, (screenRect.Height - height) / 2); }

            return(rbInfo);
        }
Exemple #11
0
        public static reBarInfo CalcAppPos( double height, double width, out AppPos pos )
        {
            System.Drawing.Rectangle screenRect = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;
            RECT rcBar, rcTrayBtn, rcStart;
            reBarInfo rbInfo = new reBarInfo();

            try
            {
                #region
                IntPtr hTaskbar = API.FindWindow( "Shell_TrayWnd", null );
                IntPtr hBar = API.FindWindowEx( hTaskbar, IntPtr.Zero, "ReBarWindow32", null );
                IntPtr hTray = API.FindWindowEx( hTaskbar, IntPtr.Zero, "TrayNotifyWnd", null );
                IntPtr hTrayBtn = API.FindWindowEx( hTray, IntPtr.Zero, "Button", null );
                IntPtr hStart = API.FindWindowEx( hTaskbar, IntPtr.Zero, "Button", null );
                API.GetWindowRect( hStart, out rcStart );
                API.GetWindowRect( hBar, out rcBar );
                API.GetWindowRect( hTrayBtn, out rcTrayBtn );
                rbInfo.hreBar = hBar;
                rbInfo.hTaskBar = hTaskbar;

                AppBarData taskbarInfo = new AppBarData();
                API.SHAppBarMessage( 0x00000005, ref taskbarInfo );
                int max_size = 40;

                switch ( taskbarInfo.uEdge )
                {
                    #region

                    case 3:////任务栏在下边
                        pos.main_left = taskbarInfo.rc.Left + 30;
                        pos.main_top = screenRect.Bottom - height - 3;
                        pos.btn_size = rcBar.Bottom - rcBar.Top > max_size ? max_size : rcBar.Bottom - rcBar.Top;
                        pos.btn_x = 40;
                        pos.btn_y = ( rcBar.Bottom - rcBar.Top - pos.btn_size ) / 2;

                        rbInfo.x = pos.btn_x + pos.btn_size;
                        rbInfo.y = 0;
                        rbInfo.height = rcBar.Bottom - rcBar.Top;
                        rbInfo.width = rcTrayBtn.Left - rbInfo.x;
                        break;
                    default:
                        pos = new AppPos( ( screenRect.Width - width ) / 2, ( screenRect.Height - height ) / 2 );
                        break;
                    #endregion
                }
                #endregion
            }
            catch
            { pos = new AppPos( ( screenRect.Width - width ) / 2, ( screenRect.Height - height ) / 2 ); }

            return rbInfo;
        }
Exemple #12
0
            public override void InvokeTask()
            {
                AppBarData data = new AppBarData(TargetWindow);

                if (SHAppBarMessage(AppBarMessage.New, ref data) == IntPtr.Zero)
                {
                    return;
                }
                SendMessage(TargetWindow, WM_SYSCOMMAND, (IntPtr)SC_RESTORE, IntPtr.Zero);
                SetWindowPos(TargetWindow, TopMostWindowHandle, 0, 0, 0, 0, SetWindowPosFlags.NoMove | SetWindowPosFlags.NoSize | SetWindowPosFlags.NoActivate);
                managedAppBars[TargetWindow] = new AppBarPreference()
                {
                    DockingPosition = DockingPosition
                };
                commands.Enqueue(new RefreshAppBarCommand(TargetWindow, false));
                commands.Enqueue(new RefreshAppBarCommand(TargetWindow, true));
            }
Exemple #13
0
        public Taskbar()
        {
            var taskbarHandle = FindWindow(TASKBAR_CLASS_NAME, null);

            var data = new AppBarData()
            {
                cbSize = (uint)Marshal.SizeOf(typeof(AppBarData)),
                hWnd   = taskbarHandle
            };

            var result = SHAppBarMessage(GET_TASKBAR_POS, ref data);

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

            Bounds = Rectangle.FromLTRB(data.rc.Left, data.rc.Top, data.rc.Right, data.rc.Bottom);
            //data.cbSize = (uint)Marshal.SizeOf(typeof(AppBarData));
            //result = SHAppBarMessage(GET_STATE, ref data);
            //int state
        }
Exemple #14
0
        private static AlertFormLocation GetTaskbarLocation()
        {
            IntPtr tbwnd = FindWindow("Shell_TrayWnd", null);

            if (tbwnd == null)
            {
                return(AlertFormLocation.BottomRight);
            }
            AppBarData abd = new AppBarData();

            abd.cbSize = Marshal.SizeOf(typeof(AppBarData));
            abd.hWnd   = tbwnd;
            IntPtr ptr = Marshal.AllocHGlobal(abd.cbSize);

            try
            {
                Marshal.StructureToPtr(abd, ptr, false);
                SHAppBarMessage(5, ptr);
                abd = (AppBarData)Marshal.PtrToStructure(ptr, typeof(AppBarData));
            }
            finally { Marshal.FreeHGlobal(ptr); }
            return(GetPosition(abd.rc));
        }
Exemple #15
0
        private void WM_NCCALCSIZE(ref Message m)
        {
            if (MinMaxState == FormWindowState.Maximized)
            {
                // ...
                var rectangle = (NativeRect)Marshal.PtrToStructure(m.LParam, typeof(NativeRect));

                // ...
                var paddedBorder = NativeMethods.GetSystemMetrics(SystemMetric.SM_CXPADDEDBORDER);
                var width        = NativeMethods.GetSystemMetrics(SystemMetric.SM_CXSIZEFRAME) + paddedBorder;
                var height       = NativeMethods.GetSystemMetrics(SystemMetric.SM_CYSIZEFRAME) + paddedBorder;

                // ...
                rectangle.Left   += width;
                rectangle.Top    += height;
                rectangle.Right  -= width;
                rectangle.Bottom -= height;

                // ...
                var appBarData = new AppBarData();
                appBarData.cbSize = Marshal.SizeOf(typeof(AppBarData));

                // ...
                var state = (AppBarState)NativeMethods.SHAppBarMessage(AppBarMessages.ABM_GETSTATE, ref appBarData);
                if ((state & AppBarState.ABS_AUTOHIDE) != 0)
                {
                    rectangle.Bottom -= 1;
                }

                // ...
                Marshal.StructureToPtr(rectangle, m.LParam, true);
            }

            // ...
            m.Result = IntPtr.Zero;
        }
Exemple #16
0
 static extern IntPtr SHAppBarMessage(AppBarMessage message, ref AppBarData appBarData);
Exemple #17
0
 internal static extern IntPtr SHAppBarMessage(uint dwMessage, ref AppBarData pData);
Exemple #18
0
            public override void InvokeTask()
            {
                AppBarPreference preference;

                if (!managedAppBars.TryGetValue(TargetWindow, out preference))
                {
                    return;
                }
                uint style        = GetWindowLong(TargetWindow, WindowLongIndex.Style);
                bool isFullScreen = ((style & (uint)WindowStyle.Popup) != 0);

                if (!isFullScreen)
                {
                    style &= ~(uint)(WindowStyle.Caption | WindowStyle.ThickFrame | WindowStyle.SystemMenu);
                    SetWindowLong(TargetWindow, WindowLongIndex.Style, style);
                    style  = GetWindowLong(TargetWindow, WindowLongIndex.ExtendedStyle);
                    style |= (uint)(WindowStyleExtended.WindowEdge | WindowStyleExtended.TopMost);
                    SetWindowLong(TargetWindow, WindowLongIndex.ExtendedStyle, style);
                }
                int        scrWidth  = GetSystemMetrics(SystemMetric.PrimaryScreenWidth);
                int        scrHeight = GetSystemMetrics(SystemMetric.PrimaryScreenHeight);
                AppBarData data      = new AppBarData(TargetWindow);

                data.Edge          = preference.DockingPosition;
                data.Bounds.Left   = 0;
                data.Bounds.Right  = scrWidth;
                data.Bounds.Top    = 0;
                data.Bounds.Bottom = scrHeight;
                SHAppBarMessage(AppBarMessage.QueryPosition, ref data);
                switch (data.Edge)
                {
                case AppBarEdge.Left:
                    data.Bounds.Right = Math.Min(
                        data.Bounds.Right,
                        data.Bounds.Left + (int)(scrWidth * preference.Width));
                    break;

                case AppBarEdge.Right:
                    data.Bounds.Left = Math.Max(
                        data.Bounds.Left,
                        data.Bounds.Right - (int)(scrWidth * preference.Width));
                    break;

                case AppBarEdge.Top:
                    data.Bounds.Bottom = Math.Min(
                        data.Bounds.Bottom,
                        data.Bounds.Top + (int)(scrHeight * preference.Height));
                    break;

                case AppBarEdge.Bottom:
                    data.Bounds.Top = Math.Max(
                        data.Bounds.Top,
                        data.Bounds.Bottom - (int)(scrHeight * preference.Height));
                    break;
                }
                SHAppBarMessage(AppBarMessage.SetPosition, ref data);
                preference.DockingPosition = data.Edge;
                if (!isFullScreen)
                {
                    SetWindowPos(TargetWindow, IntPtr.Zero,
                                 data.Bounds.Left, data.Bounds.Top,
                                 data.Bounds.Right - data.Bounds.Left,
                                 data.Bounds.Bottom - data.Bounds.Top,
                                 SetWindowPosFlags.NoZOrder | SetWindowPosFlags.NoActivate);
                }
                if (!hasCleanUpStarted && Recurs)
                {
                    Thread recurThread = new Thread(RecurCommand);
                    recurThread.IsBackground = true;
                    recurThread.Start(this);
                }
            }
Exemple #19
0
 public static AppBarData Create()
 {
     AppBarData appBarData = new AppBarData { cbSize = Marshal.SizeOf(typeof(AppBarData)) };
     return appBarData;
 }
Exemple #20
0
        public static TaskBarEdge GetTaskBarEdge()
        {
            AppBarData appBar = GetTaskBarData();

            return((TaskBarEdge)appBar.Edge);
        }
Exemple #21
0
        public static IntPtr GetHandle()
        {
            AppBarData appBar = GetTaskBarData();

            return(appBar.Handle);
        }
Exemple #22
0
 static extern IntPtr SHAppBarMessage(int msg, ref AppBarData data);
Exemple #23
0
 static extern IntPtr SHAppBarMessage(uint dwMessage, [In] ref AppBarData pData);
Exemple #24
0
 static extern UInt32 SHAppBarMessage(UInt32 dwMessage, ref AppBarData pData);
Exemple #25
0
        private static AppBarData CreateAppBarData()
        {
            AppBarData appBar = new AppBarData();

            appBar.Handle = FindWindow("Shell_TrayWnd", "");
            appBar.Size = Marshal.SizeOf(appBar);

            return appBar;
        }
Exemple #26
0
        /// <summary>
        /// 计算rebar正常位置
        /// </summary>
        /// <returns></returns>
        public reBarInfo CalcRebarPos()
        {
            System.Drawing.Rectangle screenRect = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;
            RECT rcBar, rcTrayBtn, rcStart;
            reBarInfo rbInfo = new reBarInfo();

            try
            {
                IntPtr hTaskbar = API.FindWindow("Shell_TrayWnd", null);
                IntPtr hBar = API.FindWindowEx(hTaskbar, IntPtr.Zero, "ReBarWindow32", null);
                IntPtr hTray = API.FindWindowEx(hTaskbar, IntPtr.Zero, "TrayNotifyWnd", null);
                IntPtr hTrayBtn = API.FindWindowEx(hTray, IntPtr.Zero, "Button", null);
                IntPtr hStart = API.FindWindowEx(hTaskbar, IntPtr.Zero, "Button", null);
                API.GetWindowRect(hStart, out rcStart);
                API.GetWindowRect(hBar, out rcBar);
                API.GetWindowRect(hTrayBtn, out rcTrayBtn);
                rbInfo.hreBar = hBar;
                rbInfo.hTaskBar = hTaskbar;

                AppBarData taskbarInfo = new AppBarData();
                API.SHAppBarMessage(0x00000005, ref taskbarInfo);

                switch (taskbarInfo.uEdge)
                {
                    case 0:
                    case 2:////任务栏在右边
                        rbInfo.x = 0;
                        rbInfo.y = rcBar.Left;
                        rbInfo.height = rcTrayBtn.Top - rbInfo.y;
                        rbInfo.width = rcBar.Right - rcBar.Left;
                        break;
                    case 1:
                    case 3:////任务栏在下边
                        rbInfo.x = rcBar.Top;
                        rbInfo.y = 0;
                        rbInfo.height = rcBar.Bottom - rcBar.Top;
                        rbInfo.width = rcTrayBtn.Left - rbInfo.x;
                        break;
                }
            }
            catch
            { }

            return rbInfo;
        }
 private static extern IntPtr SHAppBarMessage(AppBarMessages dwMessage, [In] ref AppBarData pData);
Exemple #28
0
        public static TaskBarState GetTaskBarState()
        {
            AppBarData appBar = CreateAppBarData();

            return((TaskBarState)SHAppBarMessage(AbMsg.GetState, ref appBar));
        }
Exemple #29
0
 private static extern int SHAppBarMessage(
     int flag,
     ref AppBarData abd);
Exemple #30
0
 public static extern uint SHAppBarMessage(int dwMessage, ref AppBarData pData);
Exemple #31
0
 private static extern IntPtr SHAppBarMessage(AbMsg dwMessage, [In, Out] ref AppBarData pData);
Exemple #32
0
        public static Point GetTaskBarLocation()
        {
            AppBarData appBar = GetTaskBarData();

            return(new Point(appBar.Rectangle.left, appBar.Rectangle.top));
        }
            public Taskbar()
            {
                var taskbarHandle = User32.FindWindow(ClassName, null);

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

                //Get DPI SCALE VALUE
                var source = PresentationSource.FromVisual(Application.Current.MainWindow)?.CompositionTarget?.TransformToDevice;
                var dpiScale = (source?.M11 ?? 1.0) - 1;

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

                Size = new double[2];
                Size[0] = Bounds.Width - Bounds.Width*dpiScale;
                Size[1] = Bounds.Height - Bounds.Height*dpiScale;

                data.cbSize = (uint)Marshal.SizeOf(typeof(AppBarData));
                result = Shell32.SHAppBarMessage(Abm.GetState, ref data);
                var state = result.ToInt32();
                AlwaysOnTop = (state & Abs.AlwaysOnTop) == Abs.AlwaysOnTop;
                AutoHide = (state & Abs.Autohide) == Abs.Autohide;
            }
Exemple #34
0
        public static Size GetTaskBarSize()
        {
            AppBarData appBar = GetTaskBarData();

            return(new Size(appBar.Rectangle.right - appBar.Rectangle.left, appBar.Rectangle.bottom - appBar.Rectangle.top));
        }
Exemple #35
0
        /// <summary>
        /// 根据任务栏位置计算窗体和主按钮位置
        /// </summary>
        /// <param name="mainWindowHeight">主窗体高度</param>
        /// <param name="mainWindowWidth">主窗体宽度</param>
        public AppPos CalcAppPos(double mainWindowHeight, double mainWindowWidth)
        {
            System.Drawing.Rectangle screenRect = System.Windows.Forms.Screen.PrimaryScreen.WorkingArea;
            RECT rcBar, rcTrayBtn, rcStart;
            AppPos pos = new AppPos();

            try
            {
                #region
                IntPtr hTaskbar = API.FindWindow("Shell_TrayWnd", null);
                IntPtr hBar = API.FindWindowEx(hTaskbar, IntPtr.Zero, "ReBarWindow32", null);
                IntPtr hTray = API.FindWindowEx(hTaskbar, IntPtr.Zero, "TrayNotifyWnd", null);
                IntPtr hTrayBtn = API.FindWindowEx(hTray, IntPtr.Zero, "Button", null);
                IntPtr hStart = API.FindWindowEx(hTaskbar, IntPtr.Zero, "Button", null);
                API.GetWindowRect(hStart, out rcStart);
                API.GetWindowRect(hBar, out rcBar);
                API.GetWindowRect(hTrayBtn, out rcTrayBtn);
                pos.rebarInfo.hreBar = hBar;
                pos.rebarInfo.hTaskBar = hTaskbar;

                AppBarData taskbarInfo = new AppBarData();
                API.SHAppBarMessage(0x00000005, ref taskbarInfo);
                int max_size = 40;

                switch (taskbarInfo.uEdge)
                {
                    #region
                    //case 0:////任务栏在左边
                    //    pos.main_left = taskbarInfo.rc.Right + 3;
                    //    pos.main_top = taskbarInfo.rc.Top + 30;
                    //    pos.btn_size = rcBar.Right - rcBar.Left > max_size ? max_size : rcBar.Right - rcBar.Left;
                    //    pos.btn_x = (rcBar.Right - rcBar.Left - pos.btn_size) / 2;
                    //    pos.btn_y = StartSize;

                    //    pos.rebarInfo.x = 0;
                    //    pos.rebarInfo.y = pos.btn_y + pos.btn_size;
                    //    pos.rebarInfo.height = rcTrayBtn.Top - pos.rebarInfo.y;
                    //    pos.rebarInfo.width = rcBar.Right - rcBar.Left;
                    //    break;
                    //case 1:////任务栏在上边
                    //    pos.main_left = taskbarInfo.rc.Left + 30;
                    //    pos.main_top = taskbarInfo.rc.Bottom + 3;
                    //    pos.btn_size = rcBar.Bottom - rcBar.Top > max_size ? max_size : rcBar.Bottom - rcBar.Top;
                    //    pos.btn_x = StartSize;
                    //    pos.btn_y = (rcBar.Bottom - rcBar.Top - pos.btn_size) / 2;

                    //    pos.rebarInfo.x = pos.btn_x + pos.btn_size;
                    //    pos.rebarInfo.y = 0;
                    //    pos.rebarInfo.height = rcBar.Bottom - rcBar.Top;
                    //    pos.rebarInfo.width = rcTrayBtn.Left - pos.rebarInfo.x;
                    //    break;
                    //case 2:////任务栏在右边
                    //    pos.main_left = screenRect.Right - mainWindowWidth - 3;
                    //    pos.main_top = taskbarInfo.rc.Top + 30;
                    //    pos.btn_size = rcBar.Right - rcBar.Left > max_size ? max_size : rcBar.Right - rcBar.Left;
                    //    pos.btn_x = (rcBar.Right - rcBar.Left - pos.btn_size) / 2;
                    //    pos.btn_y = StartSize;

                    //    pos.rebarInfo.x = 0;
                    //    pos.rebarInfo.y = pos.btn_y + pos.btn_size;
                    //    pos.rebarInfo.height = rcTrayBtn.Top - pos.rebarInfo.y;
                    //    pos.rebarInfo.width = rcBar.Right - rcBar.Left;
                    //    break;
                    case 3:////任务栏在下边
                        pos.main_left = taskbarInfo.rc.Left + 30;
                        pos.main_top = screenRect.Bottom - mainWindowHeight - 3;
                        pos.btn_size = (rcBar.Bottom - rcBar.Top) > max_size ? max_size : (rcBar.Bottom - rcBar.Top);
                        pos.btn_x = rcBar.Left;
                        pos.btn_y = (rcBar.Bottom - rcBar.Top - pos.btn_size) / 2;

                        pos.rebarInfo.x = rcBar.Left + pos.btn_size;
                        pos.rebarInfo.y = 0;
                        pos.rebarInfo.height = rcBar.Bottom - rcBar.Top;
                        pos.rebarInfo.width = rcTrayBtn.Left - pos.rebarInfo.x;
                        break;
                    default:
                        pos = new AppPos()
                        {
                            main_left = (screenRect.Width - mainWindowWidth) / 2,
                            main_top = (screenRect.Height - mainWindowHeight) / 2,
                            btn_size = -1,
                            btn_x = -1,
                            btn_y = -1
                        };
                        break;
                        #endregion
                }
                #endregion
            }
            catch
            {
                pos = new AppPos()
                {
                    main_left = (screenRect.Width - mainWindowWidth) / 2,
                    main_top = (screenRect.Height - mainWindowHeight) / 2,
                    btn_size = -1,
                    btn_x = -1,
                    btn_y = -1
                };
            }

            return pos;
        }
Exemple #36
0
 public static extern IntPtr SHAppBarMessage(Abm msg, ref AppBarData data);
Exemple #37
0
 public static extern UInt32 SHAppBarMessage(ABM dwMessage, ref AppBarData pData);
 static extern IntPtr SHAppBarMessage(int msg, ref AppBarData data);