Get size (rectangle) of complete virtual screen (all display monitors together)



Here is the code to get the complete virtual screen rectangle that includes all display monitors. Code is in C++/MFC.

//gets the coordinates of the complete virtual screen which is includes all the monitors present
CRect GetVirtualScreenRect()
{
	CRect rcVirtualScreen;
	rcVirtualScreen.left = GetSystemMetrics(SM_XVIRTUALSCREEN);
	rcVirtualScreen.top = GetSystemMetrics(SM_YVIRTUALSCREEN);
	rcVirtualScreen.right = rcVirtualScreen.left + GetSystemMetrics(SM_CXVIRTUALSCREEN);
	rcVirtualScreen.bottom = rcVirtualScreen.top + GetSystemMetrics(SM_CYVIRTUALSCREEN);
 
	return rcVirtualScreen;
}

Leave a Reply

Your email address will not be published. Required fields are marked *