X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d5947fad64ffb5bd695620fc82e5d4f20d51fb47..cc3977bf132d40cb66c6b488890ef67a396d4a0a:/src/msw/display.cpp diff --git a/src/msw/display.cpp b/src/msw/display.cpp index f9ef4e3171..6f4f1b84c5 100644 --- a/src/msw/display.cpp +++ b/src/msw/display.cpp @@ -140,6 +140,10 @@ protected: dm.dmDisplayFrequency > 1 ? dm.dmDisplayFrequency : 0); } + // Call GetMonitorInfo() and fill in the provided struct and return true if + // it succeeded, otherwise return false. + bool GetMonInfo(MONITORINFOEX& monInfo) const; + HMONITOR m_hmon; private: @@ -215,18 +219,24 @@ private: // wxDisplayMSW implementation // ---------------------------------------------------------------------------- -wxRect wxDisplayMSW::GetGeometry() const +bool wxDisplayMSW::GetMonInfo(MONITORINFOEX& monInfo) const { - WinStruct monInfo; - - if ( !gs_GetMonitorInfo(m_hmon, (LPMONITORINFO)&monInfo) ) + if ( !gs_GetMonitorInfo(m_hmon, &monInfo) ) { - wxLogLastError(wxT(__FUNCTION__)); - return wxRect(); + wxLogLastError(wxT("GetMonitorInfo")); + return false; } + return true; +} + +wxRect wxDisplayMSW::GetGeometry() const +{ + WinStruct monInfo; + wxRect rect; - wxCopyRECTToRect(monInfo.rcMonitor, rect); + if ( GetMonInfo(monInfo) ) + wxCopyRECTToRect(monInfo.rcMonitor, rect); return rect; } @@ -235,14 +245,9 @@ wxRect wxDisplayMSW::GetClientArea() const { WinStruct monInfo; - if ( !gs_GetMonitorInfo(m_hmon, (LPMONITORINFO)&monInfo) ) - { - wxLogLastError(wxT(__FUNCTION__)); - return wxRect(); - } - wxRect rectClient; - wxCopyRECTToRect(monInfo.rcWork, rectClient); + if ( GetMonInfo(monInfo) ) + wxCopyRECTToRect(monInfo.rcWork, rectClient); return rectClient; } @@ -251,24 +256,19 @@ wxString wxDisplayMSW::GetName() const { WinStruct monInfo; - if ( !gs_GetMonitorInfo(m_hmon, (LPMONITORINFO)&monInfo) ) - { - wxLogLastError(wxT(__FUNCTION__)); - return ""; - } + wxString name; + if ( GetMonInfo(monInfo) ) + name = monInfo.szDevice; - return monInfo.szDevice; + return name; } bool wxDisplayMSW::IsPrimary() const { WinStruct monInfo; - if ( !gs_GetMonitorInfo(m_hmon, (LPMONITORINFO)&monInfo) ) - { - wxLogLastError(wxT(__FUNCTION__)); + if ( !GetMonInfo(monInfo) ) return false; - } return (monInfo.dwFlags & MONITORINFOF_PRIMARY) != 0; }