Simply put, I'm trying to get the X and Y dimensions of my screen. I tried the below source, but the GetViewportExtEx() function only loads a 1 into both cx and cy. It looks as though it should work, but doesn't.
////////////////////////////////////////////////////////////
HDC hToScreenDC; SIZE screensize; long x, y;
hToWindowDC = GetDC(NULL); GetViewportExtEx(hToScreenDC, &screensize)
x = screensize.cx; y = screensize.cy;
ReleaseDC(NULL, hToScreenDC);
/////////////////////////////////////////////////////////////
All I want to do is center my application window on the screen. I'm very curious as to why this isn't working. Any help would be appreciated. Thanx
I made an error while typing this. The problem still persists. Ignore the above typo
////////////////////////////////////// hToScreenDC = GetDC(NULL); //////////////////////////////////////
GetViewportExtEx(hToScreenDC, &screensize)
Got it!
// width int cx = GetSystemMetrics(SM_CXSCREEN); // height int cy = GetSystemMetrics(SM_CYSCREEN);
I'm still curious why GetViewportExtEx() was returning only 1 has the X and Y dimension.
Log in to post a comment.
Simply put, I'm trying to get the X and Y dimensions of my screen. I tried the below source, but the GetViewportExtEx() function only loads a 1 into both cx and cy. It looks as though it should work, but doesn't.
////////////////////////////////////////////////////////////
HDC hToScreenDC;
SIZE screensize;
long x, y;
hToWindowDC = GetDC(NULL);
GetViewportExtEx(hToScreenDC, &screensize)
x = screensize.cx;
y = screensize.cy;
ReleaseDC(NULL, hToScreenDC);
/////////////////////////////////////////////////////////////
All I want to do is center my application window on the screen. I'm very curious as to why this isn't working. Any help would be appreciated. Thanx
I made an error while typing this. The problem still persists. Ignore the above typo
////////////////////////////////////////////////////////////
HDC hToScreenDC;
SIZE screensize;
long x, y;
//////////////////////////////////////
hToScreenDC = GetDC(NULL);
//////////////////////////////////////
GetViewportExtEx(hToScreenDC, &screensize)
x = screensize.cx;
y = screensize.cy;
ReleaseDC(NULL, hToScreenDC);
/////////////////////////////////////////////////////////////
Got it!
// width
int cx = GetSystemMetrics(SM_CXSCREEN);
// height
int cy = GetSystemMetrics(SM_CYSCREEN);
I'm still curious why GetViewportExtEx() was returning only 1 has the X and Y dimension.