Re: What is the correct way to response to the wxEVT_DPI_CHANGED event?
Vadim Zeitlin <[email protected]>
| Newsgroups | gmane.comp.lib.wxwindows.general |
|---|---|
| Message-ID | <[email protected]> |
On Wed, 29 Mar 2023 22:52:11 -0700 (PDT) AsmWarrior wrote:
A> Hi, when the application receive a wxEVT_DPI_CHANGED event, how can it
A> response to the event?
This depends on where you're handling it. If you handle it for some custom
widget, you would typically recompute any cached DPI-dependent metrics in
this handler. If you handle it for the TLW, you could redo the layout
taking the new DPI into account if the automatic layout update (basically,
scaling everything by the new-to-old DPI ratio) doesn't produce the best
results.
A> I looked at the wxWidgets' sample code "display", it looks like it does
A> nothing, but just show some text in the status bar:
A>
A> void MyFrame::OnDPIChanged(wxDPIChangedEvent& event)
A> {
A> wxLogStatus(this, "DPI changed: was %d*%d, now %d*%d",
A> event.GetOldDPI().x, event.GetOldDPI().y,
A> event.GetNewDPI().x, event.GetNewDPI().y);
A>
A> event.Skip();
A> }
A>
A> But if we need to layout the UIs, do we need to call the ResetMode()
A> function of the wxDisplay class?
No, you never need to call this function nor ChangeMode(). This is about
changing the display resolution and is something you basically never do.
A> I even did some test about the DPI changing, and I think if ResetMode() is
A> not called, the layout is wrong, you can see the discussion and image shots
A> here in the:
A>
A> How does the FromDIP function work under different DPI scaling? —
A> https://forums.wxwidgets.org/viewtopic.php?p=218156#p218156
A>
A> Any suggestions? Thanks!
I don't really understand what the problem is after looking at the
screenshots in the post above. It seems perfectly normal that a 250*50
button becomes of 375*75 size at 150% DPI scaling.
Have you read https://docs.wxwidgets.org/latest/overview_high_dpi.html ?
I've tried explaining high DPI support in wxWidgets as well as I could
there.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
signature.asc
(application/pgp-signature, 196 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (MingW32) iEYEABECAAYFAmQleh8ACgkQBupB3k9sHoaWIACdFepYmTlboxBmka7AAgkWt8nB t7AAmQEFQSlEDGvsAvXHL6poizTE0WGF =0SjH -----END PGP SIGNATURE-----