X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d5947fad64ffb5bd695620fc82e5d4f20d51fb47..932d0768aa4ef14b363c1f5989e7c425771ce1ff:/src/msw/display.cpp diff --git a/src/msw/display.cpp b/src/msw/display.cpp index f9ef4e3171..b7abb30192 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; } @@ -417,7 +417,7 @@ bool wxDisplayMSW::ChangeMode(const wxVideoMode& mode) // ok { // If we have a top-level, full-screen frame, emulate - // the DirectX behavior and resize it. This makes this + // the DirectX behaviour and resize it. This makes this // API quite a bit easier to use. wxWindow *winTop = wxTheApp->GetTopWindow(); wxFrame *frameTop = wxDynamicCast(winTop, wxFrame);