當前位置: 首頁>>代碼示例>>C#>>正文


C# APPBARDATA類代碼示例

本文整理匯總了C#中APPBARDATA的典型用法代碼示例。如果您正苦於以下問題:C# APPBARDATA類的具體用法?C# APPBARDATA怎麽用?C# APPBARDATA使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


APPBARDATA類屬於命名空間,在下文中一共展示了APPBARDATA類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetTaskbarState

 /// <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);
 }
開發者ID:mind0n,項目名稱:hive,代碼行數:11,代碼來源:Taskbar.cs

示例2: Taskbar

			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 + "-------------------");*/
			}
開發者ID:w01f,項目名稱:VolgaTeam.Dashboard,代碼行數:29,代碼來源:TaskBarHelper.cs

示例3: SetAppBar

        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);
        }
開發者ID:jdugdale,項目名稱:leftfork-soup,代碼行數:35,代碼來源:AppBar.cs

示例4: GetTaskbar

        /// <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);
        }
開發者ID:BroneKot,項目名稱:FTPbox,代碼行數:11,代碼來源:Win32.cs

示例5: SetTaskbarState

 /// <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);
 }
開發者ID:mind0n,項目名稱:hive,代碼行數:12,代碼來源:Taskbar.cs

示例6: GetTaskBarInfo

        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();
        }
開發者ID:bsandru,項目名稱:tasksharp,代碼行數:9,代碼來源:AppBar.cs

示例7: GetScreenHeight

        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;
        }
開發者ID:bradrees,項目名稱:HttpRules,代碼行數:10,代碼來源:AppBarFunctions.cs

示例8: ABSetPos

        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);
        }
開發者ID:Zagrebelin,項目名稱:SideBar,代碼行數:55,代碼來源:AppBarFunctions.cs

示例9: show

        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);
        }
開發者ID:umhr,項目名稱:TaskbarHide,代碼行數:11,代碼來源:Program.cs

示例10: GetTaskbarPosition

        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;
        }
開發者ID:AdditionalPylons,項目名稱:AudioSwitch,代碼行數:12,代碼來源:WindowPosition.cs

示例11: hide

        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);
        }
開發者ID:umhr,項目名稱:TaskbarHide,代碼行數:13,代碼來源:Program.cs

示例12: GetPosition

 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");
     }
 }
開發者ID:vanloc0301,項目名稱:mychongchong,代碼行數:13,代碼來源:AppBarInfo.cs

示例13: button1_Click

        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();
        }
開發者ID:EsProgram,項目名稱:TaskbarSwitch,代碼行數:14,代碼來源:Form1.cs

示例14: button2_Click

        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();
        }
開發者ID:EsProgram,項目名稱:TaskbarSwitch,代碼行數:14,代碼來源:Form1.cs

示例15: SetAppBarAutoDisplay

 /// 
 /// 設置係統任務欄是否自動隱藏
 /// 
 ///  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);
     }
 }
開發者ID:jimidzj,項目名稱:Inspect,代碼行數:22,代碼來源:SetAppBarAutoDisplay.cs


注:本文中的APPBARDATA類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。