【问题标题】:Button has black background on Windows 7按钮在 Windows 7 上具有黑色背景
【发布时间】:2017-01-16 14:48:04
【问题描述】:

我目前正在将针对 WIndows XP 和 Server 2003 的应用程序迁移到 Windows 7(及更高版本)。大多数应用程序运行良好,但某些按钮在 Windows 7 中具有黑色背景。

Windows XP

Windows 7

该应用程序面向 Visual Studio 2005 中的 .NET v2.0(一旦迁移到 Windows 7 完成,我们将迁移到更高版本的 .NET 和 Visual Studio)。可用的属性似乎都没有帮助。以下是我认为可能相关的属性列表(在 XP 和 7 上相同):

BackColor = ActiveCaptionText
BackgroundImage = (none)
TileBackgroundImageLayout = Tile
ForeColor = ControlText
TextImageRelation = Overlay
UseVisualStyleBackColor = False (changing to True doesn't help)

需要做什么才能让按钮看起来像在 Windows XP 上的样子?

【问题讨论】:

  • 您将按钮颜色设置为操作系统定义的 ActiveCaptionText。显然在这台机器上颜色是黑色的。手动将颜色设置为 Color.Grey 或任何 RGB 值。

标签: c# windows c#-2.0


【解决方案1】:

ActiveCaption 颜色在 SystemColors 类中定义。这些是在操作系统中设置的。

http://msdn.microsoft.com/en-us/library/system.drawing.systemcolors.aspx

活动标题是活动窗口标题栏的背景颜色。

我认为您需要将 BackColor 属性更改为 Control 以使您的表单看起来像您想要的那样:

BackColor = SystemColors.Control;

或任何其他想要的颜色。

【讨论】:

  • 行得通!学习系统颜色的定义可以在 Windows 版本之间更改的好教训。
猜你喜欢
  • 2011-03-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-23
  • 1970-01-01
相关资源
最近更新 更多