Using C# winforms, i want to create custom controls that looks like the real ones.
There are a lot of classes that can be used to draw controls that looks like the real ones: ControlPaint
, VisualStyleRenderer
, ButtonRenderer
, CheckBoxRenderer
, ComboBoxRenderer
, GroupBoxRenderer
, ProgressBarRenderer
, RadioButtonRenderer
, ScrollBarRenderer
, TabRenderer
, TextBoxRenderer
, TextRenderer
, ToolStripProfessionalRenderer
, ToolStripRenderer
, ToolStripSystemRenderer
, TrackBarRenderer
.
The problems coming when considering visual styles: I want to be visual styles independent. Meaning: I dont care if user allowing visual-styles or not, i want it to work. if user enabled visual-styles, i want to draw it using visual-styles, otherwise i want to draw it without visual-styles.
By the MSDN documentation, the only classes that are visual-styles independent are ButtonRenderer
, CheckBoxRenderer
, GroupBoxRenderer
, RadioButtonRenderer
. That means that for all other cases i need to check myself if visual-styles enabled and use different code to draw the parts.
Suppose i want to draw a Tab control parts myself. TabRenderer
class has all needed functionality for that, but it works only if user enabled visual styles. otherwise I need to use ControlPaint
class to draw, but it uses completely different model, there is no ControlPaint.DrawTab()
method or something like that, and i need to figure out what rectangle types i need to draw so it will look like a real tab. that`s annoying.
The built-in controls, including the Tab control, already have this functionality of drawing themselves with or without visual styles. Why doesn`t microsoft exposing this functionality for the custom control creators? Why are custom control creators should suffer?