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;
     hDC = BeginPaint(hWnd, &ps);
     POINT 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

Recommended Answers

All 3 Replies

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;
     //ScreenToClient(hWnd, &pt);
     COLORREF rgb = GetPixel(hDC, pt.x, pt.y);

ok, nevermind, i got it.

I just used HWND_DESKTOP instead of GetDesktopWindow()

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.