Arkady wrote:
hDC = GetDC( GetDesktopWindow() );
GetDesktopWindow() returns the HWND of the desktop window (the window hosting
the ListView for the desktop icons, the taskbar, etc). To get the HDC of
the screen itself, use GetDC(0) instead.
Color = C->Pixels[1100][1100];
The Pixels[][] property is just a wrapper for the Win32 GetPixel() function.
So if you are going to use the Win32 API directly to get the HDC, you may
as well use the Win32 API directly to get the pixel, too.
HDC hDC = GetDC(0);
TColor Color = (TColor) GetPixel(hDC, 1100, 1100);
ReleaseDC(0, hDC);
ShowMessage( Format( "0x%.8X", ARRAYOFCONST( ( Color ) ) ) );
ReleaseDC( NULL, hDC );
When calling ReleaseDC(), you have to specify the same HWND that you specifiy
to GetDC(). If you use GetDesktopWindow() in GetDC(), NULL in ReleaseDC()
will leak the HDC.
--
Remy Lebeau (TeamB)
Connect with Us