views:

475

answers:

1

How do you deal with the different XP themes when designing a WinForms UI? Do you avoid hard coded color values or just accept that your UI will not look good on non standard themes?

For instance, I have a light blue gradient panel that looks good against the standard control background color but would clash with other custom themes. What's a good approach to take?

+8  A: 

Avoid hex colors and colors with names like "White" or "Green". The color picker for most objects should be able to show you colors with names like "ActiveWindow" or "ForegroundText". Those are the colors you want to be using. They are available via code also, and you want to choose them so that the names have some relationship to how they're used. For example, don't set "ForegroundText" as your background color just because you want a black background. If you have a gradient, then use those colors to build the gradient. Also, there's an event you may need to handle for when the theme changes.

That's if you choose to respect the themes. If you have a really out-there interface then you may want to specify your own colors. In that case, never use the windows colors, because they won't be reliable and you might end up with something real ugly. That means you'll need to go and change all the defaults in the standard controls, but if you're doing this you probably have your own controls anyway.

In summary, the thing to remember is that it's an all or nothing shot: either respect themes and always use colors defined based on Windows widget elements, or don't use themes and never use those colors at all.

Joel Coehoorn