473,778 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 mozillacontentw indowclass 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, "MozillaContent WindowClass" );
HDC hDesktopDC = GetDC(hDesktopW nd);
HDC hCaptureDC = CreateCompatibl eDC(hDesktopDC) ;
HBITMAP hCaptureBitmap =CreateCompatib leBitmap(hDeskt opDC, nScreenWidth,
nScreenHeight);
SelectObject(hC aptureDC,hCaptu reBitmap);
BitBlt(hCapture DC,0,0,nScreenW idth,nScreenHei ght,hDesktopDC, 0,0,SRCCOPY);
ReleaseDC(hDesk topWnd,hDesktop DC);
DeleteDC(hCaptu reDC);
DeleteObject(hC aptureBitmap);
return hCaptureBitmap;

regards
Abhishek
Sep 11 '06 #1
4 2406
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***@activele ment.comwrote in message
news:%2******** ********@TK2MSF TNGP04.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 mozillacontentw indowclass 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, "MozillaContent WindowClass" );
HDC hDesktopDC = GetDC(hDesktopW nd);
HDC hCaptureDC = CreateCompatibl eDC(hDesktopDC) ;
HBITMAP hCaptureBitmap =CreateCompatib leBitmap(hDeskt opDC, nScreenWidth,
nScreenHeight);
SelectObject(hC aptureDC,hCaptu reBitmap);
BitBlt(hCapture DC,0,0,nScreenW idth,nScreenHei ght,hDesktopDC, 0,0,SRCCOPY);
ReleaseDC(hDesk topWnd,hDesktop DC);
DeleteDC(hCaptu reDC);
DeleteObject(hC aptureBitmap);
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******** ******@TK2MSFTN GP02.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***@activele ment.comwrote in message
news:%2******** ********@TK2MSF TNGP04.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 mozillacontentw indowclass 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, "MozillaContent WindowClass" );
HDC hDesktopDC = GetDC(hDesktopW nd);
HDC hCaptureDC = CreateCompatibl eDC(hDesktopDC) ;
HBITMAP hCaptureBitmap =CreateCompatib leBitmap(hDeskt opDC, nScreenWidth,
nScreenHeight) ;
SelectObject(h CaptureDC,hCapt ureBitmap);
BitBlt(hCaptur eDC,0,0,nScreen Width,nScreenHe ight,hDesktopDC ,0,0,SRCCOPY);
ReleaseDC(hDes ktopWnd,hDeskto pDC);
DeleteDC(hCapt ureDC);
DeleteObject(h CaptureBitmap);
return hCaptureBitmap;

regards
Abhishek


Sep 12 '06 #3

"Abhishek" <sh***@activele ment.comwrote in message
news:Ou******** ******@TK2MSFTN GP05.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******** ******@TK2MSFTN GP02.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***@activele ment.comwrote in message
news:%2******* *********@TK2MS FTNGP04.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 mozillacontentw indowclass 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, "MozillaContent WindowClass" );
HDC hDesktopDC = GetDC(hDesktopW nd);
HDC hCaptureDC = CreateCompatibl eDC(hDesktopDC) ;
HBITMAP hCaptureBitmap =CreateCompatib leBitmap(hDeskt opDC, nScreenWidth,
nScreenHeight );
SelectObject( hCaptureDC,hCap tureBitmap);
BitBlt(hCaptu reDC,0,0,nScree nWidth,nScreenH eight,hDesktopD C,0,0,SRCCOPY);
ReleaseDC(hDe sktopWnd,hDeskt opDC);
DeleteDC(hCap tureDC);
DeleteObject( hCaptureBitmap) ;
return hCaptureBitmap;

regards
Abhishek



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

regards
Abhishek

"Ben Voigt" <rb*@nospam.nos pamwrote in message
news:OF******** ********@TK2MSF TNGP04.phx.gbl. ..
>
"Abhishek" <sh***@activele ment.comwrote in message
news:Ou******** ******@TK2MSFTN GP05.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******* *******@TK2MSFT NGP02.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***@activele ment.comwrote in message
news:%2****** **********@TK2M SFTNGP04.phx.gb l...
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 mozillacontentw indowclass 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, "MozillaContent WindowClass" );
HDC hDesktopDC = GetDC(hDesktopW nd);
HDC hCaptureDC = CreateCompatibl eDC(hDesktopDC) ;
HBITMAP hCaptureBitmap =CreateCompatib leBitmap(hDeskt opDC,
nScreenWidth , nScreenHeight);
SelectObject (hCaptureDC,hCa ptureBitmap);
BitBlt(hCapt ureDC,0,0,nScre enWidth,nScreen Height,hDesktop DC,0,0,SRCCOPY) ;
ReleaseDC(hD esktopWnd,hDesk topDC);
DeleteDC(hCa ptureDC);
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
490
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 to parent container control as the child is created by an intermediary class that doesnt keep parent's handle or reference. regards, anony
4
1936
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 complete development on a C# application with the following basic requirements: - The app runs in the background is initially hidden from the user, including the Windows Taskbar. - The app needs to receive a registered Windows message - The app...
3
24716
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 situation is: A main window opens child windows one at a time as the user requests, each with its own name. The user may click in any child window or the main window to open a summary window, which has a name all windows know. I want to get that...
3
2689
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 child window closes then the windowHandle object is left in an orphaned state. It does't equate to null and I'm not sure how to check and see if the window still exists. The child does notify the parent window through the window.opener object when it...
3
9028
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 create form can be a child of an MDI form but it very well may not be, so I can not use MDIChildren I am wandering how it can be done in C#, please Thank you in advance Dany
11
5081
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. Spy++ gives that this window is called _Wwg. How we can get a handle to this window assuming that we do not know beforehand the name of the process,
2
3008
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 with arguments I need to do this as the method is being called Asynchronously from elsewhere using delegate's BeginInvoke method. The form is well created/initialized yet the messages states otherwise.
7
2062
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
2901
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 close functions with a handle. I have another case where a child window is opened from a datagrid hyperlink and am just wondering if anyone knows how to set up an open and close function for this window that can be run from the parent window? child ...
0
9470
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10127
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9923
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8957
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7475
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5500
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2865
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.