Release the HDC in wxGetSystemMetrics and wxSystemParametersInfo
Use WindowHDC instead of calling ::GetDC() manually and never calling ::ReleaseDC() on it. Closes https://github.com/wxWidgets/wxWidgets/pull/1437
This commit is contained in:
committed by
Vadim Zeitlin
parent
211a42ef12
commit
37f806f1d6
@@ -4750,8 +4750,9 @@ int wxGetSystemMetrics(int nIndex, const wxWindow* win)
|
||||
|
||||
if ( s_pfnGetSystemMetricsForDpi )
|
||||
{
|
||||
const int y = ::GetDeviceCaps(::GetDC(tlw->GetHWND()), LOGPIXELSY);
|
||||
return s_pfnGetSystemMetricsForDpi(nIndex, (UINT)y);
|
||||
WindowHDC hdc(tlw->GetHWND());
|
||||
const int dpi = ::GetDeviceCaps(hdc, LOGPIXELSY);
|
||||
return s_pfnGetSystemMetricsForDpi(nIndex, (UINT)dpi);
|
||||
}
|
||||
}
|
||||
#else
|
||||
@@ -4782,8 +4783,9 @@ bool wxSystemParametersInfo(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWi
|
||||
|
||||
if ( s_pfnSystemParametersInfoForDpi )
|
||||
{
|
||||
const int y = ::GetDeviceCaps(::GetDC(tlw->GetHWND()), LOGPIXELSY);
|
||||
if ( s_pfnSystemParametersInfoForDpi(uiAction, uiParam, pvParam, fWinIni, y) == TRUE )
|
||||
WindowHDC hdc(tlw->GetHWND());
|
||||
const int dpi = ::GetDeviceCaps(hdc, LOGPIXELSY);
|
||||
if ( s_pfnSystemParametersInfoForDpi(uiAction, uiParam, pvParam, fWinIni, (UINT)dpi) == TRUE )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user