]> git.saurik.com Git - wxWidgets.git/commitdiff
Compilation fixes for non-MSVC 9 compilers after r65555.
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 16 Sep 2010 11:05:46 +0000 (11:05 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 16 Sep 2010 11:05:46 +0000 (11:05 +0000)
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

index f9ef4e3171d671f76f63ea1a337b5767cd0dc92f..6f4f1b84c5bc8f37458d02606d08a2a02fcda4b4 100644 (file)
@@ -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<MONITORINFOEX> 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<MONITORINFOEX> 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<MONITORINFOEX> 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<MONITORINFOEX> 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<MONITORINFOEX> monInfo;
 
-    if ( !gs_GetMonitorInfo(m_hmon, (LPMONITORINFO)&monInfo) )
-    {
-        wxLogLastError(wxT(__FUNCTION__));
+    if ( !GetMonInfo(monInfo) )
         return false;
-    }
 
     return (monInfo.dwFlags & MONITORINFOF_PRIMARY) != 0;
 }