finding handle of child window

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
 
D

Dinesh Venugopalan

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
 
A

Abhishek

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
 
B

Ben Voigt

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top