Is there a way to get the handle of a control by its name? I am writing a
help application on top of an existing .NET app. I know the friendly names
(Control.Name) of the controls in the app, I want to get a handle to those
controls using the name so I can get the location of the control and show my
help message close to the control in question. Is there anyway to get this
information from outside the existing .NET app?

- sp

Re: get control by name? by Herfried

Herfried
Fri May 20 19:33:19 CDT 2005

"sp25" <sp25@online.nospam> schrieb:
> Is there a way to get the handle of a control by its name? I am writing a
> help application on top of an existing .NET app. I know the friendly names
> (Control.Name) of the controls in the app, I want to get a handle to those
> controls using the name so I can get the location of the control and show
> my
> help message close to the control in question. Is there anyway to get this
> information from outside the existing .NET app?

A simple Windows forms properties spy
<URL:http://www.codeproject.com/dotnet/wfspy.asp>

ControlInspector - monitor Windows Forms events as they are fired (like
Spy++ for .net)
<URL:http://www.codeproject.com/csharp/controlinspector.asp>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


Re: get control by name? by sp25

sp25
Mon May 23 12:16:27 CDT 2005

I'll try that but in the properties view in the example, I don't see the
"Name" of the control. I see the Controls class and other properties like
location and size but I don't see the .Name in the properties list. So it
will not be possible to know if I have the properties of the correct control
in question especially since I have multiple controls of the same type on the
form.

Any more help appreciated. Thanks

- sp25


"Herfried K. Wagner [MVP]" wrote:

> "sp25" <sp25@online.nospam> schrieb:
> > Is there a way to get the handle of a control by its name? I am writing a
> > help application on top of an existing .NET app. I know the friendly names
> > (Control.Name) of the controls in the app, I want to get a handle to those
> > controls using the name so I can get the location of the control and show
> > my
> > help message close to the control in question. Is there anyway to get this
> > information from outside the existing .NET app?
>
> A simple Windows forms properties spy
> <URL:http://www.codeproject.com/dotnet/wfspy.asp>
>
> ControlInspector - monitor Windows Forms events as they are fired (like
> Spy++ for .net)
> <URL:http://www.codeproject.com/csharp/controlinspector.asp>
>
> --
> M S Herfried K. Wagner
> M V P <URL:http://dotnet.mvps.org/>
> V B <URL:http://classicvb.org/petition/>
>
>

Re: get control by name? by v-jetan

v-jetan
Mon May 23 21:48:50 CDT 2005

Hi sp25,

Thanks for your feedback.

In your scenario, if you want to view an existed winform control's
property, this is a cross-process issue, which requests legacy win32 hook
technologies. I think the first article provided by "Herfried K. Wagner
[MVP]" pointed out the most important steps: injecting assembly into
another process.
A simple Windows forms properties spy
<URL:http://www.codeproject.com/dotnet/wfspy.asp>

Once we has injected the assembly in the being spyed winform application
process, we can enumerate all the windows(controls) in that process, then
we can compare each enumerated control's Name property with our held name
string. Once they are the same, we should have got the control we want.

The reason why the application in the above link does not show out the
"Name" property is that the PropertyGrid control does not show out this
property. Currently, I am not sure why the PropertyGrid control does not
show out the Name property, however, I think it will not break out
programming logic.

Hope this helps
=============================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Re: get control by name? by v-jetan

v-jetan
Tue May 24 00:45:02 CDT 2005

Hi sp25,

Ok, it seems I missed the simple thing: the Control.Name property does not
show out in PropertyGrid is because it is marked with [Browsable(false)]
attribute. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Re: get control by name? by sp25

sp25
Tue May 24 10:48:08 CDT 2005

Great Thanks a lot.
- sp25


Re: get control by name? by v-jetan

v-jetan
Wed May 25 02:57:43 CDT 2005

You are welcome :-)

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.