c#實現工作列添加控制按鈕

來源:互聯網
上載者:User

標籤:des   style   blog   http   color   使用   io   檔案   

Windows7Taskbar的使用

你需要引入3個檔案VistaBridgeLibrary.dll、Windows7.DesktopIntegration.dll、Windows7.DesktopIntegration.Registration.exe

:http://yunpan.cn/QauRaNK4H3BYW (提取碼:fe58)

裡面封裝好的類:Windows7Taskbar、ThumbButtonManager、ThumbButton、JumpListManager、RegistrationHelper等等

Windows7Taskbar用於註冊及初始化,ThumbButtonManager管理ThumbButton,包括建立添加按鈕,JumpListManager記錄,RegistrationHelper關聯檔案類型

實現步驟:

1.引用

using Windows7.DesktopIntegration;
using Windows7.DesktopIntegration.WindowsForms;

2.初始化(表單Load時)

Windows7Taskbar.AllowTaskbarWindowMessagesThroughUIPI();
Windows7Taskbar.SetCurrentProcessAppId("TaskbarManaged");//裡面的參數自訂

3.建立按鈕

ThumbButtonManager buttonManager=this.CreateThumbButtonManager();ThumbButton taskbarBtnPause = buttonManager.CreateThumbButton(101, Properties.Resources.playtask, "播放");taskbarBtnPause.Clicked += (sender, e) =>{  btnPlay_PictureClick(sender, e);  if (IsPlay == true)//這裡判斷是否在播放,更新表徵圖  {    taskbarBtnPause.Icon = Properties.Resources.playtask;  }  else  {    taskbarBtnPause.Icon = Properties.Resources.pausetask;  }
};
buttonManager.AddThumbButtons(taskbarBtnPause);

4.捕獲資訊

protected override void WndProc(ref Message m)
{  if (buttonManager != null)   buttonManager.DispatchMessage(ref m);  base.WndProc(ref m);
}

需要注意的是:

最多7個button, 沒有方法添加或刪除一個按鈕,在你初始化以後, 只能讓它不可用或隱藏.可以調用ThumbBarAddButtons和ThumbBarUpdateButtons方法來控制工具列.

在表單的Load時間裡添加ThumbButton不會起作用,這就是為什麼我不在表單Load時添加ThumbButton的原因,並且每個ThumbButton都有一個ID,這個ID是你自己分配的,不能重複

遇到的問題:

我給taskbarBtnPause.Clicked添加了一個處理事件,也就是改變表徵圖,結果是當觸發該事件時ThumbButton的屬性Icon修改了,但是介面沒有更新

 

本文地址:http://www.cnblogs.com/liuxiaobo93/p/3914424.html 暮雨冰藍

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.