MCPcopy Create free account
hub / github.com/PenguLoader/PenguLoader / get_scaling

Method get_scaling

core/src/utils/window.cc:145–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145float window::get_scaling(void *hwnd)
146{
147 const int MDT_EFFECTIVE_DPI = 0;
148 auto getDpiForMonitor = getfunc("shcore.dll", GetDpiForMonitor);
149
150 int dpi = 0;
151 if (getDpiForMonitor) {
152 UINT hdpi_uint, vdpi_uint;
153 HMONITOR hmom = MonitorFromWindow(static_cast<HWND>(hwnd), MONITOR_DEFAULTTONEAREST);
154 if (getDpiForMonitor(hmom, MDT_EFFECTIVE_DPI, &hdpi_uint, &vdpi_uint) == S_OK) {
155 dpi = static_cast<int>(hdpi_uint);
156 }
157 }
158 else {
159 HDC hdc = GetDC(NULL);
160 if (hdc) {
161 dpi = GetDeviceCaps(hdc, LOGPIXELSX);
162 ReleaseDC(NULL, hdc);
163 }
164 }
165
166 if (dpi == 0)
167 dpi = 96;
168
169 return dpi / 96.0f;
170}
171
172void window::make_foreground(void *hwnd)
173{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected