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. ShellExecute and focus lose

ShellExecute and focus lose

Scheduled Pinned Locked Moved C / C++ / MFC
question
8 Posts 3 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.
  • S Offline
    S Offline
    sdancer75
    wrote on last edited by
    #1

    Hi, Everytime I use ShellExecute to open a web page I lose the focus from the parent program (caller if the ShellExecute). Is there any way to open the page silently in the background or to regain focus back to the caller ? Regards,

    sdancer75

    Richard Andrew x64R D 2 Replies Last reply
    0
    • S sdancer75

      Hi, Everytime I use ShellExecute to open a web page I lose the focus from the parent program (caller if the ShellExecute). Is there any way to open the page silently in the background or to regain focus back to the caller ? Regards,

      sdancer75

      Richard Andrew x64R Offline
      Richard Andrew x64R Offline
      Richard Andrew x64
      wrote on last edited by
      #2

      Try this: BringWindowToTop[^]

      The difficult we do right away... ...the impossible takes slightly longer.

      S 1 Reply Last reply
      0
      • Richard Andrew x64R Richard Andrew x64

        Try this: BringWindowToTop[^]

        The difficult we do right away... ...the impossible takes slightly longer.

        S Offline
        S Offline
        sdancer75
        wrote on last edited by
        #3

        Hi, No, it didn't worked. Googleing on the net, I think that the problem is more complicated than just calling one Win32 API function. Regards,

        sdancer75

        1 Reply Last reply
        0
        • S sdancer75

          Hi, Everytime I use ShellExecute to open a web page I lose the focus from the parent program (caller if the ShellExecute). Is there any way to open the page silently in the background or to regain focus back to the caller ? Regards,

          sdancer75

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

          How are you calling ShellExecute()?

          "One man's wage rise is another man's price increase." - Harold Wilson

          "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

          "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

          S 1 Reply Last reply
          0
          • D David Crow

            How are you calling ShellExecute()?

            "One man's wage rise is another man's price increase." - Harold Wilson

            "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

            "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

            S Offline
            S Offline
            sdancer75
            wrote on last edited by
            #5

            Hi, I am calling ShellExecute like that :

            ShellExecute(NULL, "open", strURL ,NULL,NULL,SW_SHOWMINNOACTIVE);

            Where strURL is the URL address to open. Regards,

            sdancer75

            D 1 Reply Last reply
            0
            • S sdancer75

              Hi, I am calling ShellExecute like that :

              ShellExecute(NULL, "open", strURL ,NULL,NULL,SW_SHOWMINNOACTIVE);

              Where strURL is the URL address to open. Regards,

              sdancer75

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

              Have you tried other values for nShowCmd?

              "One man's wage rise is another man's price increase." - Harold Wilson

              "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

              "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

              S 2 Replies Last reply
              0
              • D David Crow

                Have you tried other values for nShowCmd?

                "One man's wage rise is another man's price increase." - Harold Wilson

                "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

                "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

                S Offline
                S Offline
                sdancer75
                wrote on last edited by
                #7

                Hi, Thank you for your reply. Yes I have already tried

                SW_SHOWNOACTIVATE

                ,

                SW_SHOWNORMAL

                ,

                SW_SHOWMINIMIZED

                ,

                SW_SHOWMINNOACTIVE

                and

                SW_SHOWNOACTIVATE

                without any success. Regards

                sdancer75

                1 Reply Last reply
                0
                • D David Crow

                  Have you tried other values for nShowCmd?

                  "One man's wage rise is another man's price increase." - Harold Wilson

                  "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

                  "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

                  S Offline
                  S Offline
                  sdancer75
                  wrote on last edited by
                  #8

                  Hi, I found out accidentally, that using the SetWindowPos to the MainFrm window inside the OnCreateClient it solves the problem. It seems that setting the attribute that does not change the Z-Order of the main window keeps it always in the top.

                  SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED);

                  What do you think ? Regards,

                  sdancer75

                  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