+ if ( m_hiddenClass )
+ {
+ if ( !::UnregisterClass(m_hiddenClass, wxGetInstance()) )
+ {
+ wxLogLastError(wxT("UnregisterClass(wxDisplayHiddenWindow)"));
+ }
+ }
+ }
+
+ ms_factory = NULL;
+}
+
+void wxDisplayFactoryMSW::DoRefreshMonitors()
+{
+ m_displays.Clear();
+
+ if ( !gs_EnumDisplayMonitors(NULL, NULL, MultimonEnumProc, (LPARAM)this) )
+ {
+ wxLogLastError(wxT("EnumDisplayMonitors"));
+ }
+}
+
+/* static */
+BOOL CALLBACK
+wxDisplayFactoryMSW::MultimonEnumProc(
+ HMONITOR hMonitor, // handle to display monitor
+ HDC WXUNUSED(hdcMonitor), // handle to monitor-appropriate device context
+ LPRECT WXUNUSED(lprcMonitor), // pointer to monitor intersection rectangle
+ LPARAM dwData) // data passed from EnumDisplayMonitors (this)
+{
+ wxDisplayFactoryMSW *const self = (wxDisplayFactoryMSW *)dwData;
+
+ self->m_displays.Add(hMonitor);
+
+ // continue the enumeration
+ return TRUE;
+}
+
+wxDisplayImpl *wxDisplayFactoryMSW::CreateDisplay(unsigned n)
+{
+ wxCHECK_MSG( n < m_displays.size(), NULL, wxT("An invalid index was passed to wxDisplay") );
+
+ return new wxDisplayMSW(n, m_displays[n]);
+}
+
+// helper for GetFromPoint() and GetFromWindow()
+int wxDisplayFactoryMSW::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] )
+ return n;
+ }
+ }
+
+ return wxNOT_FOUND;
+}
+
+int wxDisplayFactoryMSW::GetFromPoint(const wxPoint& pt)
+{
+ POINT pt2;
+ pt2.x = pt.x;
+ pt2.y = pt.y;
+
+ return FindDisplayFromHMONITOR(gs_MonitorFromPoint(pt2,
+ MONITOR_DEFAULTTONULL));
+}
+
+int wxDisplayFactoryMSW::GetFromWindow(const wxWindow *window)
+{
+ return FindDisplayFromHMONITOR(gs_MonitorFromWindow(GetHwndOf(window),
+ MONITOR_DEFAULTTONULL));
+}
+
+#endif // wxUSE_DISPLAY