From 473ca5f34aec8f80adcfc6bfb8888807567dfeae Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 16 Sep 2010 11:05:46 +0000 Subject: [PATCH] Compilation fixes for non-MSVC 9 compilers after r65555. Somehow MSVC 9 compiled invalid wxT(__FUNCTION__) expressions but both MinGW and MSVC 6 (correctly) failed. Don't use this construct at all but instead call wxLogLastError() with the real function name. Also refactor the code slightly to avoid having to repeat this fix thrice. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65557 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/display.cpp | 48 ++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-) 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; } -- 2.45.2