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]>

On Wednesday, April 5, 2023 at 5:05:11 AM UTC+8 Maarten Bent wrote:

Hi,

When I move the application between displays with different DPI, I only get 
breakpoint2 (OnDPIChanged).
When I have the application on a display, and change the DPI of that 
display in the Windows settings, it hits both breakpoints. 
I get breakpoint2 first (OnDPIChanged) and then breakpoint1 (via 
OnDisplayChanged). So opposite to what you get.
(Windows 10.0.19045, latest Visual Studio 2022).
Even without breakpoints I can see this behavior, because it shows 'Display 
resolution was changed'  in the status bar, and not ''DPI changed: ...'.

These events are direct responses to Windows messages (WM_DPICHANGED and 
WM_DISPLAYCHANGE).
We don't have any influence on the order of these events.



Hi, Maarten, thanks for the test.

I have did some more tests, and I found that the the event sequence is 
depend on whether the "Display wxWidgets sample" application window is 
active when I change the DPI scaling.

*Test case 1*: If I change the DPI scaling while the sample executable 
window is shown on the desktop, then the OnDPIChanged event arrived first, 
after that the wxFrame get reconstructed. in this case, the wxWindow::FromDIP(wxSize(250,50)); 
is 375*75, which is correct.

*Test case 2*: If I first minimize the sample window, and change the DPI 
scaling, after this operation the wxFrame get reconstructed, but no DPI 
change event arrived.
The DPI change event only arrived after I restore the sample window again. 
In this case, when the wxFrame get reconstructed, the wxWindow::FromDIP(wxSize(250,50)); 
is still  250,50 , which sounds correct, because at this time, the DPI 
change event is not arrived yet. But the bad thing is: I don't see the 
wxFrame get reconstructed again after the  OnDPIChanged function call. This 
looks like if a user has some customized window which depends on the 
FromDIP function call, it may got the wrong size values.

Luckily, in both of the above two cases, the final window size is correct!
I'm not sure my guess is correct, but from my point of view, the DPI change 
event should always arrive before the wxFrame reconstruction if I change 
the DPI scaling, in both of the above cases.

Asmwarrior

-- 
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/09b006ec-8b43-43e7-904f-2e87679c5948n%40googlegroups.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.