更改应用程序标题栏的颜色

发布于 2024-08-16 17:47:11 字数 108 浏览 3 评论 0原文

使用Delphi 7尝试从窗口主题更改软件标题栏的颜色。我见过允许您更改所有程序的所有标题栏的代码,但我只想更改我的程序。

有人见过/做过这样的事情吗?如果需要的话,不介意支付组件费用。

With Delphi 7 trying to change the color of the title bar of the software from the window theme. I have seen code which allows you to change ALL the title bars of all programs, but I am just wanting to change my program.

Anyone seen/done anything like this? Don't mind paying for a component if needed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

来日方长 2024-08-23 17:47:11

我相信 Windows 将 WM_NCPAINT 消息发送到应用程序何时应绘制窗口框架(包括标题栏)。默认行为是回退到绘制默认框架的默认 Windows 处理程序。您可以替换它,或者在之后重新绘制标题栏部分。

这看起来是一个很好的例子: http://delphi.about.com/od /adptips2006/qt/draw_captionbar.htm

I believe Windows sends the WM_NCPAINT message to an application when it should paint the window frame including the title bar. The default behaviour is to fall back to the default Windows handler which draws the default frame. You could replace this, or re-paint the title-bar section right after.

This looks like a good example: http://delphi.about.com/od/adptips2006/qt/draw_captionbar.htm

无所谓啦 2024-08-23 17:47:11

Stijn 的答案并不完全完整,因为当窗口被(取消)激活时,窗口的标题和边框也会被重新绘制。因此,除了 WM_NCPAINT 之外,您还需要处理 WM_NCACTIVATE。不幸的是,这不能简单地替换,因为默认消息处理程序中还有其他代码(除了绘图代码)需要执行。但是调用默认处理程序将导致首先绘制默认标题和边框,然后您需要用您想要的颜色绘制它们,从而导致闪烁。

解决此问题的一种方法是调整调用默认消息处理程序所用的绘图区域。请参阅“绘图标题栏在带有主题的 XP 上”,这是一个使用 Windows API 调用的示例,可以轻松地转换为 Delphi。请注意,这仅处理标题栏中的文本,但原则适用。

The answer by Stijn is not fully complete, as the caption and border of the window will also be redrawn when it is (de-)activated. So in addition to WM_NCPAINT you will also need to handle WM_NCACTIVATE. Unfortunately this can not simply be replaced, as there is other code in the default message handler (apart from drawing code) that needs to be executed. But calling the default handler will in turn lead to the default caption and border being drawn first, which you would then need to draw over with your intended colour, resulting in flicker.

One way to work around this is to adjust the drawing region that the default message handler is called with. See "Drawing titlebar on XP with themes" for an example using Windows API calls that should easily translate to Delphi. Note that this deals only with the text in the caption bar, but the principle applies.

暮倦 2024-08-23 17:47:11

您可能会看一下蒙皮库。 DevExpress 的 ExpressSkin 是一个不错的选择。

You might take a look at a skinning library. ExpressSkin by DevExpress is a good one.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文