问题
I am using VisualStyleRenderer for my Windows Application, it works perfectly for Windows XP theme but it doesn't work for Windows Classic theme. Can anybody suggest me how will I able to make application theme supportable.
Update:
Let me describe it with a clear picture. I have a list View and on the List Items I am drawing a button by using VisualStyleRenderer class and also Painting that Button region using some Gradient Color. It works in Windows XP theme but while I am changing the Theme to Windows Classic that button wffect is not coming which I have drawn by using VisualStyleRenderer class.
Any help will be appreciated
Thanks in advance.
回答1:
It's not going to happen. There are no "visual styles" for the Windows Classic theme. That's what they mean by "Classic": it's the theme that was used for years before visual styles were invented.
Windows XP's Luna theme is the first one to support visual styles. The Aero theme included with Windows Vista and 7 also supports visual styles, though they look slightly different.
If you use the VisualStyleRenderer
class as you're doing, things will paint according to the theme that the user has selected. As you've said, everything looks fine when you select the Windows XP theme. When you have the Classic theme selected, things paint using the Classic theme. That's the expected behavior; everything else in the system looks different, too.
You will need to check and see if visual styles are supported, and if not, fall back to a different drawing method. There's a sample available here on MSDN. The simplest thing to do is add an if
statement that evaluates the value returned by the Application.RenderWithVisualStyles property. If true, you can draw using the VisualStyleRenderer
class. If false, you need to kick it old school. Using the ControlPaint class might be a good way to do that.
来源:https://stackoverflow.com/questions/5141256/how-to-apply-visual-style-for-windows-classic-theme-in-win-form-using-c-sharp