1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/display.cpp
3 // Purpose: MSW Implementation of wxDisplay class
4 // Author: Royce Mitchell III, Vadim Zeitlin
5 // Modified by: Ryan Norton (IsPrimary override)
8 // Copyright: (c) wxWidgets team
9 // Copyright: (c) 2002-2006 wxWidgets team
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
13 // ===========================================================================
15 // ===========================================================================
17 // ---------------------------------------------------------------------------
19 // ---------------------------------------------------------------------------
21 // For compilers that support precompilation, includes "wx.h".
22 #include "wx/wxprec.h"
32 #include "wx/dynarray.h"
36 #include "wx/dynload.h"
38 #include "wx/display.h"
40 // Mingw's w32api headers don't include ddraw.h, though the user may have
41 // installed it. If using configure, we actually probe for ddraw.h there
42 // and set HAVE_DDRAW_H. Otherwise, assume we don't have it if using
43 // the w32api headers, and that we do otherwise.
44 #if !defined HAVE_W32API_H && !defined HAVE_DDRAW_H
45 #define HAVE_DDRAW_H 1
49 // Older versions of windef.h don't define HMONITOR. Unfortunately, we
50 // can't directly test whether HMONITOR is defined or not in windef.h as
51 // it's not a macro but a typedef, so we test for an unrelated symbol which
52 // is only defined in winuser.h if WINVER >= 0x0500
53 #if !defined(HMONITOR_DECLARED) && !defined(MNS_NOCHECK)
54 DECLARE_HANDLE(HMONITOR
);
55 #define HMONITOR_DECLARED
57 #endif // !__WXWINCE__
62 // we don't want to link with ddraw.lib which contains the real
63 // IID_IDirectDraw2 definition
64 const GUID wxIID_IDirectDraw2
=
65 { 0xB3A6F3E0, 0x2B43, 0x11CF, { 0xA2,0xDE,0x00,0xAA,0x00,0xB9,0x33,0x56 } };
68 // ----------------------------------------------------------------------------
69 // typedefs for dynamically loaded Windows functions
70 // ----------------------------------------------------------------------------
72 typedef LONG (WINAPI
*ChangeDisplaySettingsEx_t
)(LPCTSTR lpszDeviceName
,
79 typedef BOOL (PASCAL
*DDEnumExCallback_t
)(GUID
*pGuid
,
80 LPTSTR driverDescription
,
85 typedef HRESULT (WINAPI
*DirectDrawEnumerateEx_t
)(DDEnumExCallback_t lpCallback
,
89 typedef HRESULT (WINAPI
*DirectDrawCreate_t
)(GUID
*lpGUID
,
94 typedef BOOL (WINAPI
*EnumDisplayMonitors_t
)(HDC
,LPCRECT
,MONITORENUMPROC
,LPARAM
);
95 typedef HMONITOR (WINAPI
*MonitorFromPoint_t
)(POINT
,DWORD
);
96 typedef HMONITOR (WINAPI
*MonitorFromWindow_t
)(HWND
,DWORD
);
97 typedef BOOL (WINAPI
*GetMonitorInfo_t
)(HMONITOR
,LPMONITORINFO
);
99 static EnumDisplayMonitors_t gs_EnumDisplayMonitors
= NULL
;
100 static MonitorFromPoint_t gs_MonitorFromPoint
= NULL
;
101 static MonitorFromWindow_t gs_MonitorFromWindow
= NULL
;
102 static GetMonitorInfo_t gs_GetMonitorInfo
= NULL
;
104 // ----------------------------------------------------------------------------
106 // ----------------------------------------------------------------------------
111 // handle of this monitor used by MonitorXXX() functions, never NULL
114 // IDirectDraw object used to control this display, may be NULL
116 IDirectDraw2
*m_pDD2
;
121 // DirectDraw GUID for this display, only valid when using DirectDraw
124 // the entire area of this monitor in virtual screen coordinates
127 // the display device name for this monitor, empty initially and retrieved
128 // on demand by DoGetName()
131 wxDisplayInfo() { m_hmon
= NULL
; m_pDD2
= NULL
; }
134 if ( m_pDD2
) m_pDD2
->Release();
139 WX_DECLARE_OBJARRAY(wxDisplayInfo
, wxDisplayInfoArray
);
140 #include "wx/arrimpl.cpp"
141 WX_DEFINE_OBJARRAY(wxDisplayInfoArray
);
143 // this module is used to cleanup gs_displays array
144 class wxDisplayModule
: public wxModule
147 virtual bool OnInit() { return true; }
148 virtual void OnExit();
150 DECLARE_DYNAMIC_CLASS(wxDisplayModule
)
153 IMPLEMENT_DYNAMIC_CLASS(wxDisplayModule
, wxModule
)
155 // ----------------------------------------------------------------------------
157 // ----------------------------------------------------------------------------
160 // do we use DirectX?
161 static bool gs_useDirectX
= false;
164 // Try to look up the functions needed for supporting multiple monitors. If
165 // they aren't available (probably because we're running on Win95 or NT4 which
166 // predate this API), set a flag which makes wxDisplay return results for a
168 static bool OsSupportsMultipleMonitors()
170 static int isNewEnough
= -1;
171 if ( isNewEnough
== -1 )
174 wxDynamicLibrary
dllUser32(_T("user32.dll"));
175 // Check for one of the symbols to avoid logging errors just because
176 // we happen to be running on Win95 or NT4.
177 if ( dllUser32
.IsLoaded() &&
178 dllUser32
.HasSymbol(wxT("EnumDisplayMonitors")) )
180 // GetMonitorInfo has Unicode/ANSI variants, the others don't.
181 gs_EnumDisplayMonitors
= (EnumDisplayMonitors_t
)
182 dllUser32
.GetSymbol(wxT("EnumDisplayMonitors"));
183 gs_MonitorFromPoint
= (MonitorFromPoint_t
)
184 dllUser32
.GetSymbol(wxT("MonitorFromPoint"));
185 gs_MonitorFromWindow
= (MonitorFromWindow_t
)
186 dllUser32
.GetSymbol(wxT("MonitorFromWindow"));
187 gs_GetMonitorInfo
= (GetMonitorInfo_t
)
188 dllUser32
.GetSymbolAorW(wxT("GetMonitorInfo"));
189 if ( gs_EnumDisplayMonitors
!= NULL
&&
190 gs_MonitorFromPoint
!= NULL
&&
191 gs_MonitorFromWindow
!= NULL
&&
192 gs_GetMonitorInfo
!= NULL
)
198 return (isNewEnough
!= 0);
202 // dynamically resolved DirectDrawCreate()
203 static DirectDrawCreate_t gs_DirectDrawCreate
= NULL
;
206 // this is not really MT-unsafe as wxDisplay is only going to be used from the
207 // main thread, i.e. we consider that it's a GUI class and so don't protect it
208 static wxDisplayInfoArray
*gs_displays
= NULL
;
210 // ===========================================================================
212 // ===========================================================================
214 // ----------------------------------------------------------------------------
215 // callbacks for monitor/modes enumeration stuff
216 // ----------------------------------------------------------------------------
218 static BOOL CALLBACK
wxmswMonitorEnumProc (
219 HMONITOR hMonitor
, // handle to display monitor
220 HDC
WXUNUSED(hdcMonitor
), // handle to monitor-appropriate device context
221 LPRECT lprcMonitor
, // pointer to monitor intersection rectangle
222 LPARAM
WXUNUSED(dwData
) // data passed from EnumDisplayMonitors (unused)
225 wxDisplayInfo
*info
= new wxDisplayInfo();
227 // we need hMonitor to be able to map display id to it which is needed for
228 // MonitorXXX() functions, in particular MonitorFromPoint()
229 info
->m_hmon
= hMonitor
;
231 // we also store the display geometry
232 info
->m_rect
.SetX ( lprcMonitor
->left
);
233 info
->m_rect
.SetY ( lprcMonitor
->top
);
234 info
->m_rect
.SetWidth ( lprcMonitor
->right
- lprcMonitor
->left
);
235 info
->m_rect
.SetHeight ( lprcMonitor
->bottom
- lprcMonitor
->top
);
237 // now add this monitor to the array
238 gs_displays
->Add(info
);
240 // continue the enumeration
246 wxDDEnumExCallback(GUID
*pGuid
,
247 LPTSTR
WXUNUSED(driverDescription
),
249 LPVOID
WXUNUSED(lpContext
),
254 wxDisplayInfo
*info
= new wxDisplayInfo();
257 info
->m_guid
= *pGuid
;
258 info
->m_devName
= driverName
;
260 gs_displays
->Add(info
);
262 //else: we're called for the primary monitor, skip it
264 // continue the enumeration
268 HRESULT WINAPI
wxDDEnumModesCallback(LPDDSURFACEDESC lpDDSurfaceDesc
,
271 // we need at least the mode size
272 static const DWORD FLAGS_REQUIRED
= DDSD_HEIGHT
| DDSD_WIDTH
;
273 if ( (lpDDSurfaceDesc
->dwFlags
& FLAGS_REQUIRED
) == FLAGS_REQUIRED
)
275 wxArrayVideoModes
* const modes
= (wxArrayVideoModes
*)lpContext
;
277 modes
->Add(wxVideoMode(lpDDSurfaceDesc
->dwWidth
,
278 lpDDSurfaceDesc
->dwHeight
,
279 lpDDSurfaceDesc
->ddpfPixelFormat
.dwRGBBitCount
,
280 lpDDSurfaceDesc
->dwRefreshRate
));
283 // continue the enumeration
288 // ----------------------------------------------------------------------------
290 // ----------------------------------------------------------------------------
293 // initialize gs_displays using DirectX functions
294 static bool DoInitDirectX()
297 // suppress the errors if ddraw.dll is not found
298 wxLog::EnableLogging(false);
301 wxDynamicLibrary
dllDX(_T("ddraw.dll"));
304 wxLog::EnableLogging();
307 if ( !dllDX
.IsLoaded() )
310 DirectDrawEnumerateEx_t pDDEnumEx
= (DirectDrawEnumerateEx_t
)
311 dllDX
.GetSymbolAorW(_T("DirectDrawEnumerateEx"));
315 // we'll also need DirectDrawCreate() later, resolve it right now
316 gs_DirectDrawCreate
= (DirectDrawCreate_t
)
317 dllDX
.GetSymbol(_T("DirectDrawCreate"));
318 if ( !gs_DirectDrawCreate
)
321 if ( (*pDDEnumEx
)(wxDDEnumExCallback
,
323 DDENUM_ATTACHEDSECONDARYDEVICES
) != DD_OK
)
328 // ok, it seems like we're going to use DirectDraw and so we're going to
329 // need ddraw.dll all the time, don't unload it
336 // initialize gs_displays using the standard Windows functions
337 static void DoInitStdWindows()
339 // enumerate all displays
340 if ( !gs_EnumDisplayMonitors(NULL
, NULL
, wxmswMonitorEnumProc
, 0) )
342 wxLogLastError(wxT("EnumDisplayMonitors"));
344 // TODO: still create at least one (valid) entry in gs_displays for the
349 // this function must be called before accessing gs_displays array as it
350 // creates and initializes it
351 static void InitDisplays()
356 gs_displays
= new wxDisplayInfoArray();
359 if ( !gs_useDirectX
|| !DoInitDirectX() )
361 // either we were told not to try to use DirectX or fall back to std
362 // functions if DirectX method failed
363 gs_useDirectX
= false;
372 // convert a DEVMODE to our wxVideoMode
373 wxVideoMode
ConvertToVideoMode(const DEVMODE
& dm
)
375 // note that dmDisplayFrequency may be 0 or 1 meaning "standard one" and
376 // although 0 is ok for us we don't want to return modes with 1hz refresh
377 return wxVideoMode(dm
.dmPelsWidth
,
380 dm
.dmDisplayFrequency
> 1 ? dm
.dmDisplayFrequency
: 0);
384 // emulation of ChangeDisplaySettingsEx() for Win95
385 LONG WINAPI
ChangeDisplaySettingsExForWin95(LPCTSTR
WXUNUSED(lpszDeviceName
),
389 LPVOID
WXUNUSED(lParam
))
391 return ::ChangeDisplaySettings(lpDevMode
, dwFlags
);
393 #endif // !__WXWINCE__
395 // ----------------------------------------------------------------------------
397 // ----------------------------------------------------------------------------
399 void wxDisplayModule::OnExit()
404 // ---------------------------------------------------------------------------
406 // ---------------------------------------------------------------------------
409 void wxDisplay::UseDirectX(bool useDX
)
411 wxCHECK_RET( !gs_displays
, _T("it is too late to call UseDirectX") );
414 // DirectDrawEnumerateEx requires Win98 or Win2k anyway.
415 if ( OsSupportsMultipleMonitors() ) gs_useDirectX
= useDX
;
421 // helper for GetFromPoint() and GetFromWindow()
422 static int DisplayFromHMONITOR(HMONITOR hmon
)
426 const size_t count
= wxDisplay::GetCount();
428 for ( size_t n
= 0; n
< count
; n
++ )
430 if ( hmon
== (*gs_displays
)[n
].m_hmon
)
439 size_t wxDisplayBase::GetCount()
441 if ( !OsSupportsMultipleMonitors() ) return 1;
445 //RN: FIXME: This is wrong - the display info array should reload after every call
446 //to GetCount() - otherwise it will not be accurate.
447 //The user can change the number of displays in display properties/settings
448 //after GetCount or similar is called and really mess this up...
449 //wxASSERT_MSG( gs_displays->GetCount() == (size_t)::GetSystemMetrics(SM_CMONITORS),
450 // _T("So how many displays does this system have?") );
452 return gs_displays
->GetCount();
456 int wxDisplayBase::GetFromPoint ( const wxPoint
& pt
)
458 if ( !OsSupportsMultipleMonitors() )
460 const wxSize size
= wxGetDisplaySize();
461 if (pt
.x
>= 0 && pt
.x
< size
.GetWidth() &&
462 pt
.y
>= 0 && pt
.y
< size
.GetHeight())
473 return DisplayFromHMONITOR(gs_MonitorFromPoint(pt2
, MONITOR_DEFAULTTONULL
));
477 int wxDisplayBase::GetFromWindow(wxWindow
*window
)
479 if ( !OsSupportsMultipleMonitors() )
481 const wxRect
r(window
->GetRect());
482 const wxSize size
= wxGetDisplaySize();
483 if (r
.x
< size
.GetWidth() && r
.x
+ r
.width
>= 0 &&
484 r
.y
< size
.GetHeight() && r
.y
+ r
.height
>= 0)
491 return DisplayFromHMONITOR
493 gs_MonitorFromWindow(GetHwndOf(window
), MONITOR_DEFAULTTONULL
)
497 // ----------------------------------------------------------------------------
498 // wxDisplay ctor/dtor
499 // ----------------------------------------------------------------------------
501 wxDisplay::wxDisplay ( size_t n
)
502 : wxDisplayBase ( n
)
504 if ( !OsSupportsMultipleMonitors() ) return;
506 // if we do this in ctor we won't have to call it from all the member
513 wxDisplayInfo
& dpyInfo
= (*gs_displays
)[n
];
515 LPDIRECTDRAW2
& pDD2
= dpyInfo
.m_pDD2
;
518 if ( !gs_DirectDrawCreate
)
525 HRESULT hr
= (*gs_DirectDrawCreate
)(&dpyInfo
.m_guid
, &pDD
, NULL
);
527 if ( FAILED(hr
) || !pDD
)
530 wxLogApiError(_T("DirectDrawCreate"), hr
);
532 else // got IDirectDraw, we want IDirectDraw2
534 hr
= pDD
->QueryInterface(wxIID_IDirectDraw2
, (void **)&pDD2
);
535 if ( FAILED(hr
) || !pDD2
)
537 wxLogApiError(_T("IDirectDraw::QueryInterface(IDD2)"), hr
);
543 //else: DirectDraw object corresponding to our display already exists
545 // increment its ref count to account for Release() in dtor
547 // NB: pDD2 will be only really Release()d when gs_displays is
548 // destroyed which is ok as we don't want to recreate DD objects
555 wxDisplay::~wxDisplay()
558 if ( !OsSupportsMultipleMonitors() ) return;
560 wxDisplayInfo
& dpyInfo
= (*gs_displays
)[m_index
];
562 LPDIRECTDRAW2
& pDD2
= dpyInfo
.m_pDD2
;
570 // ----------------------------------------------------------------------------
571 // wxDisplay simple accessors
572 // ----------------------------------------------------------------------------
574 bool wxDisplay::IsOk() const
577 return m_index
< GetCount() &&
578 (!gs_useDirectX
|| (*gs_displays
)[m_index
].m_pDD2
);
580 return m_index
< GetCount();
584 wxRect
wxDisplay::GetGeometry() const
586 if ( !OsSupportsMultipleMonitors() )
588 wxSize size
= wxGetDisplaySize();
589 return wxRect(0, 0, size
.GetWidth(), size
.GetHeight());
592 wxDisplayInfo
& dpyInfo
= (*gs_displays
)[m_index
];
593 wxRect
& rect
= dpyInfo
.m_rect
;
597 wxZeroMemory(monInfo
);
598 monInfo
.cbSize
= sizeof(monInfo
);
600 if ( !gs_GetMonitorInfo(dpyInfo
.m_hmon
, &monInfo
) )
602 wxLogLastError(_T("GetMonitorInfo"));
606 wxCopyRECTToRect(monInfo
.rcMonitor
, rect
);
613 wxString
wxDisplay::GetName() const
615 if ( !OsSupportsMultipleMonitors() ) return wxT("");
617 wxDisplayInfo
& dpyInfo
= (*gs_displays
)[m_index
];
618 if ( dpyInfo
.m_devName
.empty() )
620 MONITORINFOEX monInfo
;
621 wxZeroMemory(monInfo
);
622 monInfo
.cbSize
= sizeof(monInfo
);
624 // NB: Cast from MONITORINFOEX* to MONITORINFO* is done because
625 // Mingw headers - unlike the ones from Microsoft's Platform SDK -
626 // don't derive the former from the latter in C++ mode and so
627 // the pointer's type is not converted implicitly.
628 if ( !gs_GetMonitorInfo(dpyInfo
.m_hmon
, (LPMONITORINFO
)&monInfo
) )
630 wxLogLastError(_T("GetMonitorInfo"));
634 dpyInfo
.m_devName
= monInfo
.szDevice
;
638 return dpyInfo
.m_devName
;
641 // ----------------------------------------------------------------------------
642 // determine if this is the primary display
643 // ----------------------------------------------------------------------------
645 bool wxDisplay::IsPrimary() const
647 if ( !OsSupportsMultipleMonitors() ) return true;
649 wxDisplayInfo
& dpyInfo
= (*gs_displays
)[m_index
];
651 MONITORINFOEX monInfo
;
652 wxZeroMemory(monInfo
);
653 monInfo
.cbSize
= sizeof(monInfo
);
655 // NB: Cast from MONITORINFOEX* to MONITORINFO* is done because
656 // Mingw headers - unlike the ones from Microsoft's Platform SDK -
657 // don't derive the former from the latter in C++ mode and so
658 // the pointer's type is not converted implicitly.
659 if ( !gs_GetMonitorInfo(dpyInfo
.m_hmon
, (LPMONITORINFO
)&monInfo
) )
661 wxLogLastError(_T("GetMonitorInfo"));
664 return (monInfo
.dwFlags
& MONITORINFOF_PRIMARY
) == MONITORINFOF_PRIMARY
;
667 // ----------------------------------------------------------------------------
668 // video modes enumeration
669 // ----------------------------------------------------------------------------
673 wxDisplay::DoGetModesDirectX(const wxVideoMode
& WXUNUSED(modeMatch
)) const
675 wxArrayVideoModes modes
;
677 IDirectDraw2
*pDD
= (*gs_displays
)[m_index
].m_pDD2
;
681 HRESULT hr
= pDD
->EnumDisplayModes
684 NULL
, // all modes (TODO: use modeMatch!)
685 &modes
, // callback parameter
686 wxDDEnumModesCallback
691 wxLogApiError(_T("IDirectDraw::EnumDisplayModes"), hr
);
700 wxDisplay::DoGetModesWindows(const wxVideoMode
& modeMatch
) const
702 wxArrayVideoModes modes
;
704 // The first parameter of EnumDisplaySettings() must be NULL under Win95
705 // according to MSDN. The version of GetName() we implement for Win95
706 // returns an empty string.
707 const wxString name
= GetName();
708 const wxChar
* const deviceName
= name
.empty() ? NULL
: name
.c_str();
711 dm
.dmSize
= sizeof(dm
);
712 dm
.dmDriverExtra
= 0;
713 for ( int iModeNum
= 0;
714 ::EnumDisplaySettings(deviceName
, iModeNum
, &dm
);
717 const wxVideoMode mode
= ConvertToVideoMode(dm
);
718 if ( mode
.Matches(modeMatch
) )
727 wxArrayVideoModes
wxDisplay::GetModes(const wxVideoMode
& modeMatch
) const
730 return gs_useDirectX
? DoGetModesDirectX(modeMatch
)
731 : DoGetModesWindows(modeMatch
);
733 return DoGetModesWindows(modeMatch
);
737 wxVideoMode
wxDisplay::GetCurrentMode() const
741 // The first parameter of EnumDisplaySettings() must be NULL under Win95
742 // according to MSDN. The version of GetName() we implement for Win95
743 // returns an empty string.
744 const wxString name
= GetName();
745 const wxChar
* const deviceName
= name
.empty() ? NULL
: name
.c_str();
748 dm
.dmSize
= sizeof(dm
);
749 dm
.dmDriverExtra
= 0;
750 if ( !::EnumDisplaySettings(deviceName
, ENUM_CURRENT_SETTINGS
, &dm
) )
752 wxLogLastError(_T("EnumDisplaySettings(ENUM_CURRENT_SETTINGS)"));
756 mode
= ConvertToVideoMode(dm
);
762 // ----------------------------------------------------------------------------
763 // video mode switching
764 // ----------------------------------------------------------------------------
767 bool wxDisplay::DoChangeModeDirectX(const wxVideoMode
& mode
)
769 IDirectDraw2
*pDD
= (*gs_displays
)[m_index
].m_pDD2
;
773 wxWindow
*winTop
= wxTheApp
->GetTopWindow();
774 wxCHECK_MSG( winTop
, false, _T("top level window required for DirectX") );
776 HRESULT hr
= pDD
->SetCooperativeLevel
779 DDSCL_EXCLUSIVE
| DDSCL_FULLSCREEN
783 wxLogApiError(_T("IDirectDraw::SetCooperativeLevel"), hr
);
788 hr
= pDD
->SetDisplayMode(mode
.w
, mode
.h
, mode
.bpp
, mode
.refresh
, 0);
791 wxLogApiError(_T("IDirectDraw::SetDisplayMode"), hr
);
801 bool wxDisplay::DoChangeModeWindows(const wxVideoMode
& mode
)
803 // prepare ChangeDisplaySettingsEx() parameters
809 if ( mode
== wxDefaultVideoMode
)
811 // reset the video mode to default
815 else // change to the given mode
817 wxCHECK_MSG( mode
.w
&& mode
.h
, false,
818 _T("at least the width and height must be specified") );
821 dm
.dmSize
= sizeof(dm
);
822 dm
.dmDriverExtra
= 0;
823 dm
.dmFields
= DM_PELSWIDTH
| DM_PELSHEIGHT
;
824 dm
.dmPelsWidth
= mode
.w
;
825 dm
.dmPelsHeight
= mode
.h
;
829 dm
.dmFields
|= DM_BITSPERPEL
;
830 dm
.dmBitsPerPel
= mode
.bpp
;
835 dm
.dmFields
|= DM_DISPLAYFREQUENCY
;
836 dm
.dmDisplayFrequency
= mode
.refresh
;
843 #else // !__WXWINCE__
844 flags
= CDS_FULLSCREEN
;
845 #endif // __WXWINCE__/!__WXWINCE__
849 // get pointer to the function dynamically
851 // we're only called from the main thread, so it's ok to use static
853 static ChangeDisplaySettingsEx_t pfnChangeDisplaySettingsEx
= NULL
;
854 if ( !pfnChangeDisplaySettingsEx
)
856 wxDynamicLibrary
dllUser32(_T("user32.dll"));
857 if ( dllUser32
.IsLoaded() )
859 pfnChangeDisplaySettingsEx
= (ChangeDisplaySettingsEx_t
)
860 dllUser32
.GetSymbolAorW(_T("ChangeDisplaySettingsEx"));
862 //else: huh, no user32.dll??
865 if ( !pfnChangeDisplaySettingsEx
)
867 // we must be under Win95 and so there is no multiple monitors
869 pfnChangeDisplaySettingsEx
= ChangeDisplaySettingsExForWin95
;
871 #endif // !__WXWINCE__
874 // do change the mode
875 switch ( pfnChangeDisplaySettingsEx
877 GetName(), // display name
878 pDevMode
, // dev mode or NULL to reset
881 NULL
// pointer to video parameters (not used)
884 case DISP_CHANGE_SUCCESSFUL
:
887 // If we have a top-level, full-screen frame, emulate
888 // the DirectX behavior and resize it. This makes this
889 // API quite a bit easier to use.
890 wxWindow
*winTop
= wxTheApp
->GetTopWindow();
891 wxFrame
*frameTop
= wxDynamicCast(winTop
, wxFrame
);
892 if (frameTop
&& frameTop
->IsFullScreen())
894 wxVideoMode current
= GetCurrentMode();
895 frameTop
->SetClientSize(current
.w
, current
.h
);
900 case DISP_CHANGE_BADMODE
:
901 // don't complain about this, this is the only "expected" error
905 wxFAIL_MSG( _T("unexpected ChangeDisplaySettingsEx() return value") );
911 bool wxDisplay::ChangeMode(const wxVideoMode
& mode
)
914 return gs_useDirectX
? DoChangeModeDirectX(mode
)
915 : DoChangeModeWindows(mode
);
917 return DoChangeModeWindows(mode
);
921 #endif // wxUSE_DISPLAY