如何更改 TTabSheets 的背景颜色?
我正在使用 Delphi 2009 设计表单,并且正在尝试找出 TPageControl 元素。我试图为每个选项卡创建单独的对话框。我可以制作 TTabSheets,并且可以将元素放置在 TabSheets 上,但我的问题是它们是大麦可见的,因为 TTabSheet 的默认背景似乎是白色。我尝试在 TabSheet 上放置一个面板,但无论出于何种原因,该面板总是出现在 TabSheet 后面。所以我的问题是:有没有办法将标签页的颜色更改为标准的 Windows 米色,或者他们是否可以在标签页上放置 TPanel 来实现相同的目标?
Im Designing a Form with Delphi 2009, and Im trying to figure out the TPageControl element. Im trying to make separate dialogs for each tab. I can make the TTabSheets, and I can place my elements on the TabSheets, but my problem is that they are barley visible, as the default background for a TTabSheet appears to be white. Ive tried to place a panel on the TabSheet, but for whatever reason, the panel always appears behind the TabSheet. So my question: Is there any way to change the color of a tab sheet to the standard windows beige, or is their a way to place a TPanel on the tab page, accomplishing the same goal?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
将样式属性设置为 tsFlatButtons
背景〜颜色〜将恢复为美丽的clBtnFace
Set the style property to tsFlatButtons
The background ~colour~ will revert to beautiful clBtnFace
选项卡的标准 Windows 颜色是白色。该标准是在 XP 主题推出时应运而生的。如果用户切换回 Windows Classic,他们将看到灰色背景。 [你的意思是灰色而不是米色,不是吗?米色真的很卑鄙!]
选项卡内的面板永远不能位于页面后面,因为它位于页面内部。实际发生的情况是,面板被透明绘制,以便标准选项卡颜色占主导地位。
The standard Windows colour for a tab sheet is white. That standard came into being when XP themes were introduced. If a user switches back to Windows Classic then they will get a grey background. [You do mean grey rather than beige don't you? Beige would be truly vile!]
A panel inside a tab sheet can never be behind the page since it is inside the page. What is actually happening is that the panel is being drawn transparently so that the standard tab sheet colour prevails.
在您的表单中的界面中使用此单位:
Use this unit in your Form at the interface:
不太喜欢这两种解决方案,这就是我正在做的事情来阻止您遇到的问题。您不需要牺牲 Windows 主题来使其工作:
只需检查:
并设置表单的颜色,然后再将其显示在选项卡上。
(就我个人而言,我从来不喜欢这个解决方案,但这就是我在开始之前编写的程序的主要部分是如何编程的,因此为了使它在我的计算机异或终端服务器上看起来不像垃圾,这就是我必须做的)
ThemeServices 是在主题.pas中
Not liking either solution much, this is what I'm doing to thwart the problem you're having. You don't need to sacrifice windows themes to make it work:
just check:
and set the color of the form before you show it on your tabs.
(personally, I never liked this solution, but it's how a major part of the program I work on was programmed before I started, so to make it not look like crap on my compuer XOR terminal servers that's what I had to do)
ThemeServices is in themes.pas
如果您希望将 PageControl Style 属性保留为 tsTabs,那么您需要破解 TTabSheet 类...
在表单的类型声明上方添加以下内容...
然后在单元的实现部分...
最后创建和销毁你在单元的初始化和完成部分刷...
If you wish to preserve the PageControl Style property as tsTabs then you'll need to hack the TTabSheet class ...
Just above your form's type declaration add the following ...
Then in the unit's implementation section ...
And finally create and destroy your brush in the unit's initialization and finalization sections ...