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. Hide the dilog in dialog based application.

Hide the dilog in dialog based application.

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
7 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.
  • V Offline
    V Offline
    vicky00000
    wrote on last edited by
    #1

    I Used ShowWindow(SW_HIDE) it hide the dialog but at the inital it popup how to avoid this . Thanks in advance

    M R D 4 Replies Last reply
    0
    • V vicky00000

      I Used ShowWindow(SW_HIDE) it hide the dialog but at the inital it popup how to avoid this . Thanks in advance

      M Offline
      M Offline
      Maxwell Chen
      wrote on last edited by
      #2

      vicky00000 wrote:

      I Used ShowWindow(SW_HIDE) it hide the dialog but at the inital it popup how to avoid this

      According to MSDN, the SW_HIDE is ignored during the 1st call when the dialog is about to pop up. ShowWindow[^] The first time an application calls ShowWindow, it should use the WinMain function's nCmdShow parameter as its nCmdShow parameter. Subsequent calls to ShowWindow must use one of the values in the given list, instead of the one specified by the WinMain function's nCmdShow parameter. As noted in the discussion of the nCmdShow parameter, the nCmdShow value is ignored in the first call to ShowWindow if the program that launched the application specifies startup information in the structure. In this case, ShowWindow uses the information specified in the STARTUPINFO structure to show the window.

      Maxwell Chen

      V 1 Reply Last reply
      0
      • V vicky00000

        I Used ShowWindow(SW_HIDE) it hide the dialog but at the inital it popup how to avoid this . Thanks in advance

        M Offline
        M Offline
        Maxwell Chen
        wrote on last edited by
        #3

        And the reason is: If it worked, then no target window would receive messages. There is a solution for this: To make your application hide to systray.

        Maxwell Chen

        1 Reply Last reply
        0
        • V vicky00000

          I Used ShowWindow(SW_HIDE) it hide the dialog but at the inital it popup how to avoid this . Thanks in advance

          R Offline
          R Offline
          Rajkumar R
          wrote on last edited by
          #4

          vicky00000 wrote:

          I Used ShowWindow(SW_HIDE) it hide the dialog but at the inital it popup how to avoid this .

          don't call DoModal until you want it to show.

          1 Reply Last reply
          0
          • V vicky00000

            I Used ShowWindow(SW_HIDE) it hide the dialog but at the inital it popup how to avoid this . Thanks in advance

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

            Override the OnWindowPosChanging() method with:

            if (! m_bVisible) // set to false in the dialog's constructor
            lpwndpos->flags &= ~SWP_SHOWWINDOW;

            CDialog::OnWindowPosChanging(lpwndpos);

            Just before calling ShowWindow(SW_SHOW), set m_bVisible to true.

            "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            V 1 Reply Last reply
            0
            • M Maxwell Chen

              vicky00000 wrote:

              I Used ShowWindow(SW_HIDE) it hide the dialog but at the inital it popup how to avoid this

              According to MSDN, the SW_HIDE is ignored during the 1st call when the dialog is about to pop up. ShowWindow[^] The first time an application calls ShowWindow, it should use the WinMain function's nCmdShow parameter as its nCmdShow parameter. Subsequent calls to ShowWindow must use one of the values in the given list, instead of the one specified by the WinMain function's nCmdShow parameter. As noted in the discussion of the nCmdShow parameter, the nCmdShow value is ignored in the first call to ShowWindow if the program that launched the application specifies startup information in the structure. In this case, ShowWindow uses the information specified in the STARTUPINFO structure to show the window.

              Maxwell Chen

              V Offline
              V Offline
              vicky00000
              wrote on last edited by
              #6

              Is there any way to update STARTUPINFO structure ? Thanks for your replay

              1 Reply Last reply
              0
              • D David Crow

                Override the OnWindowPosChanging() method with:

                if (! m_bVisible) // set to false in the dialog's constructor
                lpwndpos->flags &= ~SWP_SHOWWINDOW;

                CDialog::OnWindowPosChanging(lpwndpos);

                Just before calling ShowWindow(SW_SHOW), set m_bVisible to true.

                "Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman

                "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                V Offline
                V Offline
                vicky00000
                wrote on last edited by
                #7

                Thank you very much DavidCrow I solve my problem with the help of you Thanks

                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