widget demo: enable Windows system DPI awareness#64
Conversation
| # Enable system DPI awareness for sharper UI on Windows | ||
| # https://www.perlmonks.org/?node_id=11101747 | ||
| if ($^O eq 'MSWin32') { | ||
| require Win32::API; |
There was a problem hiding this comment.
Is it guaranteed that Win32::API is available on all Windows Perl installations? Otherwise I would prefer a more defensive approach, e.g. if ($^O eq 'MSWin32' && eval { require Win32::API; 1 }).
Also, do all Windows versions have the SetProcessDPIAware() function available? Otherwise the eval{} should be extended even further.
There was a problem hiding this comment.
I confess I haven't thought through the details of including this in Perl/Tk very well, so I will mark this as a draft for now.
Win32::API is included in Strawberry Perl going back to at least 5.8.9.2, and I'm not sure about ActivePerl. But it isn't a core module, and its predecessor Win32 was a core module only prior to 5.8.4. However neither should be strictly necessary as Perl/Tk uses XS.
SetProcessDPIAware() is in Vista/2008 or later. What is the minimum version Perl/Tk supports—should I assume the same as Perl 5.8 or and/or Tcl/Tk 8.4, which would include 2000/XP?
There was a problem hiding this comment.
I'd say, if the solution is simple (i.e. moving the Win32::API::More->new into the eval{}), then this is the way to go.
From writeup on Perlmonks: https://www.perlmonks.org/?node_id=11101747 (see also chrstphrchvz/perl-tcl-ptk#6 (comment))
Before:

After:

There are likely further refinements which could help, e.g. font size.