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. switch to existing instance [modified]

switch to existing instance [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
question
9 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.
  • N Offline
    N Offline
    negativeG
    wrote on last edited by
    #1

    My app allows users to start a 'helper' applet that runs independently. I am using a mutex to limit this applet to a single instance. I use the mutex both to prevent starting the second instance from my app (by CreateProcess or ShellExecute)AND to have any second instance started outside my (by clicking icons, etc) to self-terminate. How can I have them switch to the current instance of the applet? That is, if they select to run the applet from my app I don't want to ignore it or display a message that an instance is running. I want to make that instance be get focus and be the top most application. Thanks, -G

    modified on Wednesday, March 4, 2009 1:39 PM

    L D 3 Replies Last reply
    0
    • N negativeG

      My app allows users to start a 'helper' applet that runs independently. I am using a mutex to limit this applet to a single instance. I use the mutex both to prevent starting the second instance from my app (by CreateProcess or ShellExecute)AND to have any second instance started outside my (by clicking icons, etc) to self-terminate. How can I have them switch to the current instance of the applet? That is, if they select to run the applet from my app I don't want to ignore it or display a message that an instance is running. I want to make that instance be get focus and be the top most application. Thanks, -G

      modified on Wednesday, March 4, 2009 1:39 PM

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Is there some reason you bolded your entire post? I'm so distracted by it I can't even read the post.

      E N 2 Replies Last reply
      0
      • L led mike

        Is there some reason you bolded your entire post? I'm so distracted by it I can't even read the post.

        E Offline
        E Offline
        Eytukan
        wrote on last edited by
        #3

        Exactly. That's really harmful to the eyes. X|

        He never answers anyone who replies to him. I've taken to calling him a retard, which is not fair to retards everywhere.-Christian Graus

        1 Reply Last reply
        0
        • L led mike

          Is there some reason you bolded your entire post? I'm so distracted by it I can't even read the post.

          N Offline
          N Offline
          negativeG
          wrote on last edited by
          #4

          Not intentionally. That is how the post came up when I started it. I thought the preview just came that way. Reviewing it, I see that there as indeed a bold tag around it all, which I have since removed (I hope) Sorry. -G

          1 Reply Last reply
          0
          • N negativeG

            My app allows users to start a 'helper' applet that runs independently. I am using a mutex to limit this applet to a single instance. I use the mutex both to prevent starting the second instance from my app (by CreateProcess or ShellExecute)AND to have any second instance started outside my (by clicking icons, etc) to self-terminate. How can I have them switch to the current instance of the applet? That is, if they select to run the applet from my app I don't want to ignore it or display a message that an instance is running. I want to make that instance be get focus and be the top most application. Thanks, -G

            modified on Wednesday, March 4, 2009 1:39 PM

            L Offline
            L Offline
            led mike
            wrote on last edited by
            #5

            negativeG wrote:

            I want to make that instance be get focus and be the top most application.

            SetWindowPos()[^]

            N 1 Reply Last reply
            0
            • L led mike

              negativeG wrote:

              I want to make that instance be get focus and be the top most application.

              SetWindowPos()[^]

              N Offline
              N Offline
              negativeG
              wrote on last edited by
              #6

              Sure, but how do I find the hWnd for the Applet (it is a dialog based) from my App? There is some recourse if I start the Applet from my App using CreateProcess, but if it is run from the command line, my app has no knowledge of it. -G

              L 1 Reply Last reply
              0
              • N negativeG

                Sure, but how do I find the hWnd for the Applet (it is a dialog based) from my App? There is some recourse if I start the Applet from my App using CreateProcess, but if it is run from the command line, my app has no knowledge of it. -G

                L Offline
                L Offline
                led mike
                wrote on last edited by
                #7

                negativeG wrote:

                Sure, but how do I find the hWnd for the Applet (it is a dialog based) from my App?

                Ah, a new question. Sorry I mistook you for someone that had a clue about what they were doing. Good luck.

                1 Reply Last reply
                0
                • N negativeG

                  My app allows users to start a 'helper' applet that runs independently. I am using a mutex to limit this applet to a single instance. I use the mutex both to prevent starting the second instance from my app (by CreateProcess or ShellExecute)AND to have any second instance started outside my (by clicking icons, etc) to self-terminate. How can I have them switch to the current instance of the applet? That is, if they select to run the applet from my app I don't want to ignore it or display a message that an instance is running. I want to make that instance be get focus and be the top most application. Thanks, -G

                  modified on Wednesday, March 4, 2009 1:39 PM

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  negativeG wrote:

                  I want to make that instance be get focus and be the top most application.

                  See the InitInstance() method in this example.

                  "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

                  "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                  N 1 Reply Last reply
                  0
                  • D David Crow

                    negativeG wrote:

                    I want to make that instance be get focus and be the top most application.

                    See the InitInstance() method in this example.

                    "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

                    "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                    N Offline
                    N Offline
                    negativeG
                    wrote on last edited by
                    #9

                    Thanks! I had to massage it a little since I have a Dialog based app, but it is working great now! -G

                    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