- // enumerate all displays
- if ( !::EnumDisplayMonitors(NULL, NULL, wxmswMonitorEnumProc, 0) )
- {
- wxLogLastError(wxT("EnumDisplayMonitors"));
-
- // TODO: still create at least one (valid) entry in gs_displays for the
- // primary display!
- }
-}
-
-// this function must be called before accessing gs_displays array as it
-// creates and initializes it
-static void InitDisplays()
-{
- if ( gs_displays )
- return;
-
- gs_displays = new wxDisplayInfoArray();
-
- if ( gs_useDirectX && !DoInitDirectX() )
- {
- // either we were told not to try to use DirectX or fall back to std
- // functions if DirectX method failed
- gs_useDirectX = false;
-
- DoInitStdWindows();
- }
-}
-
-// convert a DEVMODE to our wxVideoMode
-wxVideoMode ConvertToVideoMode(const DEVMODE& dm)
-{
- // note that dmDisplayFrequency may be 0 or 1 meaning "standard one" and
- // although 0 is ok for us we don't want to return modes with 1hz refresh
- return wxVideoMode(dm.dmPelsWidth,
- dm.dmPelsHeight,
- dm.dmBitsPerPel,
- dm.dmDisplayFrequency > 1 ? dm.dmDisplayFrequency : 0);
-}
-
-// emulation of ChangeDisplaySettingsEx() for Win95
-LONG WINAPI ChangeDisplaySettingsExForWin95(LPCTSTR WXUNUSED(lpszDeviceName),
- LPDEVMODE lpDevMode,
- HWND WXUNUSED(hwnd),
- DWORD dwFlags,
- LPVOID WXUNUSED(lParam))
-{
- return ::ChangeDisplaySettings(lpDevMode, dwFlags);
-}
-
-// ----------------------------------------------------------------------------
-// wxDisplayModule
-// ----------------------------------------------------------------------------
-
-void wxDisplayModule::OnExit()
-{
- delete gs_displays;
-}
-
-// ---------------------------------------------------------------------------
-// wxDisplay
-// ---------------------------------------------------------------------------
-
-/* static */
-void wxDisplay::UseDirectX(bool useDX)
-{
- wxCHECK_RET( !gs_displays, _T("it is too late to call UseDirectX") );
-
- gs_useDirectX = useDX;
-}
-
-// helper of GetFromPoint() and GetFromWindow()
-static int DisplayFromHMONITOR(HMONITOR hmon)
-{
- if ( hmon )
- {
- const size_t count = wxDisplay::GetCount();
-
- for ( size_t n = 0; n < count; n++ )
- {
- if ( hmon == (*gs_displays)[n].m_hmon )
- return n;
- }
- }
-
- return wxNOT_FOUND;
-}
-
-/* static */
-size_t wxDisplayBase::GetCount()
-{
- InitDisplays();