3

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: WinForms radio button 100% DPI If I increase the DPI to 150% in windows, the radio buttons look nice and big: WinForms radio button 150% DPI

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 (WinForms radio button no visual style)
  • 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.

Duke Nukem
  • 357
  • 2
  • 11
  • For anyone curious, I went with "solutions I'm avoiding" #1. For the life of me, I couldn't find the entrypoint that draws the themed glyphs :( – Duke Nukem Oct 16 '17 at 04:13

0 Answers0