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 restore my application instead of running a new instance?

How to restore my application instead of running a new instance?

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
4 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
    julych
    wrote on last edited by
    #1

    How to restore (maximize) my application instead of running a new instance when another instance is already running?

    B M C 3 Replies Last reply
    0
    • J julych

      How to restore (maximize) my application instead of running a new instance when another instance is already running?

      B Offline
      B Offline
      BlackRider
      wrote on last edited by
      #2

      You could try to define a hook to maximize your app when you do smtg ... Or you could hit ALT-TAB :)

      1 Reply Last reply
      0
      • J julych

        How to restore (maximize) my application instead of running a new instance when another instance is already running?

        M Offline
        M Offline
        Michael P Butler
        wrote on last edited by
        #3

        Have a read of http://www.codeproject.com/cpp/avoidmultinstance.asp[^] and http://www.codeproject.com/cpp/csingleinst.asp[^] Michael 'Logic, my dear Zoe, merely enables one to be wrong with authority.' - The Doctor: The Wheel in Space

        1 Reply Last reply
        0
        • J julych

          How to restore (maximize) my application instead of running a new instance when another instance is already running?

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

          Somehow, before you create your app window, you need to find if another instance is running. One way is to use a named mutex that each instance tries to aquire. Another is to use the main window text as shown below (although not the suggested method) :

          HWND h = ::FindWindowW(AppName, NULL);
          if( h ) {
          // Set focus to foremost child window.
          // The "| 0x01" is used to bring any owned windows to the
          // foreground and activate them.
          ::SetForegroundWindow( (HWND)((ulong)h|0x00000001) );
          return(true);
          }

          The key point in the above is not finding the app window, but how to restore it once found. ...cmk Save the whales - collect the whole set

          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