0

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? 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.

Attempting to match the color of a control to the Outlook 2010 user selected theme

Magnum
  • 1,555
  • 4
  • 18
  • 39

4 Answers4

2

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.

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:

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.

Mike Cheel
  • 12,626
  • 10
  • 72
  • 101
0

Expanding on Mike's post,

this registry entry 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.

Silver theme and Blue theme use black foreground. Black theme uses white and black theme is a value of 3

Sorceri
  • 7,870
  • 1
  • 29
  • 38
0

I finally solved the problem by implementing the Paint event at the formregion level.

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;
    }
}
Barax
  • 113
  • 1
  • 1
  • 9
-1

I beleive if you access the SetForeColor property of your label or what have you, you can do the following:

label1.SetForeColor(SystemColors.Highlight);

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

also see:

SystemColors.ActiveBorder
SystemColors.ActiveCaption
SystemColors.ActiveTextCaption
jordan
  • 3,436
  • 11
  • 44
  • 75
  • thanks for the response. I tried this but it only pulls the window Highlight color (in my case "blue") which isn't what I needed. I think Mike's post has the answer, but I'm wondering if I really need to read the registry keys to figure out forecolor? – Magnum Jun 21 '13 at 07:26