+ // continue the enumeration
+ return true;
+}
+
+HRESULT WINAPI wxDDEnumModesCallback(LPDDSURFACEDESC lpDDSurfaceDesc,
+ LPVOID lpContext)
+{
+ // we need at least the mode size
+ static const DWORD FLAGS_REQUIRED = DDSD_HEIGHT | DDSD_WIDTH;
+ if ( (lpDDSurfaceDesc->dwFlags & FLAGS_REQUIRED) == FLAGS_REQUIRED )
+ {
+ wxArrayVideoModes * const modes = (wxArrayVideoModes *)lpContext;
+
+ modes->Add(wxVideoMode(lpDDSurfaceDesc->dwWidth,
+ lpDDSurfaceDesc->dwHeight,
+ lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount,
+ lpDDSurfaceDesc->dwRefreshRate));
+ }
+
+ // continue the enumeration
+ return DDENUMRET_OK;
+}
+
+// ----------------------------------------------------------------------------
+// local functions
+// ----------------------------------------------------------------------------
+
+// initialize gs_displays using DirectX functions
+static bool DoInitDirectX()
+{
+#if wxUSE_LOG
+ // suppress the errors if ddraw.dll is not found
+ wxLog::EnableLogging(false);
+#endif
+
+ wxDynamicLibrary dllDX(_T("ddraw.dll"));
+
+#if wxUSE_LOG
+ wxLog::EnableLogging();
+#endif
+
+ if ( !dllDX.IsLoaded() )
+ return false;
+
+ DirectDrawEnumerateEx_t pDDEnumEx = (DirectDrawEnumerateEx_t)
+ dllDX.GetSymbol(WINFUNC(DirectDrawEnumerateEx));
+ if ( !pDDEnumEx )
+ return false;
+
+ // we'll also need DirectDrawCreate() later, resolve it right now
+ gs_DirectDrawCreate = (DirectDrawCreate_t)
+ dllDX.GetSymbol(_T("DirectDrawCreate"));
+ if ( !gs_DirectDrawCreate )
+ return false;
+
+ if ( (*pDDEnumEx)(wxDDEnumExCallback,
+ NULL,
+ DDENUM_ATTACHEDSECONDARYDEVICES) != DD_OK )
+ {
+ return false;
+ }
+
+ // ok, it seems like we're going to use DirectDraw and so we're going to
+ // need ddraw.dll all the time, don't unload it
+ dllDX.Detach();
+
+ return true;
+}
+
+// initialize gs_displays using the standard Windows functions
+static void DoInitStdWindows()
+{