Phil,
It depends if you just want the color, or want to draw UI items with
that same color. I'm not sure how the get the actual current theme
name.
An enabled TextBox has a BackColor of SystemColor.Control when
disabled, and SystemColor.Window when enabled.
If you are using .NET 2.0 you may look into the Theme-aware classes:
http://msdn2.microsoft.com/en-us/library/ms171733.aspx
For example, this code draws a rectangle that is the same color as a
disabled TextBox: See the other members of the VisualStyleElement
class for other supported objects.
using System;
using System.Text;
using System.Windows.Forms.VisualStyles;
using System.Windows.Forms;
using System.Drawing;
namespace ThemeTesting
{
public class CustomControl : Control
{
private VisualStyleRenderer renderer = null;
// Depending on which VisualStyleElement of TextEdit
// we select here, we get different results.
private readonly VisualStyleElement element =
VisualStyleElement.TextBox.TextEdit.Disabled;
public CustomControl()
{
this.Location = new Point(50, 50);
this.Size = new Size(200, 200);
// It will render red if VisualStyles aren't enabled.
this.BackColor = Color.Red;
// Must check this otherwise we'll get an exception
// if themes aren't enabled or supported at runtime.
if (Application.RenderWithVisualStyles &&
VisualStyleRenderer.IsElementDefined(element))
{
renderer = new VisualStyleRenderer(element);
}
}
protected override void OnPaint(PaintEventArgs e)
{
// Draw the element if the renderer has been set.
if (renderer != null)
{
renderer.DrawBackground(e.Graphics,
this.ClientRectangle);
}
// Visual styles are disabled or the element is undefined,
// so just draw a message.
else
{
this.Text = "Visual styles are disabled.";
TextRenderer.DrawText(e.Graphics, this.Text, this.Font,
new Point(0, 0), this.BackColor);
}
}
}
}
I hope this helps,
-- Tim Scott
http://geekswithblogs.net/tscott