Click to See Complete Forum and Search --> : Determining the color of a pixel if application is hidden


kurtk
January 27th, 2006, 04:18 AM
Hello,

I would like to determine the color of a pixel in an application (this could be any application, not neccessarily my own) even if the application window is hidden by another application. For example pixel (10, 50) in relative coordinates of this specific application. Is this possible, and how?

Thank you very much for any help.

kkez
January 27th, 2006, 04:32 AM
Did you try GetWindowDC()? You can try PrintWindow() too...

golanshahar
January 27th, 2006, 04:50 AM
Hello,

I would like to determine the color of a pixel in an application (this could be any application, not neccessarily my own) even if the application window is hidden by another application. For example pixel (10, 50) in relative coordinates of this specific application. Is this possible, and how?

Thank you very much for any help.

this might help you: Capturing Windows Regardless of Their Z-Order (http://www.codeguru.com/cpp/g-m/gdi/capturingimages/article.php/c11231/) ;)

Cheers

kkez
January 27th, 2006, 07:36 AM
From the source file of the article:
BOOL CaptureEx::Capture( HWND hwnd,HDC memDC)
{
typedef BOOL (WINAPI *tPrintWindow)( HWND, HDC,UINT);

tPrintWindow pPrintWindow = 0;
HINSTANCE handle = ::LoadLibrary("User32.dll");
if ( handle == 0 )
return FALSE;

pPrintWindow = (tPrintWindow)::GetProcAddress(handle, "PrintWindow");
int Ret = TRUE;
if ( pPrintWindow )
Ret = pPrintWindow(hwnd, memDC,0 );
else
{
::AfxMessageBox("cant gain address of PrintWindow(..) api\nplease update your sdk");
Ret = FALSE;
}
::FreeLibrary(handle);
return (Ret? TRUE: FALSE);
}

So my suggestion about PrintWindow was correct :)
EDIT: that function is available only under xp...