Remove dynamic loading of Display APIs.
ChangeDisplaySettingsEx, EnumDisplayMonitors, MonitorFromPoint, MonitorFromWindow and GetMonitorInfo are available since Win2k.
This commit is contained in:
@@ -70,32 +70,6 @@
|
|||||||
|
|
||||||
static const wxChar displayDllName[] = wxT("user32.dll");
|
static const wxChar displayDllName[] = wxT("user32.dll");
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// typedefs for dynamically loaded Windows functions
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
typedef LONG (WINAPI *ChangeDisplaySettingsEx_t)(LPCTSTR lpszDeviceName,
|
|
||||||
LPDEVMODE lpDevMode,
|
|
||||||
HWND hwnd,
|
|
||||||
DWORD dwFlags,
|
|
||||||
LPVOID lParam);
|
|
||||||
|
|
||||||
typedef BOOL (WINAPI *EnumDisplayMonitors_t)(HDC,LPCRECT,MONITORENUMPROC,LPARAM);
|
|
||||||
typedef HMONITOR (WINAPI *MonitorFromPoint_t)(POINT,DWORD);
|
|
||||||
typedef HMONITOR (WINAPI *MonitorFromWindow_t)(HWND,DWORD);
|
|
||||||
typedef BOOL (WINAPI *GetMonitorInfo_t)(HMONITOR,LPMONITORINFO);
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxDisplayMSW declaration
|
// wxDisplayMSW declaration
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -148,12 +122,6 @@ private:
|
|||||||
|
|
||||||
WX_DEFINE_ARRAY(HMONITOR, wxMonitorHandleArray);
|
WX_DEFINE_ARRAY(HMONITOR, wxMonitorHandleArray);
|
||||||
|
|
||||||
// functions dynamically bound by wxDisplayFactoryMSW ctor.
|
|
||||||
static MonitorFromPoint_t gs_MonitorFromPoint = NULL;
|
|
||||||
static MonitorFromWindow_t gs_MonitorFromWindow = NULL;
|
|
||||||
static GetMonitorInfo_t gs_GetMonitorInfo = NULL;
|
|
||||||
static EnumDisplayMonitors_t gs_EnumDisplayMonitors = NULL;
|
|
||||||
|
|
||||||
class wxDisplayFactoryMSW : public wxDisplayFactory
|
class wxDisplayFactoryMSW : public wxDisplayFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -236,7 +204,7 @@ wxDisplayFactoryMSW* wxDisplayFactoryMSW::ms_factory = NULL;
|
|||||||
|
|
||||||
bool wxDisplayMSW::GetMonInfo(MONITORINFOEX& monInfo) const
|
bool wxDisplayMSW::GetMonInfo(MONITORINFOEX& monInfo) const
|
||||||
{
|
{
|
||||||
if ( !gs_GetMonitorInfo(m_hmon, &monInfo) )
|
if ( !::GetMonitorInfo(m_hmon, &monInfo) )
|
||||||
{
|
{
|
||||||
wxLogLastError(wxT("GetMonitorInfo"));
|
wxLogLastError(wxT("GetMonitorInfo"));
|
||||||
return false;
|
return false;
|
||||||
@@ -390,30 +358,8 @@ bool wxDisplayMSW::ChangeMode(const wxVideoMode& mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 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??
|
|
||||||
|
|
||||||
if ( !pfnChangeDisplaySettingsEx )
|
|
||||||
{
|
|
||||||
// we must be under Win95 and so there is no multiple monitors
|
|
||||||
// support anyhow
|
|
||||||
pfnChangeDisplaySettingsEx = ChangeDisplaySettingsExForWin95;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// do change the mode
|
// do change the mode
|
||||||
switch ( pfnChangeDisplaySettingsEx
|
switch ( ::ChangeDisplaySettingsEx
|
||||||
(
|
(
|
||||||
GetName().t_str(), // display name
|
GetName().t_str(), // display name
|
||||||
pDevMode, // dev mode or NULL to reset
|
pDevMode, // dev mode or NULL to reset
|
||||||
@@ -478,25 +424,6 @@ wxDisplayFactoryMSW::wxDisplayFactoryMSW()
|
|||||||
m_hiddenHwnd = NULL;
|
m_hiddenHwnd = NULL;
|
||||||
m_hiddenClass = NULL;
|
m_hiddenClass = NULL;
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
DoRefreshMonitors();
|
DoRefreshMonitors();
|
||||||
|
|
||||||
// Also create a hidden window to listen for WM_SETTINGCHANGE that we
|
// Also create a hidden window to listen for WM_SETTINGCHANGE that we
|
||||||
@@ -535,7 +462,7 @@ void wxDisplayFactoryMSW::DoRefreshMonitors()
|
|||||||
{
|
{
|
||||||
m_displays.Clear();
|
m_displays.Clear();
|
||||||
|
|
||||||
if ( !gs_EnumDisplayMonitors(NULL, NULL, MultimonEnumProc, (LPARAM)this) )
|
if ( !::EnumDisplayMonitors(NULL, NULL, MultimonEnumProc, (LPARAM)this) )
|
||||||
{
|
{
|
||||||
wxLogLastError(wxT("EnumDisplayMonitors"));
|
wxLogLastError(wxT("EnumDisplayMonitors"));
|
||||||
}
|
}
|
||||||
@@ -586,14 +513,14 @@ int wxDisplayFactoryMSW::GetFromPoint(const wxPoint& pt)
|
|||||||
pt2.x = pt.x;
|
pt2.x = pt.x;
|
||||||
pt2.y = pt.y;
|
pt2.y = pt.y;
|
||||||
|
|
||||||
return FindDisplayFromHMONITOR(gs_MonitorFromPoint(pt2,
|
return FindDisplayFromHMONITOR(::MonitorFromPoint(pt2,
|
||||||
MONITOR_DEFAULTTONULL));
|
MONITOR_DEFAULTTONULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxDisplayFactoryMSW::GetFromWindow(const wxWindow *window)
|
int wxDisplayFactoryMSW::GetFromWindow(const wxWindow *window)
|
||||||
{
|
{
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
return FindDisplayFromHMONITOR(gs_MonitorFromWindow(GetHwndOf(window),
|
return FindDisplayFromHMONITOR(::MonitorFromWindow(GetHwndOf(window),
|
||||||
MONITOR_DEFAULTTONULL));
|
MONITOR_DEFAULTTONULL));
|
||||||
#else
|
#else
|
||||||
const wxSize halfsize = window->GetSize() / 2;
|
const wxSize halfsize = window->GetSize() / 2;
|
||||||
|
Reference in New Issue
Block a user