How to apply visual style for Windows classic theme in Win form using C#

后端 未结 1 1230
失恋的感觉
失恋的感觉 2021-01-27 05:53

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 wil

相关标签:
1条回答
  • 2021-01-27 06:22

    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.

    0 讨论(0)
提交回复
热议问题