+
+// ----------------------------------------------------------------------------
+// wxDisplayFactoryMSW implementation
+// ----------------------------------------------------------------------------
+
+wxDisplayFactoryMSW::wxDisplayFactoryMSW()
+{
+ if ( gs_MonitorFromPoint==NULL || gs_MonitorFromWindow==NULL
+ || gs_GetMonitorInfo==NULL || gs_EnumDisplayMonitors==NULL )
+ {
+ // First initialization, or last initialization failed.
+ wxDynamicLibrary dllDisplay(displayDllName, wxDL_VERBATIM | wxDL_QUIET);
+
+ wxDL_INIT_FUNC(gs_, MonitorFromPoint, dllDisplay);
+ wxDL_INIT_FUNC(gs_, MonitorFromWindow, dllDisplay);
+ wxDL_INIT_FUNC_AW(gs_, GetMonitorInfo, dllDisplay);
+ wxDL_INIT_FUNC(gs_, EnumDisplayMonitors, dllDisplay);
+
+ // we can safely let dllDisplay go out of scope, the DLL itself will
+ // still remain loaded as all programs link to it statically anyhow
+ }
+
+ if ( gs_MonitorFromPoint==NULL || gs_MonitorFromWindow==NULL
+ || gs_GetMonitorInfo==NULL || gs_EnumDisplayMonitors==NULL )
+ return;
+
+ // enumerate all displays
+ 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)