MultiMarine,
You can get a control associated with given HWND only if the control has
been created in the application from a WindowsForm class. When you create a
control the framework keeps map between HWNDs and control objects and uses
this map to when Control.FromChildHandle is called.
You cannot create a control object form a random window by its HWND.
..NET provides NativeWindow class that can be attached to any HWND and can be
used for windows subclassing.
--
HTH
Stoitcho Goutsev (100)
"MultiMarine" <mu***********@hotmail.com> wrote in message
news:11*********************@u72g2000cwu.googlegro ups.com...
Hello
I have just started using .NET and C# from a c++ background using
win32. Now i want to do something that i used to do, without using the
win32 API.
I use Spy++ to get a HWND from another application in hex form from a
RICHEDIT control.
now i want to turn this hex value (HWND) into a control in C#.
Why doesn't this work?
IntPtr ptr = new IntPtr(0x00020A92);
Control control = System.Windows.Forms.Control.FromChildHandle(ptr);
Is there some other way to do this?? i don't wanna use the win32 API!
Thanks in advance!