向表单添加边框图标
使用 Delphi 我想向边框图标按钮添加另一个按钮;关闭、最大化、最小化。关于如何做到这一点有什么想法吗?
Using Delphi I would like to add another button to the border icon buttons; close, maximize, minimize. Any ideas on how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在 Windows Aero 出现之前,这很容易做到。您只需监听
WM_NCPAINT
和WM_NCACTIVATE
消息即可在标题栏顶部进行绘制,类似地,您可以使用其他WM_NC*
响应鼠标点击等的消息,特别是WM_NCHITTEST
、WM_NCLBUTTONDOWN
和WM_NCLBUTTONUP
。例如,要在标题栏上绘制字符串,您只需执行“
现在,这在启用 Aero 的情况下不起作用”。尽管如此,还是有一种方法可以在标题栏上绘图;我已经这样做了,但它要复杂得多。有关工作示例,请参阅本文 。
This was easy to do prior to Windows Aero. You simply had to listen to the
WM_NCPAINT
andWM_NCACTIVATE
messages to draw on top of the caption bar, and similarly you could use the otherWM_NC*
messages to respond to mouse clicks etc, in particularWM_NCHITTEST
,WM_NCLBUTTONDOWN
, andWM_NCLBUTTONUP
.For instance, to draw a string on the title bar, you only had to do
Now, this doesn't work with Aero enabled. Still, there is a way to draw on the caption bar; I have done that, but it is far more complicated. See this article for a working example.
Chris Rolliston 撰写了有关 在 Vista 和 Windows 7 上创建自定义标题栏。
他还写了一篇后续文章 并在 CodeCentral 上发布了示例代码。
Chris Rolliston wrote a detailed blog about creating a custom title bar on Vista and Windows 7.
He also wrote a follow up article and posted example code on CodeCentral.
是的,将表单的边框样式属性设置为 bsNone 并使用您喜欢的所有按钮和自定义行为实现您自己的标题栏。
Yes, set the form's border style property to bsNone and implement your own title bar with all the buttons and custom behaviour you like.