finding handle of child window

  • Thread starter Thread starter Abhishek
  • Start date Start date
A

Abhishek

Hi All,

how do I find the handle of a child window and get a screenshot of that
in a hbitmap at present i tried the below method but am getting the
screenshot of the desktop. the Egyptian Addiction is the name of the game
and the mozillacontentwindowclass is the handle i need who's window i want
to capture

int nScreenWidth = 300;
int nScreenHeight = 225;
//hwnd1 = FindWindow( NULL, "Egyptian Addiction" );
HWND hDesktopWnd = FindWindow( NULL, "MozillaContentWindowClass" );
HDC hDesktopDC = GetDC(hDesktopWnd);
HDC hCaptureDC = CreateCompatibleDC(hDesktopDC);
HBITMAP hCaptureBitmap =CreateCompatibleBitmap(hDesktopDC, nScreenWidth,
nScreenHeight);
SelectObject(hCaptureDC,hCaptureBitmap);
BitBlt(hCaptureDC,0,0,nScreenWidth,nScreenHeight,hDesktopDC,0,0,SRCCOPY);
ReleaseDC(hDesktopWnd,hDesktopDC);
DeleteDC(hCaptureDC);
DeleteObject(hCaptureBitmap);
return hCaptureBitmap;

regards
Abhishek
 
Hi,

First you need to get the rect of the window for which you are want to
capture image. Here you have just hardcoded it.
Secondly make sure that the window is visible on the screen.

Hope this helps

WBR
Dinesh Venugopalan
 
Hi,

the window can be hidden as well.
I guess then u cant use this then. how do i then take a screenshot of a
hidden window then?

regards
Abhishek
 
Abhishek said:
Hi,

the window can be hidden as well.
I guess then u cant use this then. how do i then take a screenshot of a
hidden window then?

Send it WM_PRINT and a DC to draw onto.
 
Back
Top