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, everyone, I still have question about the DPI change handling.

Here is the patch I made to the "display" sample code:

diff --git a/samples/display/display.cpp b/samples/display/display.cpp
index 58f18de..fb028ef 100644
--- a/samples/display/display.cpp
+++ b/samples/display/display.cpp
@@ -356,6 +356,10 @@ void MyFrame::PopuplateWithDisplayInfo()
         sizer->Add(new wxStaticText(page, wxID_ANY, "Current: "));
         sizer->Add(new wxStaticText(page, Display_CurrentMode, 
currentMode));
 
+        wxSize dpi = GetDPI();
+        wxSize newSize = wxWindow::FromDIP(wxSize(250,50));
+        sizer->Add(new wxButton(page, wxID_ANY, _T("Hello World"), 
wxDefaultPosition, newSize));
+
         sizerTop->Add(new wxButton(page, Display_ResetMode, "&Reset mode"),
                       wxSizerFlags().Centre().Border());
 #endif // wxUSE_DISPLAY


And now I try to set two breakpoints. The breakpoint1 in the above code, in 
the line of Add() function call. The breakpoint2 is set inside the function:

void MyFrame::OnDPIChanged(wxDPIChangedEvent& event)
{
    wxLogStatus(this, "DPI changed: was %d*%d, now %d*%d",
                event.GetOldDPI().x, event.GetOldDPI().y,
                event.GetNewDPI().x, event.GetNewDPI().y);

    event.Skip();
}
Now, I try to run the executable when the initial DPI scaling is 100%, I 
first got breakpoint1 hit, and I see the "newSize" is 250*50. Now, I try to 
change the DPI scaling to 150%, and after that, I got breakpoint1 hit 
again, I see the value of "newSize" is still 250*50. After that I got the 
breakpoint2 hit.

I expect that when the second time the breakpoint1 got hit, the newSize 
value should be 375*75, because I have already changed the DPI scaling.
Also, I expect that the breakpoint2 should be hit before the breakpoint1 
after the DPI changes?

Any one can explain this?

Thanks.
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/d55b16b5-2aed-462c-940b-9e0e8ea96a0bn%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.