Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Get form of running application

Get form of running application

Scheduled Pinned Locked Moved C#
csharphtmlcomquestion
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Judah Gabriel Himango
    wrote on last edited by
    #1

    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

    C S 2 Replies Last reply
    0
    • J Judah Gabriel 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

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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

      J 1 Reply Last reply
      0
      • C Christian Graus

        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

        J Offline
        J Offline
        Judah Gabriel Himango
        wrote on last edited by
        #3

        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

        C 1 Reply Last reply
        0
        • J Judah Gabriel 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

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Almost certainly not, no.

          Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

          A 1 Reply Last reply
          0
          • C Christian Graus

            Almost certainly not, no.

            Christian Graus - C++ MVP 'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert

            A Offline
            A Offline
            aSarafian
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • J Judah Gabriel 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

              S Offline
              S Offline
              S Senthil Kumar
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups