RE: High DPI on Windows with Tk
[email protected] ("Konovalov, Vadim") Sun, 23 Jun 2019 07:07:38 +0000
| Newsgroups | perl.tcltk |
|---|---|
| Message-ID | <[email protected]> |
Dell Customer Communication - Confidential
> > From: Christopher Chavez=20
> > To: tcltk
> > I wanted to
> share a way for using high-DPI appearance on Windows that I
> > found, in case
> anyone was interested. I have posted it to
> >
> https://www.perlmonks.org/?node_id=3D11101747
Thank you
Pretty nice
> > Before calling
> MainWindow->new in Tk, use Win32::API to invoke
> > SetProcessDPIAware():
> >=20
> > if ($^O eq 'MSWin32') {
> > use Win32::API;
Here should be 'require', not 'use'
> > # See https://docs.microsoft.com/en-us/windows/desktop/api/winuser/n=
f-winuser-setprocessdpiaware
> > my $SetProcessDPIAware =3D Win32::API::More->new('User32', 'BOOL Set=
ProcessDPIAware()');
> > $SetProcessDPIAware->Call() or warn 'Failed to set process DPI aware=
ness';
> > }
> >=20
> >=20
> > This isn't the approach Microsoft
> recommends (they suggest using an
> > application manifest instead), but this
> seems to be an easy enough approach
> > for standalone scripts.
> >=20
> >=20
> > Recent
> Tcl/Tk will enable high-DPI by default for scripts run using tclsh/wish,
> > but
> not the Tcl C API. I'm not sure this behavior should be the default in
> >
> Tcl::pTk, for compatibility (i.e. since Perl/Tk does not enable high-DPI)=
and
> >
> because certain elements like images will not be resized automatically.
> >=20
> >
> Maybe Tcl::Tk would be more in favor of having this behavior by default (=
for
> >
> consistency with Tcl/Tk), but it might require XS or dependency on anothe=
r
> >
> module like Win32::API.
> >=20
> >=20
> > Christopher A. Chavez