-// ----------------------------------------------------------------------------
-// wxDisplayFactoryWin32Base
-// ----------------------------------------------------------------------------
-
-int wxDisplayFactoryWin32Base::ms_supportsMultimon = -1;
-
-wxDisplayFactoryWin32Base::wxDisplayFactoryWin32Base()
-{
- if ( ms_supportsMultimon == -1 )
- {
- ms_supportsMultimon = 0;
-
- wxDynamicLibrary dllUser32(_T("user32.dll"));
-
- wxLogNull noLog;
-
- gs_MonitorFromPoint = (MonitorFromPoint_t)
- dllUser32.GetSymbol(wxT("MonitorFromPoint"));
- if ( !gs_MonitorFromPoint )
- return;
-
- gs_MonitorFromWindow = (MonitorFromWindow_t)
- dllUser32.GetSymbol(wxT("MonitorFromWindow"));
- if ( !gs_MonitorFromWindow )
- return;
-
- gs_GetMonitorInfo = (GetMonitorInfo_t)
- dllUser32.GetSymbolAorW(wxT("GetMonitorInfo"));
- if ( !gs_GetMonitorInfo )
- return;
-
- ms_supportsMultimon = 1;
-
- // we can safely let dllUser32 go out of scope, the DLL itself will
- // still remain loaded as all Win32 programs use it
- }
-}
-
-void wxDisplayFactoryWin32Base::Clear()
-{
- WX_CLEAR_ARRAY(m_displays);
-}
-
-wxDisplayFactoryWin32Base::~wxDisplayFactoryWin32Base()
-{
- Clear();
-}
-
-// helper for GetFromPoint() and GetFromWindow()
-int wxDisplayFactoryWin32Base::FindDisplayFromHMONITOR(HMONITOR hmon) const
-{
- if ( hmon )
- {
- const size_t count = m_displays.size();
- for ( size_t n = 0; n < count; n++ )
- {
- if ( hmon == m_displays[n]->m_hmon )
- return n;
- }
- }
-
- return wxNOT_FOUND;
-}
-
-int wxDisplayFactoryWin32Base::GetFromPoint(const wxPoint& pt)
-{
- POINT pt2;
- pt2.x = pt.x;
- pt2.y = pt.y;
-
- return FindDisplayFromHMONITOR(gs_MonitorFromPoint(pt2,
- MONITOR_DEFAULTTONULL));
-}
-
-int wxDisplayFactoryWin32Base::GetFromWindow(wxWindow *window)
-{
- return FindDisplayFromHMONITOR(gs_MonitorFromWindow(GetHwndOf(window),
- MONITOR_DEFAULTTONULL));
-}
-
-// ============================================================================
-// wxDisplay implementation using Win32 multimon API
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// wxDisplayFactoryMultimon initialization
-// ----------------------------------------------------------------------------
-
-wxDisplayFactoryMultimon::wxDisplayFactoryMultimon()
-{
- if ( !ms_supportsMultimon )
- return;
-
- // look up EnumDisplayMonitors() which we don't need with DirectDraw
- // implementation
- EnumDisplayMonitors_t pfnEnumDisplayMonitors;
- {
- wxLogNull noLog;
-
- wxDynamicLibrary dllUser32(_T("user32.dll"));
- pfnEnumDisplayMonitors = (EnumDisplayMonitors_t)
- dllUser32.GetSymbol(wxT("EnumDisplayMonitors"));
- if ( !pfnEnumDisplayMonitors )
- return;
- }
-
- // enumerate all displays
- if ( !pfnEnumDisplayMonitors(NULL, NULL, MultimonEnumProc, (LPARAM)this) )
- {
- wxLogLastError(wxT("EnumDisplayMonitors"));
- }
-}
-
-/* static */
-BOOL CALLBACK
-wxDisplayFactoryMultimon::MultimonEnumProc(
- HMONITOR hMonitor, // handle to display monitor
- HDC WXUNUSED(hdcMonitor), // handle to monitor-appropriate device context
- LPRECT lprcMonitor, // pointer to monitor intersection rectangle
- LPARAM dwData // data passed from EnumDisplayMonitors (this)
-)
-{
- wxDisplayFactoryMultimon *const self = (wxDisplayFactoryMultimon *)dwData;
- self->AddDisplay(hMonitor, lprcMonitor);
-
- // continue the enumeration
- return TRUE;
-}
-
-// ----------------------------------------------------------------------------
-// wxDisplayFactoryMultimon helper functions
-// ----------------------------------------------------------------------------
-
-void wxDisplayFactoryMultimon::AddDisplay(HMONITOR hMonitor, LPRECT lprcMonitor)
-{
- wxDisplayInfo *info = new wxDisplayInfo(hMonitor);
-
- // we also store the display geometry
- info->m_rect = wxRect(lprcMonitor->left, lprcMonitor->top,
- lprcMonitor->right - lprcMonitor->left,
- lprcMonitor->bottom - lprcMonitor->top);
-
- // now add this monitor to the array
- m_displays.Add(info);
-}
-
-// ----------------------------------------------------------------------------
-// wxDisplayFactoryMultimon inherited pure virtuals implementation
-// ----------------------------------------------------------------------------
-
-wxDisplayImpl *wxDisplayFactoryMultimon::CreateDisplay(size_t n)
-{
- wxCHECK_MSG( n < m_displays.size(), NULL, _T("invalid display index") );
-
- return new wxDisplayImplMultimon(n, *(m_displays[n]));
-}
-
-// ----------------------------------------------------------------------------
-// wxDisplayImplMultimon implementation
-// ----------------------------------------------------------------------------
-
-wxArrayVideoModes
-wxDisplayImplMultimon::GetModes(const wxVideoMode& modeMatch) const