コード例 #1
0
ファイル: w32dc.cpp プロジェクト: kant/livecode
// IM-2014-01-28: [[ HiDPI ]] Return the DPI scale factor of the given monitor.
//   For system-DPI-aware applications this will be the global system DPI value.
//   For Per-Monitor-DPI-aware applications, this will be the effective DPI scale of the given monitor
bool MCWin32GetMonitorPixelScale(HMONITOR p_monitor, MCGFloat &r_pixel_scale)
{
	uint32_t t_xdpi, t_ydpi;

	// try to get per-monitor DPI setting
	if (!MCWin32GetDPIForMonitor(p_monitor, t_xdpi, t_ydpi) &&
		// fallback to the global system DPI setting
		!MCWin32GetScreenDPI(t_xdpi, t_ydpi))
			return false;

	r_pixel_scale = (MCGFloat)MCMax(t_xdpi, t_ydpi) / NORMAL_DENSITY;

	return true;
}
コード例 #2
0
ファイル: w32dc.cpp プロジェクト: alilloyd/livecode
// IM-2014-01-28: [[ HiDPI ]] Return the DPI scale factor of the given monitor.
//   For system-DPI-aware applications this will be the global system DPI value.
//   For Per-Monitor-DPI-aware applications, this will be the effective DPI scale of the given monitor
bool MCWin32GetMonitorPixelScale(HMONITOR p_monitor, MCGFloat &r_pixel_scale)
{
	UINT t_xdpi, t_ydpi;
	HRESULT t_result;
	
	// try to get per-monitor DPI setting
	if (!MCWin32GetDPIForMonitor(t_result, p_monitor, kMCWin32MDTDefault, &t_xdpi, &t_ydpi) ||
		t_result != S_OK)
	{
		// fallback to the global system DPI setting
		uint32_t t_screen_xdpi, t_screen_ydpi;
		if (!MCWin32GetScreenDPI(t_screen_xdpi, t_screen_ydpi))
			return false;
		t_xdpi = t_screen_xdpi;
		t_ydpi = t_screen_ydpi;
	}

	r_pixel_scale = (MCGFloat)MCMax(t_xdpi, t_ydpi) / NORMAL_DENSITY;

	return true;
}