using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Windows7.DesktopIntegration; namespace Windows7Test { public partial class Form1 : Form { public Form1() { InitializeComponent(); } ThumbButtonManager _thumbButtonManager; protected override void WndProc(ref Message m) { // … // 转发消息 if (m.Msg == Windows7Taskbar.TaskbarButtonCreatedMessage) { // 切换状态 if (_thumbButtonManager != null) { _thumbButtonManager = null; } else { // 创建ThumbButtonManager对象 _thumbButtonManager = new ThumbButtonManager(Handle); //创建工具栏按钮 ThumbButton button = _thumbButtonManager.CreateThumbButton(101, global::Windows7Test.Properties.Resources.上一曲_正常, "上一曲"); // 处理按钮点击消息 button.Clicked += delegate { MessageBox.Show("上一曲", "提示"); }; ThumbButton button2 = _thumbButtonManager.CreateThumbButton(102, global::Windows7Test.Properties.Resources.播放_正常, "播放"); // 处理按钮点击消息 button2.Clicked += delegate { MessageBox.Show("播放", "提示"); }; ThumbButton button3 = _thumbButtonManager.CreateThumbButton(103, global::Windows7Test.Properties.Resources.下一曲_正常, "下一曲"); // 处理按钮点击消息 button3.Clicked += delegate { MessageBox.Show("下一曲", "提示"); }; // 将按钮添加到缩略图工具栏中 _thumbButtonManager.AddThumbButtons(button, button2, button3); } } if (_thumbButtonManager != null) _thumbButtonManager.DispatchMessage(ref m); base.WndProc(ref m); } private void Form1_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { } } }