windows 如何向窗口标题栏添加一个额外的按钮,使其成为标准?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5571072/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to add an extra button to the window title bar, so it will be work as standard?
提问by Anton Semenov
Firstly I want mention that I have already read all articles on SO on subject, but still have no answer for my question. Also my question slightly different than others.
Today a I have a look on Skype window. There is one extra button on it's title bar. But this button acts as native system button. Just look on glowing, it spreads out of the window. So I have the reasonable question. According to that we can see on the picture below, there is standard way to add extra button on title bar. But all answers on subj leads to hooking of WM_NCPAINT
event and manual drawing of extra button. This approach is work but it could not yield such beautifull glowing as on the picture.
Does anybody knows the way to add standartized button on window's title bar?
Thanks in advance!
首先,我想提一下,我已经阅读了所有关于 SO 主题的文章,但仍然没有回答我的问题。另外我的问题与其他人略有不同。
今天我看看Skype窗口。它的标题栏上有一个额外的按钮。但此按钮充当本机系统按钮。看着发光,它从窗外蔓延开来。所以我有一个合理的问题。据此我们可以在下图中看到,在标题栏上添加额外按钮的标准方法。但是 subj 上的所有答案都会导致WM_NCPAINT
事件的挂钩和额外按钮的手动绘制。这种方法是可行的,但它不能产生像图片上那样美丽的发光。
有人知道在窗口标题栏上添加标准化按钮的方法吗?提前致谢!
采纳答案by Jason Williams
In Vista and Windows 7 there is a new thing called the Desktop Window Manager. This is used to draw the "Aero glass" window titlebars, and do the glow effects. The old Windows XP approach of implementing WM_NCPAINT handlers doesn't work with this new system, so you have to use a whole new API.
在 Vista 和 Windows 7 中有一个叫做桌面窗口管理器的新东西。这用于绘制“航空玻璃”窗口标题栏,并制作发光效果。旧的 Windows XP 实现 WM_NCPAINT 处理程序的方法不适用于这个新系统,因此您必须使用全新的 API。
I'm sure I've seen some articles on doing what you're asking about, but can't find them right now. Some pages that might give you some leads are:
我确定我已经看过一些关于做你所问的事情的文章,但现在找不到它们。一些可能会给你一些线索的页面是:
回答by Jerry Coffin
Yes, this can be (and undoubtedly is) done by hooking WM_NCPAINT and painting their button in response to it. The "glowing" is just a matter of picking the appropriate color and shading (and possibly doing a bit of alpha blending to have some "glow" show up close to the button).
是的,这可以(毫无疑问是)通过挂钩 WM_NCPAINT 并响应它来绘制按钮来完成。“发光”只是选择适当的颜色和阴影的问题(并且可能进行一些 alpha 混合以使按钮附近出现一些“发光”)。