Add framework for Per-Monitor DPI Awareness on Windows
React to the WM_DPICHANGED event and update the size of the child windows and the top-level window. Scale the minimum and maximum window size to the new DPI. Only react to WM_DPICHANGED when DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 is used.
This commit is contained in:
@@ -2830,6 +2830,7 @@ WX_MSW_DECLARE_HANDLE(HBITMAP);
|
||||
WX_MSW_DECLARE_HANDLE(HIMAGELIST);
|
||||
WX_MSW_DECLARE_HANDLE(HGLOBAL);
|
||||
WX_MSW_DECLARE_HANDLE(HDC);
|
||||
WX_MSW_DECLARE_HANDLE(DPI_AWARENESS_CONTEXT);
|
||||
typedef WXHINSTANCE WXHMODULE;
|
||||
|
||||
#undef WX_MSW_DECLARE_HANDLE
|
||||
|
@@ -23,7 +23,11 @@
|
||||
#endif
|
||||
|
||||
#ifndef WM_PRINTCLIENT
|
||||
#define WM_PRINTCLIENT 0x318
|
||||
#define WM_PRINTCLIENT 0x0318
|
||||
#endif
|
||||
|
||||
#ifndef WM_DPICHANGED
|
||||
#define WM_DPICHANGED 0x02E0
|
||||
#endif
|
||||
|
||||
#ifndef DT_HIDEPREFIX
|
||||
|
@@ -165,6 +165,9 @@ protected:
|
||||
int& x, int& y,
|
||||
int& w, int& h) const wxOVERRIDE;
|
||||
|
||||
// WM_DPICHANGED handler.
|
||||
bool HandleDPIChange(const wxSize& newDPI, const wxRect& newRect);
|
||||
|
||||
// This field contains the show command to use when showing the window the
|
||||
// next time and also indicates whether the window should be considered
|
||||
// being iconized or maximized (which may be different from whether it's
|
||||
@@ -191,6 +194,14 @@ protected:
|
||||
wxWindowRef m_winLastFocused;
|
||||
|
||||
private:
|
||||
// Keep track of the DPI used in this window. So when per-monitor dpi
|
||||
// awareness is enabled, both old and new DPI are known for
|
||||
// wxDPIChangedEvent and wxWindow::MSWUpdateOnDPIChange.
|
||||
wxSize m_activeDPI;
|
||||
|
||||
// This window supports handling per-monitor DPI awareness when the
|
||||
// application manifest contains <dpiAwareness>PerMonitorV2</dpiAwareness>.
|
||||
bool m_perMonitorDPIaware;
|
||||
|
||||
// The system menu: initially NULL but can be set (once) by
|
||||
// MSWGetSystemMenu(). Owned by this window.
|
||||
|
@@ -586,6 +586,10 @@ public:
|
||||
// Should be overridden by all classes storing the "last focused" window.
|
||||
virtual void WXDoUpdatePendingFocus(wxWindow* WXUNUSED(win)) {}
|
||||
|
||||
// Called from WM_DPICHANGED handler for all windows to let them update
|
||||
// any sizes and fonts used internally when the DPI changes.
|
||||
void MSWUpdateOnDPIChange(const wxSize& oldDPI, const wxSize& newDPI);
|
||||
|
||||
protected:
|
||||
// this allows you to implement standard control borders without
|
||||
// repeating the code in different classes that are not derived from
|
||||
|
Reference in New Issue
Block a user