Comments, how-to's, examples, tools, techniques and other material regarding .NET and related technologies.
Tuesday, April 08, 2008
ControlPaint and Vista
What's ControlPaint for? Well, you can use it for different purposes, e.g. for printing a form including the controls on it properly rendered.
Another reason why you would want to use ControlPaint is when you want to do some customization to controls that support ownerdraw, e.g. the TreeView control.
Be aware, however, that ControlPaint doesn't support visual styles. So for instance if you use ControlPaint.DrawCheckBox you will notice that under Vista it will render the checkboxes with the XP style. That's not hat you want.
In those cases where you want support for visual styles use classes such as the CheckBoxRenderer and similar classes in System.Windows.Forms. So for the checkbox you would use CheckBoxRenderer.DrawCheckBox. The difference will be that the CheckBoxRenderer supports visual styles. Your checkboxes will look as expected on Vista as well.
I have tested this, and it works on Vista with .NET 2.0. Don't necessarily rely on the online information. Give it a try on your development and your target platform. Also give it a try on the .NET version you are using. The described technique should be available for all versions between 2.0 and 3.5. The online documentation is contradictory on this. It doesn't seem to be supported on the compact framework. But who runs Vista on his portable device....
Labels:
Technology
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment
All comments, questions and other feedback is much appreciated. Thank you!