[MFC] how to get screen width, height

in #programming7 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);
Sort:  

@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.

Coin Marketplace

STEEM 0.14
TRX 0.25
JST 0.031
BTC 83613.24
ETH 1597.03
USDT 1.00
SBD 0.78