From 00526cefb61bf71df2337f9c896e566ffce5132d Mon Sep 17 00:00:00 2001 From: Iwbnwif Yiw Date: Mon, 28 Mar 2016 21:37:55 +0200 Subject: [PATCH] Return full virtual screen size from wxScreenDC::GetSize() in wxMSW Return the size of the entire virtual screen, possibly composed from multiple monitors, rather than just the size of the primary monitor. This makes this method consistent with wxScreenDC actually representing the entire virtual screen and not just the primary monitor and also with wxGTK. Closes #13279. --- docs/changes.txt | 1 + include/wx/msw/dcscreen.h | 8 +++----- src/msw/dcscreen.cpp | 10 +++++++++- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 0a2951edcb..06f7800124 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -78,6 +78,7 @@ wxMSW: - Enable wxStackWalker in MinGW64 builds. - Fix crash when using wxCHMHelpController() in 64 bit builds (Xlord2). - Fix MDI menu display after failure to create a child frame (troelsk). +- Fix wxScreenDC::GetSize() with multiple monitors (iwbnwif). wxOSX: diff --git a/include/wx/msw/dcscreen.h b/include/wx/msw/dcscreen.h index 839b585ab1..082660c4af 100644 --- a/include/wx/msw/dcscreen.h +++ b/include/wx/msw/dcscreen.h @@ -17,13 +17,11 @@ class WXDLLIMPEXP_CORE wxScreenDCImpl : public wxMSWDCImpl { public: - // Create a DC representing the whole screen + // Create a DC representing the whole virtual screen (all monitors) wxScreenDCImpl( wxScreenDC *owner ); - virtual void DoGetSize(int *w, int *h) const - { - GetDeviceSize(w, h); - } + // Return the size of the whole virtual screen (all monitors) + virtual void DoGetSize(int *w, int *h) const; wxDECLARE_CLASS(wxScreenDCImpl); wxDECLARE_NO_COPY_CLASS(wxScreenDCImpl); diff --git a/src/msw/dcscreen.cpp b/src/msw/dcscreen.cpp index 397a227641..de4eb9b6d3 100644 --- a/src/msw/dcscreen.cpp +++ b/src/msw/dcscreen.cpp @@ -26,7 +26,7 @@ wxIMPLEMENT_ABSTRACT_CLASS(wxScreenDCImpl, wxMSWDCImpl); -// Create a DC representing the whole screen +// Create a DC representing the whole virtual screen (all monitors) wxScreenDCImpl::wxScreenDCImpl( wxScreenDC *owner ) : wxMSWDCImpl( owner ) { @@ -37,3 +37,11 @@ wxScreenDCImpl::wxScreenDCImpl( wxScreenDC *owner ) : ::SetBkMode( GetHdc(), TRANSPARENT ); } +// Return the size of the whole virtual screen (all monitors) +void wxScreenDCImpl::DoGetSize(int *width, int *height) const +{ + if ( width ) + *width = ::GetSystemMetrics(SM_CXVIRTUALSCREEN); + if ( height ) + *height = ::GetSystemMetrics(SM_CYVIRTUALSCREEN); +}