c#控制系統工作列的自動隱藏與顯示

來源:互聯網
上載者:User

public struct RECT
    {
        public int Left;
        public int
Top;
        public int Right;
        public int Bottom;
    }
   
public struct APPBARDATA
    {
        public int cbSize;
       
public int hwnd;
        public int uCallbackMessage;
        public int
uEdge;
        public RECT rc;
        public int lParam;
    }

        public const int ABS_ALWAYSONTOP = 0x002;
        public const int
ABS_AUTOHIDE = 0x001;
        public const int ABS_BOTH = 0x003;
       
public const int ABM_ACTIVATE = 0x006;
        public const int ABM_GETSTATE
= 0x004;
        public const int ABM_GETTASKBARPOS = 0x005;
       
public const int ABM_NEW = 0x000;
        public const int ABM_QUERYPOS =
0x002;
        public const int ABM_SETAUTOHIDEBAR = 0x008;
        public
const int ABM_SETSTATE = 0x00A;

        ///
        /// 向系統工作列發送訊息
        ///

        [DllImport("shell32.dll")]
        public static extern
int SHAppBarMessage(int dwmsg, ref APPBARDATA app);

        [DllImport("user32.dll", EntryPoint = "FindWindow")]
       
public static extern int FindWindow(string lpClassName, string
lpWindowName);

        ///
        /// 設定系統工作列是否自動隱藏
        ///

        ///

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);
            }
        }

 

在XP與2003系統下測試通過!

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.