Get form of running application
-
Despite sounding simple, this one's really stumped me. I've got a C# desktop application running. From a second C# app, can I get the main Form of the first C# application? I know I can create and register a .NET IPC channel and talk between the 2 processes, but that seems like overkill; I just want to get at the Form of the first application. Is there an easy way? p.s. Please note that I need more than just the Form's handle, the Form's text. I actually need the Form instance itself.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: Check out this cutie The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
-
Despite sounding simple, this one's really stumped me. I've got a C# desktop application running. From a second C# app, can I get the main Form of the first C# application? I know I can create and register a .NET IPC channel and talk between the 2 processes, but that seems like overkill; I just want to get at the Form of the first application. Is there an easy way? p.s. Please note that I need more than just the Form's handle, the Form's text. I actually need the Form instance itself.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: Check out this cutie The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
Depends what you mean. Can you get a handle to the window ? Yes, using Win32 calls. Can you get a reference to the form class ? No.
Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
-
Depends what you mean. Can you get a handle to the window ? Yes, using Win32 calls. Can you get a reference to the form class ? No.
Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
Christian Graus wrote:
Can you get a reference to the form class ? No.
That's what I mean. I know I can get the handle, the text, and other things via native interop, but I need the actual form reference. I was hoping System.Windows.Forms.NativeWindow.FromHandle would work, but no luck. :(
Tech, life, family, faith: Give me a visit. I'm currently blogging about: Check out this cutie The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
-
Christian Graus wrote:
Can you get a reference to the form class ? No.
That's what I mean. I know I can get the handle, the text, and other things via native interop, but I need the actual form reference. I was hoping System.Windows.Forms.NativeWindow.FromHandle would work, but no luck. :(
Tech, life, family, faith: Give me a visit. I'm currently blogging about: Check out this cutie The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
Almost certainly not, no.
Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
-
Almost certainly not, no.
Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
i think it can be done. There is a project in codeproject that can select an other .net form and display its properties and events in a propertygrid. That means that it gets a handle to that object. Let me Look it up. Ok found it I think that this RuntimeObjectEditor Project[^]does what you are looking for not only for a form After getting the object a cast must be feasible
-
Despite sounding simple, this one's really stumped me. I've got a C# desktop application running. From a second C# app, can I get the main Form of the first C# application? I know I can create and register a .NET IPC channel and talk between the 2 processes, but that seems like overkill; I just want to get at the Form of the first application. Is there an easy way? p.s. Please note that I need more than just the Form's handle, the Form's text. I actually need the Form instance itself.
Tech, life, family, faith: Give me a visit. I'm currently blogging about: Check out this cutie The apostle Paul, modernly speaking: Epistles of Paul Judah Himango
Looks like you would need to inject code into the other process to get this to work. Rama's wfspy[^] does that to get access properties of forms running in other processes.
Regards Senthil [MVP - Visual C#] _____________________________ My Blog | My Articles | WinMacro