要取得屏幕大小,可以用下面幾個函數:
int cx = GetSystemMetrics( SM_CXFULLSCREEN );
int cy = GetSystemMetrics( SM_CYFULLSCREEN );
int cy = GetSystemMetrics( SM_CYFULLSCREEN );
通過上邊兩個函數獲取的是 顯示屏幕的大小,但不包括任務欄等區域。
int cx = GetSystemMetrics( SM_CXSCREEN );
int cy = GetSystemMetrics( SM_CYSCREEN );
int cy = GetSystemMetrics( SM_CYSCREEN );
這兩個函數獲取的是真正屏幕的大小。
MFC:
MFC:
HDC hDC = ::GetDC(HWND(NULL)); // 得到屏幕DC
int x = ::GetDeviceCaps(hDC,HORZRES); // 寬
int y = ::GetDeviceCaps(hDC,VERTRES); // 高
::ReleaseDC(HWND(NULL),hDC); // 釋放DC
int x = ::GetDeviceCaps(hDC,HORZRES); // 寬
int y = ::GetDeviceCaps(hDC,VERTRES); // 高
::ReleaseDC(HWND(NULL),hDC); // 釋放DC


