Using a HWND from another application.
-
I wrote an application a while back that used WIN32 C++ to query a list box in another application for its contents (using SendMessage). I would like to do the same in C#, but instead of using SendMessage, I would like to associate the HWND with a ListBox instance. I can get the HWND for the listbox that is in another app, and I tried using Control.FromHandle, but it returns null. If, however, I put a listbox in my own application it works. This made me suspect that it is a security issue and just not possible. Thanks for any help.
-
I wrote an application a while back that used WIN32 C++ to query a list box in another application for its contents (using SendMessage). I would like to do the same in C#, but instead of using SendMessage, I would like to associate the HWND with a ListBox instance. I can get the HWND for the listbox that is in another app, and I tried using Control.FromHandle, but it returns null. If, however, I put a listbox in my own application it works. This made me suspect that it is a security issue and just not possible. Thanks for any help.
An HWND is not global but specific for an application's domain. (It's essentially a pointer). It is therefore not possible to use an HWND outside of that application.