473,324 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

finding handle of child window

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,h DesktopDC,0,0,SRCCOPY);
ReleaseDC(hDesktopWnd,hDesktopDC);
DeleteDC(hCaptureDC);
DeleteObject(hCaptureBitmap);
return hCaptureBitmap;

regards
Abhishek
Sep 11 '06 #1
4 2351
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

"Abhishek" <sh***@activelement.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
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,h DesktopDC,0,0,SRCCOPY);
ReleaseDC(hDesktopWnd,hDesktopDC);
DeleteDC(hCaptureDC);
DeleteObject(hCaptureBitmap);
return hCaptureBitmap;

regards
Abhishek

Sep 12 '06 #2
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
"Dinesh Venugopalan" <di****@epiance.comwrote in message
news:eN**************@TK2MSFTNGP02.phx.gbl...
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

"Abhishek" <sh***@activelement.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>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


Sep 12 '06 #3

"Abhishek" <sh***@activelement.comwrote in message
news:Ou**************@TK2MSFTNGP05.phx.gbl...
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.
>
regards
Abhishek
"Dinesh Venugopalan" <di****@epiance.comwrote in message
news:eN**************@TK2MSFTNGP02.phx.gbl...
>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

"Abhishek" <sh***@activelement.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
>>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



Sep 12 '06 #4
Thanks got this done!.

regards
Abhishek

"Ben Voigt" <rb*@nospam.nospamwrote in message
news:OF****************@TK2MSFTNGP04.phx.gbl...
>
"Abhishek" <sh***@activelement.comwrote in message
news:Ou**************@TK2MSFTNGP05.phx.gbl...
>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.
>>
regards
Abhishek
"Dinesh Venugopalan" <di****@epiance.comwrote in message
news:eN**************@TK2MSFTNGP02.phx.gbl...
>>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

"Abhishek" <sh***@activelement.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl.. .
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,nScreenHeigh t,hDesktopDC,0,0,SRCCOPY);
ReleaseDC(hDesktopWnd,hDesktopDC);
DeleteDC(hCaptureDC);
DeleteObject(hCaptureBitmap);
return hCaptureBitmap;

regards
Abhishek



Sep 21 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ayaz Ali | last post by:
Hello, Does anybody know how to get window handle of parent window (the main application window) in C#. I am trying to set mdiParent of a child window in child's Load( ). I dont know how to set it...
4
by: Brad Jones | last post by:
<Previously posted in microsoft.public.dotnet.framework.windowsforms> Hi all. Any suggestions here would be appreciated. Thanks for reading. I'm primarly a C++ developer but I've been trying to...
3
by: NeverLift | last post by:
But, if it's not open, I don't want to open it . . . using window.open will open it if it doesn't exist, even if the url in that open is null (the window is then empty -- but it's open). The...
3
by: Will | last post by:
I have a parent/child relationship between two windows. The parent spawns the child using something like this. windowHandle = window.open("child.aspx","child"); the problem is that if the...
3
by: Daniel H. | last post by:
Hi! When I create a new form programatically, I can save its handle in a collection of some type Later, I need to find that form based on a handle I saved and call one of its functions. The newly...
11
by: objectref | last post by:
Hi to all, is there a way to get the window handle of the main window of an application or process ? For example, if someone opens Microsoft Word, he gets a window so he/she can write text....
2
by: rawCoder | last post by:
Hi I am having this InvalidOperationException with message Cannot call Invoke or InvokeAsync on a control until the window handle has been created This is raised when i try to invoke a method...
7
by: lkr | last post by:
hi is there is anyway to capture the document events of a MSWord?eg:I have to handle the event awhen WM_KEYUP or anyother events will occur. give me a solution............ thanks in advance lkr
1
by: Paul | last post by:
Hi this is kind of related to a post from yesterday, closing a child window from actions on the parent window. Anyhow I was able to get this to work using java script, and setting up open and...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.