1. Difference between resolution and DPI:
Resolution: 显示器width*height有多大
DPI: 每 Inch 显示多少个点(dot)
DPI: 每 Inch 显示多少个点(dot)
2. How to get resolution:
a)
unsigned int w = ::GetSystemMetrics(SM_CXSCREEN);
unsigned int h = ::GetSystemMetrics(SM_CYSCREEN);
unsigned int h = ::GetSystemMetrics(SM_CYSCREEN);
b)
RECT rect;
::GetWindowRect(::GetDesktopWindow(), &rect);
unsigned int w = ::abs(rect.right - rect.left);
unsigned int h = ::abs(rect.bottom - rect.top);
::GetWindowRect(::GetDesktopWindow(), &rect);
unsigned int w = ::abs(rect.right - rect.left);
unsigned int h = ::abs(rect.bottom - rect.top);
3. How to get DPI:
HDC hDC = ::GetDC(0);
int dpiX = ::GetDeviceCaps(hDC, LOGPIXELSX);
int dpiY = ::GetDeviceCaps(hDC, LOGPIXELSY);
int dpiX = ::GetDeviceCaps(hDC, LOGPIXELSX);
int dpiY = ::GetDeviceCaps(hDC, LOGPIXELSY);
本文详细解释了分辨率和DPI的区别:分辨率指显示器的宽高像素数,而DPI则是每英寸显示的点数。文中提供了获取这两种参数的具体方法,包括使用Windows API函数GetSystemMetrics获取屏幕分辨率及通过GetDeviceCaps获取DPI。
4060

被折叠的 条评论
为什么被折叠?



