Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

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
Updated 25-Aug-11 10:35am

1 solution

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
EnumWindows[^]
FindWindow[^]
FindWindowEx[^]
Or
UIAutomation[^]

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.
 
Share this answer
 
Comments
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?
Sergey Alexandrovich Kryukov 25-Aug-11 19:35pm    
My 5.
--SA

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900