How to draw user interface elements with visual styles disabled?

I have an owner control where I need to draw the extension (plus / minus) window of the tree. With the visual style enabled, it's simple, just create a visualizer for the corresponding VisualStyleElement object:

VisualStyleElement element = VisualStyleElement.TreeView.Glyph.Opened VisualStyleRenderer renderer = new VisualStyleRenderer( element ); Size size = renderer.GetPartSize( graphics, ThemeSizeType.True ); ... renderer.DrawBackground( graphics, someRect ); 

Is it possible to achieve a similar effect when disabling visual styles? I know that there is a ControlPaint class that can draw whole controls, but how to draw (and get the size) only part of the TreeView control?

+4
source share
1 answer

Without VisualStyles, I believe that the controls plus or minus are calls to the DrawRectangle and DrawLine methods.

The Rectangle element looks like it is using the color SystemColors.Control , and the Plus / Minus part looks like SystemColors.ControlText (or black).

enter image description here

+1
source

Source: https://habr.com/ru/post/1380189/


All Articles