EnumDisplayMonitors from HDC

1
2
3
4
5
6
7
8
	HDC monitorDC = (CreateDC(displayDevices[0].DeviceName, displayDevices[0].DeviceName, NULL, NULL));

	i = 0;
	while (i < 1200)
	{
		std::cout << (INT)GetRValue(GetPixel(monitorDC, i, i)) << " " << (INT)GetGValue(GetPixel(monitorDC, i, i)) << " " << (INT)GetBValue(GetPixel(monitorDC, i, i)) << " " << std::endl;
		i++;
	}


This is just to test that it has accessed the first monitor and the handle is valid. When I tested this and anything moved, such as the console, I could see real-time results (So HDC is good).

When I try:

EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, 0);

The CALLBACK returns true and works correctly, however when I try:

EnumDisplayMonitors(monitorDC, NULL, MonitorEnumProc, 0);

The CALLBACK returns false. Even though it **appears** that the HDC is valid and stating the MSDN:
Enumerates all display monitors that intersect the visible region of the device context.
**The callback function receives a handle to a DC for the specific display monitor.** but the BOOL always returns false using the above code.
Registered users can post here. Sign in or register to post.