Click here to Skip to main content
13,093,097 members (68,931 online)
Rate this:
Please Sign up or sign in to vote.
See more:

I am working on a project in which I am trying to get the handle of a control in another application. However I don't understand too well the System.Windows.Forms.Control.FromChildHandle(handle) function. What I'm doing is getting the handle of the main form and want to get all the childhandles into controls.

I have been looking online for examples but haven't found any and the msdn doesn't provide examples.

My code actually compiles, but the System.Windows.Forms.Control.FromChildHandle function does not return a control.

thank you
Posted 25-Aug-11 10:33am
Updated 25-Aug-11 10:35am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Control.FromChildHandle Method - MSDN entry[^]
According to the documentation Control.FromChildHandle walks up the parent chain and returns the control with the given handle, null if not found.

I am trying to get the handle of a control in another application
you have to look into

In short you won't be able to get a Form and any kind of Control object which represents a form/control in another application. Thus Control.FromChildHandle returns null when you give it a handle that doesn't belong to the current application.
nanomass 25-Aug-11 16:55pm
I used FindWindow() to get the handle of the other application, I tried to use FindWindowEx() but the tabcontrol doesn't have caption, therefore it only works if the tabcontrol is the only control in the other application. is there any way to convert handles from another Window Form (aka application) into control objects?
SAKryukov 25-Aug-11 19:35pm
My 5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170813.1 | Last Updated 25 Aug 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100