Backends: Win32: Support for #define NOGDI, won't try to call GetDeviceCaps(). (#3137, #2327)

This commit is contained in:
omar 2020-04-19 17:52:09 +02:00
parent 388bf66247
commit 37f665b619
2 changed files with 4 additions and 1 deletions

View File

@ -43,6 +43,7 @@ Other Changes:
flag was also set, and _OpenOnArrow is frequently set along with _OpenOnDoubleClick). flag was also set, and _OpenOnArrow is frequently set along with _OpenOnDoubleClick).
- TreeNode: Fixed bug where dragging a payload over a TreeNode() with either _OpenOnDoubleClick - TreeNode: Fixed bug where dragging a payload over a TreeNode() with either _OpenOnDoubleClick
or _OpenOnArrow would open the node. (#143) or _OpenOnArrow would open the node. (#143)
- Backends: Win32: Support for #define NOGDI, won't try to call GetDeviceCaps(). (#3137, #2327)
----------------------------------------------------------------------- -----------------------------------------------------------------------

View File

@ -408,7 +408,7 @@ void ImGui_ImplWin32_EnableDpiAwareness()
SetProcessDPIAware(); SetProcessDPIAware();
} }
#ifdef _MSC_VER #if defined(_MSC_VER) && !defined(NOGDI)
#pragma comment(lib, "gdi32") // Link with gdi32.lib for GetDeviceCaps() #pragma comment(lib, "gdi32") // Link with gdi32.lib for GetDeviceCaps()
#endif #endif
@ -421,6 +421,7 @@ float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor)
if (PFN_GetDpiForMonitor GetDpiForMonitorFn = (PFN_GetDpiForMonitor)::GetProcAddress(shcore_dll, "GetDpiForMonitor")) if (PFN_GetDpiForMonitor GetDpiForMonitorFn = (PFN_GetDpiForMonitor)::GetProcAddress(shcore_dll, "GetDpiForMonitor"))
GetDpiForMonitorFn((HMONITOR)monitor, MDT_EFFECTIVE_DPI, &xdpi, &ydpi); GetDpiForMonitorFn((HMONITOR)monitor, MDT_EFFECTIVE_DPI, &xdpi, &ydpi);
} }
#ifndef NOGDI
else else
{ {
const HDC dc = ::GetDC(NULL); const HDC dc = ::GetDC(NULL);
@ -428,6 +429,7 @@ float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor)
ydpi = ::GetDeviceCaps(dc, LOGPIXELSY); ydpi = ::GetDeviceCaps(dc, LOGPIXELSY);
::ReleaseDC(NULL, dc); ::ReleaseDC(NULL, dc);
} }
#endif
IM_ASSERT(xdpi == ydpi); // Please contact me if you hit this assert! IM_ASSERT(xdpi == ydpi); // Please contact me if you hit this assert!
return xdpi / 96.0f; return xdpi / 96.0f;
} }