API:
要取得屏幕大小,可以用下面几个函数:
int cx = GetSystemMetrics( SM_CXFULLSCREEN ); int cy = GetSystemMetrics( SM_CYFULLSCREEN );
通过上边两个函数获取的是 显示屏幕的大小,但不包括任务栏等区域。
int cx = GetSystemMetrics( SM_CXSCREEN ); int cy = GetSystemMetrics( SM_CYSCREEN );
这两个函数获取的是真正屏幕的大小。MFC:
HDC hDC = :: GetDC( HWND( NULL)); // 得到屏幕DC int x = :: GetDeviceCaps(hDC, HORZRES); // 宽 int y = :: GetDeviceCaps(hDC, VERTRES); // 高 :: ReleaseDC( HWND( NULL),hDC); // 释放DC