2

I am working on an app that basically capture an application and draw it in openGL.

I first get a valid HWND and want to retrieve all the other windows that are related to it. I fetch all those by using the main HWND pid. I put all of them in a list (standard std::list)

HWND tmpWindowHandle = GetTopWindow(NULL);
while(tmpWindowHandle!=NULL){
    DWORD pid;
    DWORD currentWindowPid;
    GetWindowThreadProcessId(tmpWindowHandle,&pid);
    GetWindowThreadProcessId(this->hwnd,&currentWindowPid);
    if(pid==currentWindowPid && tmpWindowHandle != this->hwnd){
        MyWindow* child = new MyWindow("child",tmpWindowHandle,NULL);
        //child->findAllChilds(); <= Recursivity for later
        childList.push_front(child);
    }
    tmpWindowHandle = GetNextWindow(tmpWindowHandle,GW_HWNDNEXT);
}

After this, I get in childList all the windows that do have the same PID as the main HWND (sorted by z-oder)

The second step of my app is to get the bitmap of the specified HWND and to draw it on a surface. I plot them according to the zorder.

drawWindow(HWND hwnd, float zorder) is a function that get the BITMAP of the hwnd handle, and draw it at zorder.

drawWindow(parent, -15);
for(int i = 0; i < currentWindow->childList.size()%10;i++){
  MyWindow* child = currentWindow->childList.back();
  currentWindow->childList.pop_back();
  float deltaZOrder = (float)(currentWindow->childList.size()-i)/currentWindow->childList.size();
  drawWindow(child,zOrder+deltaZOrder);
  currentWindow->childList.push_front(child);
}

To be more practical, is here what I get when I set the main HWND to be the HWND of a paint windows.

Paint drawn in openGL

Unfortunately, when it comes to drawing "sisters" (not using the term child because it would mean something else in winapi terminology), I do get weird black cross over my childs :

enter image description here

Do you have any idea what could cause such a behaviour ? My feeling is that there is some windows that also have the same PID that are black and superimpose with the other "visible" windows. My draw function test if the window is visible (if(IsWindowVisible(currentWindow->hwnd)){) so I do not get why they are visible anyway as they do not appear on the regular mspaint.exe

Al_th
  • 1,174
  • 1
  • 12
  • 24
  • 1
    Notice that the menu has a drop shadow, which is implemented by the window manager. The black box you're seeing is likely the image used to create the drop shadow, but without taking account of any transparency. You will find that the menu window will likely have the `CS_DROPSHADOW` style. How it's drawn... I don't know. Perhaps you need to capture the alpha channel too? – icabod Mar 28 '14 at 11:14
  • Nice catch ! I apparently missed that yesterday evening because I did not even think of what was visible beneath the black lines ... I will investigate on this, but definitely thanks for the input. – Al_th Mar 28 '14 at 14:10

0 Answers0