I'm trying to find some way to draw large-DPI UI glyphs in WinForms with visual styles. For example, if I have the DPI set to 100% in windows, no matter how I try to draw a styled radio button, it ends up looking like this: If I increase the DPI to 150% in windows, the radio buttons look nice and big:
I can't find any way to draw the large-DPI radio button above, without changing the windows user-profile-wide DPI setting. I do not want large UI elements in any other apps. Here are the things I tried (unsuccessfully) so far:
- Forms' AutoScale* properties - do not affect UI glyph size
- Graphics.ScaleTransform() before calling UI glyph drawing routines - does not affect UI glyph size if visual styles are enabled
- ControlPaint methods - allows me to draw scaled UI glyphs but only without visual styles (
)
- Using VisualStyleRenderer directly - no way (that I know of) to change the drawn UI glyph sizes
Solutions I'm avoiding:
- Embedding pre-rendered UI glyphs in executable - I need my app to follow the selected windows user-profile-wide visual style, so this approach would quickly get very complex and hard to maintain, as future windows versions will add different visual styles.
- Switching to WPF - client requires WinForms and the amount of refactoring that would be involved will be ridiculous (this is a fairly large app)
So is there any way to do this given the above two constraints? Maybe somehow tricking the VisualStyleRenderer or somehow forcing DPI for a single process? Any ideas, tips, and WinAPI hacks welcome.