I have a
HWND for a window. I have double checked that it is a 100% valid window by using
SetForegroundWindow() on it, successfully bringing it to the frontmost window. However whenever I try to use
GetPixel on it it returns -1 (0xFFFFFFFF). What am I doing wrong? Here is a sample of what I am talking about:
HWND myWindow=FindWindow(NULL,"Test Window"); if (!myWindow)return; SetActiveWindow(myWindow); SetFocus(myWindow); SetForegroundWindow(myWindow); //now the window with title text "Test Window" is active, focussed and in the foreground uint32_t pxl=GetPixel(GetDC(myWindow),500,500); //pxl ALWAYS equals 0xFFFFFFFF here... why?!
I have used pretty much identical code before without this problem, why am I getting it now?
The only difference I can see is that this time the x and y coordinates are stored in a global variable for ease of use with my multi-threaded functions (threaded with
CreateThread). Can anybody tell me why I can't seem to access the pixels of my window?