Re: What is the correct way to response to the wxEVT_DPI_CHANGED event?
AsmWarrior <[email protected]>
| Newsgroups | gmane.comp.lib.wxwindows.general |
|---|---|
| Message-ID | <[email protected]> |
Hi, VZ, thanks for your time and help.
On Thursday, March 30, 2023 at 8:07:35 PM UTC+8 Vadim Zeitlin wrote:
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.
OK, I see, it looks like in many cases, I don't even do anything to handle
the wxEVT_DPI_CHANGED even, just like currently the sample "display" does.
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.
OK. So, it looks like the ResetMode() function is just for debug only?
Maybe some document(like your above explanation) is need to mention this.
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.
OK, I think you are correct, thanks.
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.
I have read this document for at least two or three times, but I think some
of knowledge are still hard to understand.
That's why I try to run the sample "display" to test it.
I would suggest that a minimal sample code should be put in this document,
so that people(like me) can understand quickly.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
--
Please read https://www.wxwidgets.org/support/mlhowto.htm before posting.
---
You received this message because you are subscribed to the Google Groups "wx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/wx-users/08315361-0db0-40eb-9fd9-3c5aa0430757n%40googlegroups.com.