[MFC] how to get screen width, height

in programming •  6 years ago  (edited)

GetWindowRect(), GetDesktopWindow()

CRect rc;
::GetWindowRect(GetDesktopWindow()->m_hWnd, &rc);
int nWidth = rc.right - rc.left;
int nHeight = rc.bottom - rc.top;

GetSystemMetrics()

int nWidth = GetSystemMetrics(SM_CXSCREEN);
int nHeight = GetSystemMetrics(SM_CYSCREEN);

GetDeviceCaps()

HDC hDC = GetDC();
int nWidth = GetDeviceCaps(hDC, HORZRES);
int nHeight = GetDeviceCaps(hDC, VERTRES);
Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

@pepsiman, I gave you an upvote on your first post! Please give me a follow and I will give you a follow in return!

Please also take a moment to read this post regarding bad behavior on Steemit.