Reputation: 145
I need to get the maximum possible height and width of a window being created (window is not maximized first). How to do it?
Upvotes: 5
Views: 3475
Reputation: 15355
You can use GetSystemMetrics with SM_CXSCREEN
and SM_CYSCREEN
. This is the width and height off your primary display monitor.
Another way would be to determine the desktop workarea size:
CRect rectWorkArea;
SystemParametersInfo(SPI_GETWORKAREA,0,&rectWorkArea,0);
Or to determine the size of the work area of a specific monitor were your window exists
CRect rectWorkArea;
MONITORINFO mi;
mi.cbSize = sizeof(mi);
::GetMonitorInfo(::MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST), &mi);
rectWorkArea = mi.rcWork;
MONITORINFO
also contains the monitor size.
Depends what you need to do.
Upvotes: 2
Reputation: 4395
You can get screen height and width, and pass that value to get maximum possible size of window.
Try this:
int X = GetSystemMetrics( SM_CXSCREEN );
int Y = GetSystemMetrics( SM_CYSCREEN );
Here in X
you will get the Width of the screen.
And in Y
you will get the Height of the screen.
Upvotes: 2