0

So far i have gotten GetPixel() to do pretty much exactly what I want it to do inside of the client window. But, is there any way I can get the color of pixels outside the client window?


Heres my current code:

HDC     hDC;
     PAINTSTRUCT ps;
     hDC = BeginPaint(hWnd, &ps);
     POINT pt;
     GetCursorPos(&pt);
     ScreenToClient(hWnd, &pt);
     COLORREF rgb = GetPixel(hDC, pt.x, pt.y);
     paint(hDC, rgb);
     EndPaint(hWnd, &ps);

hWnd is a global variable containing the HWND of the client window paint(hDC, rgb) is a function that draws a line across the window with the color rgb

2
Contributors
3
Replies
6
Views
9 Years
Discussion Span
Last Post by prushik
0

GetWindowDesktop() only returns the HWND of the desktop.
I tried the following code, but it always returns black:

HWND desk = GetDesktopWindow(); 
     hDC = GetDC(desk);
     POINT pt;
     GetCursorPos(&pt);
     //ScreenToClient(hWnd, &pt);
     COLORREF rgb = GetPixel(hDC, pt.x, pt.y);
0

ok, nevermind, i got it.

I just used HWND_DESKTOP instead of GetDesktopWindow()

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.