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:
// 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;
}
{
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;
}
{
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;
}