+
+
+ // get pointer to the function dynamically
+ //
+ // we're only called from the main thread, so it's ok to use static
+ // variable
+ static ChangeDisplaySettingsEx_t pfnChangeDisplaySettingsEx = NULL;
+ if ( !pfnChangeDisplaySettingsEx )
+ {
+ wxDynamicLibrary dllDisplay(displayDllName, wxDL_VERBATIM | wxDL_QUIET);
+ if ( dllDisplay.IsLoaded() )
+ {
+ wxDL_INIT_FUNC_AW(pfn, ChangeDisplaySettingsEx, dllDisplay);
+ }
+ //else: huh, no this DLL must always be present, what's going on??
+
+#ifndef __WXWINCE__
+ if ( !pfnChangeDisplaySettingsEx )
+ {
+ // we must be under Win95 and so there is no multiple monitors
+ // support anyhow
+ pfnChangeDisplaySettingsEx = ChangeDisplaySettingsExForWin95;
+ }
+#endif // !__WXWINCE__
+ }
+
+ // do change the mode
+ switch ( pfnChangeDisplaySettingsEx
+ (
+ GetName().t_str(), // display name
+ pDevMode, // dev mode or NULL to reset
+ NULL, // reserved
+ flags,
+ NULL // pointer to video parameters (not used)
+ ) )
+ {
+ case DISP_CHANGE_SUCCESSFUL:
+ // ok
+ {
+ // If we have a top-level, full-screen frame, emulate
+ // the DirectX behaviour and resize it. This makes this
+ // API quite a bit easier to use.
+ wxWindow *winTop = wxTheApp->GetTopWindow();
+ wxFrame *frameTop = wxDynamicCast(winTop, wxFrame);
+ if (frameTop && frameTop->IsFullScreen())
+ {
+ wxVideoMode current = GetCurrentMode();
+ frameTop->SetClientSize(current.GetWidth(), current.GetHeight());
+ }
+ }
+ return true;
+
+ case DISP_CHANGE_BADMODE:
+ // don't complain about this, this is the only "expected" error
+ break;
+
+ default:
+ wxFAIL_MSG( wxT("unexpected ChangeDisplaySettingsEx() return value") );
+ }
+
+ return false;