实现Thumbnail Toolbars,对最小化任务栏的图标点击按钮

实现Thumbnail Toolbars
如同win7系统中Windows Media Player播放器自动的功能一样,在最小化到任务栏,当你鼠标滑动到windows Media Player时,可以看到一个播放的按钮,如下图


 
在我们自己的程序中,我们可以添加按钮,并且对所添加的按钮添加不同的事件,下面进行一个简单的例子:


1.首先,这是用的Thumbnail Toolbars的功能,我们需要添加Microsoft.WindowsAPICodePack.DLL文件和Microsoft.WindowsAPICodePack.Shell.DELL文件


2.其次,我们需要添加几个引用PresentationCore.dll ,WindowsBase.dll 这两个系统内的Dll文件,需要到C盘的目录下进行查找,目录应该是在C:\Program Files (x86)

\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\PresentationCore.dll ,不添加这两个引用会报错“The type 'System.Windows.UIElement' is defined in an assembly that is not referenced.” 这里千万注意


3.接下来再Form_Load内添加对ThumbnailToolbarButton 的引用

        private void Form0106_Load(object sender, EventArgs e)
        {
            infoButton = new ThumbnailToolbarButton(SystemIcons.Information, "Information");
            infoButton.Click += infoButton_Click;
            infoButton.Visible = true;
            TaskbarManager.Instance.ThumbnailToolbars.AddButtons(this.Handle, infoButton);//必须添加这行代码,否则不会出现按钮
        }


4.接下里添加按钮事件,可以自己定义

        private void infoButton_Click(object sender, ThumbnailButtonClickedEventArgs e)
        {
            MessageBox.Show("Show Application Information");
        }


接下里就可以进行调试看到新添加的按钮了。


有以下几个比较好的参考链接
# [VB.Net] Adding ThumbnailToolbarButton's to Your Application
http://tech.reboot.pro/showthread.php?tid=270
# Working with Windows 7 Thumbnails
http://visualstudiomagazine.com/articles/2010/08/04/windows-7-thumbnails.aspx
# Taskbar Extensions
http://msdn.microsoft.com/en-us/library/windows/desktop/dd378460(v=vs.85).aspx
# Programming the Windows Vista DWM in C#
http://community.bartdesmet.net/blogs/bart/archive/2006/10/05/4495.aspx


______________________________________________________________________________________________________________________

欢迎大神光临菜鸟博客,希望能得到各位大神在编码方面的指引,同时欢迎与我一样刚进入编程世界的朋友一起讨论学习!相信前进的道路上,有你们,编程世界会更加精彩!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值