简体   繁体   English

为什么在Win Classic主题中TabControl的背景不会改变颜色?

[英]Why in Win Classic theme TabControl's background doesn't change the colour?

In Win7 theme it works good, but in win classic theme it looks weird. 在Win7主题中,效果很好,但在经典主题中,它看起来很奇怪。

In Win 7 theme : 在Win 7主题中: 在此处输入图片说明

In Win Classic theme: 在Win Classic主题中:

在此处输入图片说明

Is there any chance to fix this ? 有没有机会解决这个问题?

This is by design. 这是设计使然。 It doesn't have anything to do with "change the colour", it is actually a transparency effect. 它与“更改颜色”没有任何关系,实际上是透明效果。 The window is rectangular and not shaped to fit the tabs. 窗口是矩形的,并且形状不适合选项卡。 The control first paints the space for the tabs by asking the parent window to draw itself, passing its own window handle. 该控件首先通过要求父窗口绘制自身并传递其自己的窗口句柄来绘制选项卡的空间。 Then draws the tabs on top of that. 然后在其上方绘制选项卡。 You can see this by setting the parent's BackgroundImage property. 您可以通过设置父级的BackgroundImage属性来查看此内容。 Also the way that, say, the Label and PictureBox controls simulate transparency. 另外,例如Label和PictureBox控件模拟透明度的方式。

This is behavior implemented by the visual styles renderer. 这是视觉样式渲染器实现的行为。 Windows Classic doesn't use any transparency effects. Windows Classic不使用任何透明效果。

If this is really important to you then do consider WPF. 如果这对您确实很重要,请考虑使用WPF。 It doesn't use a window for its controls and is thus not affected by the selected theme. 它不使用窗口作为控件,因此不受所选主题的影响。

If you really want your own style-independent customized tab, draw the tab yourself using OwnerDrawFixed . 如果您确实想要自己的与样式无关的自定义标签,请使用OwnerDrawFixed 自己绘制标签 See an example on codeproject . 请参阅codeproject上的示例

Curtis Schlak的“自定义”选项卡控件。

Its the same question as go to How to change the background color of unused space tab in C# winforms? 如何更改C#winforms中未使用的空格选项卡的背景色的问题相同

you've to overload the OnPaintBackground method 您必须重载OnPaintBackground方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM