子弹 の VISIONS

NEVER back down ~~

C++博客 首页 新随笔 联系 聚合 管理
  112 Posts :: 34 Stories :: 99 Comments :: 0 Trackbacks


1. Difference between resolution and DPI:

Resolution: 显示器width*height有多大
DPI: 每 Inch 显示多少个点(dot)

2. How to get resolution:

a)
unsigned int w = ::GetSystemMetrics(SM_CXSCREEN);
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);

3. How to get DPI:

HDC hDC = ::GetDC(0);
int dpiX = ::GetDeviceCaps(hDC, LOGPIXELSX);
int dpiY = ::GetDeviceCaps(hDC, LOGPIXELSY);
// dpiX == dpiY

posted on 2009-01-17 23:14 子弹のVISIONS 阅读(893) 评论(0)  编辑 收藏 引用 所属分类: 2.2 GDI API

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理