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 / C++ / MFC
  4. How to pass a window handle to another as command line argument.

How to pass a window handle to another as command line argument.

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++tutorial
6 Posts 6 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.
  • N Offline
    N Offline
    Nitheesh George
    wrote on last edited by
    #1

    Hi, I am developing application which is launched by another application. I wanted to notify the parent application (the launcher) that the task successful or failed. So I need to pass the main window handle of the launcher application to my second application like /CallingProgramWindow="0001009C". Then how can i convert the string back to window handle. And is this method is the right way to do this.? I am using VC++ to develop the application. Thanks Nitheesh Nitheesh George http://www.simpletools.co.in

    D L C J M 5 Replies Last reply
    0
    • N Nitheesh George

      Hi, I am developing application which is launched by another application. I wanted to notify the parent application (the launcher) that the task successful or failed. So I need to pass the main window handle of the launcher application to my second application like /CallingProgramWindow="0001009C". Then how can i convert the string back to window handle. And is this method is the right way to do this.? I am using VC++ to develop the application. Thanks Nitheesh Nitheesh George http://www.simpletools.co.in

      D Offline
      D Offline
      dasblinkenlight
      wrote on last edited by
      #2

      As far as converting to HWND goes, a handle is really a void*, so all you need to do is to parse a HEX number into a void pointer. I do not know if this is the right approach, but I think it has a good chance of working. If it does not work, you could try a less reliable method of passing coordinates of, say, the upper-left corner of the window, and then call WindowFromPoint[^] on it.

      1 Reply Last reply
      0
      • N Nitheesh George

        Hi, I am developing application which is launched by another application. I wanted to notify the parent application (the launcher) that the task successful or failed. So I need to pass the main window handle of the launcher application to my second application like /CallingProgramWindow="0001009C". Then how can i convert the string back to window handle. And is this method is the right way to do this.? I am using VC++ to develop the application. Thanks Nitheesh Nitheesh George http://www.simpletools.co.in

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        While this may work, I am not sure that it is the 'correct' way to implement what you want. It may be better to use the Process functions (CreateProcess etc) and use the return value form GetExitCodeProcess()[^].

        The best things in life are not things.

        1 Reply Last reply
        0
        • N Nitheesh George

          Hi, I am developing application which is launched by another application. I wanted to notify the parent application (the launcher) that the task successful or failed. So I need to pass the main window handle of the launcher application to my second application like /CallingProgramWindow="0001009C". Then how can i convert the string back to window handle. And is this method is the right way to do this.? I am using VC++ to develop the application. Thanks Nitheesh Nitheesh George http://www.simpletools.co.in

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #4

          There are several ways to make the two processes communicate. The way you depicted is actually feasible, just use the strtoul[^] function to convert the string. Another simple way would be using the RegisterWindowMessage[^] mechanism. :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          1 Reply Last reply
          0
          • N Nitheesh George

            Hi, I am developing application which is launched by another application. I wanted to notify the parent application (the launcher) that the task successful or failed. So I need to pass the main window handle of the launcher application to my second application like /CallingProgramWindow="0001009C". Then how can i convert the string back to window handle. And is this method is the right way to do this.? I am using VC++ to develop the application. Thanks Nitheesh Nitheesh George http://www.simpletools.co.in

            J Offline
            J Offline
            jschell
            wrote on last edited by
            #5

            Nitheesh George wrote:

            So I need to pass the main window handle of the launcher application to my second application like /CallingProgramWindow="0001009C". Then how can i convert the string back to window handle. And is this method is the right way to do this.?

            Unlikely. What exactly do you want to do with the handle in the second app? In general you solve the problem like this. 1. Target app runs 2. Target app gets to point X in app and this is considered 'succcess' 3. Target app 'sends' result to host application. Step 2 is defined by your application. There are several ways to do 3, such as stdio or sockets. However if you just need to know if the target ran and the host ran it then the process of actually running it would tell you that.

            1 Reply Last reply
            0
            • N Nitheesh George

              Hi, I am developing application which is launched by another application. I wanted to notify the parent application (the launcher) that the task successful or failed. So I need to pass the main window handle of the launcher application to my second application like /CallingProgramWindow="0001009C". Then how can i convert the string back to window handle. And is this method is the right way to do this.? I am using VC++ to develop the application. Thanks Nitheesh Nitheesh George http://www.simpletools.co.in

              M Offline
              M Offline
              Mark Salsbery
              wrote on last edited by
              #6

              Nitheesh George wrote:

              So I need to pass the main window handle of the launcher application to my second application

              Interprocess COmmunication[^]

              Mark Salsbery Microsoft MVP - Visual C++ :java:

              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