Organizational Research By

Surprising Reserch Topic

how can i get the pixel of the covered window

how can i get the pixel of the covered window  using -'c++,c,winapi'

I am using Visual Studio 2008 on Windows XP and studying C++.
I am curious about the getting pixel from desktop.
Can I get the screen pixel with GetPixel function in the case that the window is covered with another window?  In the status of my window being covered, I was trying to call the GetPixel:

GetPixel(hdc, x, y);

But this call dosen't retrieve the pixel of the original window but the covering window or other color one.  

How can I get the pixel of the covered window?

I add my code as the following ...

VOID GetDisplay(HWND& hwnd, RECT& area, COLORREF (*display)[1000]) {
    HDC hdc=GetDC(hwnd);
    for(INT x=area.left;x<=area.right;x++) {
        for(int;y<=area.bottom;y++) {
            display[x][y]=GetPixel(hdc, x, y);
    ReleaseDC(hwnd, hdc);


SetWindowPos(hwnd, HWND_TOPMOST, 300, 300, 500, 350, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE);
//EnableWindow(hwnd, TRUE);

GetDisplay(hwnd, within_wall, display);//trouble

The problem is causing on the GetPixel in GetDisplay.  GetPixel is returning the pixel color of the covering window.

asked Sep 9, 2015 by TawnyaHaskin
0 votes

Related Hot Questions

1 Answer

0 votes
answered Sep 9, 2015 by MylesPmwhibx