简体   繁体   English

如何设置标签控件的前色以匹配选定的Outlook主题?

[英]How to set the forecolor of a label control to match the selected outlook theme?

How do I set the color of my labels in a custom form region I developed for Outlook 2010 to match the user selected theme color? 如何在为Outlook 2010开发的自定义窗体区域中设置标签的颜色,以匹配用户选择的主题颜色? Please see picture below about the demonstration of what I'm trying to do. 请参见下面的图片,以演示我正在尝试做的事情。

I'm trying to match my custom form label forecolor to whatever the selected theme forecolor is of the Outlook instance. 我试图将自定义表单标签前景色与Outlook实例的选定主题前景色进行匹配。

尝试将控件的颜色与Outlook 2010用户选择的主题进行匹配

From what I can tell (and I may be wrong) Outlook gets its theme from Windows (unless you are meaning email or stationary theme. I would try that route. 据我所知(我可能是错的),Outlook从Windows获得了它的主题(除非您的意思是电子邮件或固定主题,我会尝试这种方法。

Update: Looking around some more I see if you go into an email and then Office Button -> Editor Options -> Theme you can choose between 3 default themes (blue, black and silver) but the only thing I can see that updates in the registry is the key at: 更新:环顾四周,我看到您是否收到电子邮件,然后进入Office按钮->编辑器选项->主题,您可以在3个默认主题(蓝色,黑色和银色)之间进行选择,但我唯一能看到的是注册表是关键:

HKCU\Software\Microsoft\Office\12.0\Common\Theme

I'm using Office 2007. The bad part is that it is just plugging in a hex number that appears to correspond to the theme but I don't see where one can find the mappings for this. 我正在使用Office2007。不好的地方是它只是插入一个看起来与主题相对应的十六进制数字,但我看不到在哪里可以找到该映射。

Expanding on Mike's post, 扩展Mike的职位,

this registry entry HKCU\\Software\\Microsoft\\Office\\12.0\\Common\\Theme 此注册表项HKCU \\ Software \\ Microsoft \\ Office \\ 12.0 \\ Common \\ Theme

There are only three options. 只有三个选项。

Values of 1 and 2 are black with a value of 3 is white for foreground. 值1和2为黑色,值3为前景白色。

Silver theme and Blue theme use black foreground. 银色主题和蓝色主题使用黑色前景。 Black theme uses white and black theme is a value of 3 黑色主题使用白色,黑色主题的值为3

I finally solved the problem by implementing the Paint event at the formregion level. 我终于通过在formregion级别实现Paint事件解决了这个问题。

private void FormRegion1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
    if (controlX.BackColor.ToArgb() == System.Drawing.Color.FromArgb(255, 0, 0, 0).ToArgb())
    {
        controlX.ForeColor = System.Drawing.Color.White;
    }
    else if (controlX.BackColor.ToArgb() == System.Drawing.Color.FromArgb(255, 255, 255, 255).ToArgb())
    {
        controlX.ForeColor = System.Drawing.Color.DarkGray;
    }
}

I beleive if you access the SetForeColor property of your label or what have you, you can do the following: 我相信如果您访问标签的SetForeColor属性或拥有的内容,可以执行以下操作:

label1.SetForeColor(SystemColors.Highlight);

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

also see: 另请参阅:

SystemColors.ActiveBorder
SystemColors.ActiveCaption
SystemColors.ActiveTextCaption

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

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