I've read that wxGetDisplayPPI() is kind of deprecated since it doesn't return a per-display ppi rate. So I've switched to wxDisplay::GetPPI(int display). But I seem unable to find a way to find out which display my application currently is shown on.
If there were such a way I would propose a wxWindow::GetPPI() function that
automatically returns the ppi for the current window.
const unsigned display_idx = wxDisplay::GetFromWindow(window);const wxSize ppi = (display_idx != wxNOT_FOUND ? wxDisplay(display_idx) : wxDisplay(0u)).GetPPI();
std::cerr << "screen idx:" << wxDisplay::GetFromWindow(this) << std::endl;Bind(wxEVT_SHOW, [this](wxShowEvent &event) { std::cerr << "screen idx:" << wxDisplay::GetFromWindow(this) << std::endl; CallAfter([=]() { std::cerr << "screen idx:" << wxDisplay::GetFromWindow(this) << std::endl; });});
0
0
1
It should be noted, however, that on Linux the wxDisplay::GetFromWindow() function only works reliably once the window is on screen / has been on screen for a bit.
I'm not sure what's going on there, but I've learned not to rely on bare wxDisplay::GetFromWindow() in window construction code.
Note that
wxWindowCreateEvent is sent by wxGTK only once the window has been
realized, so it's safe to do everything in this event handler.
Note that
wxWindowCreateEvent is sent by wxGTK only once the window has been
realized, so it's safe to do everything in this event handler.
Paul, if you're reading this, would you
have any (better) ideas about how could we make structuring application
code which needs to get the DPI applicable to the window when initializing
it? Does anybody know how do typical GTK+ applications do this?
m_manager.AddPane(m_worksheet->m_mainToolBar,
wxAuiPaneInfo().Name(wxT("toolbar")).
Top().TopDockable(true).Show(true).
BottomDockable(true).
CaptionVisible(false).CloseButton(false).
LeftDockable(false).DockFixed().
RightDockable(false).Gripper(false).Row(1)
);
Kind regards,
Gunter.
I encounter all those problems that can be found about manifest files and dpi awareness.Has anyone been able to get the wx display sample running correctly on MSW?