绘制在Windows Vista / 7的Aero标题栏自定义按钮 [英] Draw Custom Buttons on Windows Vista/7 Aero Titlebar

查看:893
本文介绍了绘制在Windows Vista / 7的Aero标题栏自定义按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现的计算器绘制自定义按钮。基本上,用户想画的标题栏自定义按钮。

I found this question on StackOverflow. Basically, the user wanted to draw custom buttons on the titlebar.

我试过的代码,并意识到它在Vista中工作/ 7,只有当Aero是禁用的。我的问题是,有没有办法在启用航空吸取标题栏的自定义按钮?

I tried the code and realised it works in vista/7 only when Aero is disabled. My question is, is there any way to draw custom buttons on the titlebar while aero is enabled?

此外,有没有阅读任何方式从目前的主题信息,以便我可以风格我的按钮相匹配的已经存在的。

Also, is there any way of reading information from the current theme so I can style my buttons to match the already existing ones.

更新

下面是从我的电脑演示上述概念的屏幕截图。我是在安装后DisplayFusion得到了额外的标题栏按钮。结果

Here is a screenshot from my computer demonstrating the above concept. I got the additional titlebar buttons after installing DisplayFusion.

我知道DisplayFusion是一个.NET程序,因为它在.net反射打开。不利的一面是,该程序进行模糊处理。不像我想反编译程序或任何东西;我只想一个按钮添加到我的标题栏做别的事情(比如最小化到系统托盘实例)。结果
下面是截图,证明该方案是一个.NET应用程序。结果

And I know DisplayFusion is a .NET program because it opens in .NET Reflector. The down side is that the program is obfuscated. Not like I wanted to decompile the program or anything; I just want to add a button to my titlebar to do something else (like minimise to the system tray for instance).
Below is the screenshot, proving the program is a .NET app.

推荐答案

我做了一些研究,这是我在我自己的多屏解决方案来实现这一点。方式DisplayFusion和TeamViewer实现这在包含按钮选择所需的窗口覆盖自定义表单。您可以使用间谍++证实了这一点。

I did some research into this as I implemented this too in my own multi-monitor solution. The way DisplayFusion and TeamViewer implemented this is overlaying a custom form over the desired window containing the buttons. You can use Spy++ to confirm this.

这是总体思路:


  1. 写的时候创建窗口,删除,激活,重新定位或调整得到通知的DLL钩

  2. 使用transparancy键或使用本的字母PNG和GDI +解决方案以及模拟按钮(s)的画你自己。

  3. 在窗口创建/移除你显示/隐藏所需窗口(S)你titlebarbutton形式。

  4. 在窗口调整大小/重新定位的消息,你重新调整你的titlebarbutton形式。

  5. 在窗口激活你设置窗口的Z位置,使其所需的窗口顶部。

  1. Write a DLL hook for getting notified when a window is created, removed, activated, repositioned or resized.
  2. Make a transparant form using transparancy key or using this alpha-PNG and GDI+ solution and simulate the button(s) by painting it your own.
  3. On window creation/removal you show/hide your titlebarbutton form for the desired window(s).
  4. On window resize/reposition messages you realign your titlebarbutton form.
  5. On window activation you set the Z position of the window so that it is on top of the desired window.

获取和设置通过Z位置的 GetWindow SetWindowPos 的API。结果
请注意,DLL必须在本地语言编写。然而,你面包车使用这样的事情来解决这个问题:
使用窗口消息来实现全球系统钩子在C#

Getting and setting the Z position through the GetWindow and SetWindowPos API's.
Be aware that the DLL must be written in a native language. However you van use something like this to work around that problem: Using Window Messages to Implement Global System Hooks in C#

和这里是我的结果:

这篇关于绘制在Windows Vista / 7的Aero标题栏自定义按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆