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. Parent Dialog's labels are vanishing for little bit of time when the child dialog exit

Parent Dialog's labels are vanishing for little bit of time when the child dialog exit

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
7 Posts 5 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

    Hai all, One of my dialog based application, I call a child dialog from parent dialog , Parent dialog's labels (Underneath of child dialog) will vanish for a while , while i exit the child dialog. how to avoid this problem ? Thanks in advance.

    H I 2 Replies Last reply
    0
    • V vicky00000

      Hai all, One of my dialog based application, I call a child dialog from parent dialog , Parent dialog's labels (Underneath of child dialog) will vanish for a while , while i exit the child dialog. how to avoid this problem ? Thanks in advance.

      H Offline
      H Offline
      Hamid Taebi
      wrote on last edited by
      #2

      Can you more explain when you call child then label of parent is hide?

      1 Reply Last reply
      0
      • V vicky00000

        Hai all, One of my dialog based application, I call a child dialog from parent dialog , Parent dialog's labels (Underneath of child dialog) will vanish for a while , while i exit the child dialog. how to avoid this problem ? Thanks in advance.

        I Offline
        I Offline
        Iain Clarke Warrior Programmer
        wrote on last edited by
        #3

        When then child dialog disappears, the underneath area needs to be repainted, so the parent dialog (and some controls) are invalidated, ready for a WM_PAINT message. My guess is that you have something like:

        void CParentDlg::OnSomeButton ()
        {
        CCHildDlg dlg (this);

        dlg.m_ManyThings = Blah;

        if (dlg.DoModal () != IDOK) return;

        DoSomeVerySlowStuff ();

        // ChildDlg's destructor implicitly called here.
        }

        The paint messages won't be handled until after CParentDlg::OnSomeButton returns. So, are you doing some slow steps? If you cancel out of the child dialog, is the repainting faster? Is the child dialog doing loads of things in its destructor? Or in its OnDestroy method? Iain.

        Iain Clarke appears because CPallini still cares.

        V 1 Reply Last reply
        0
        • I Iain Clarke Warrior Programmer

          When then child dialog disappears, the underneath area needs to be repainted, so the parent dialog (and some controls) are invalidated, ready for a WM_PAINT message. My guess is that you have something like:

          void CParentDlg::OnSomeButton ()
          {
          CCHildDlg dlg (this);

          dlg.m_ManyThings = Blah;

          if (dlg.DoModal () != IDOK) return;

          DoSomeVerySlowStuff ();

          // ChildDlg's destructor implicitly called here.
          }

          The paint messages won't be handled until after CParentDlg::OnSomeButton returns. So, are you doing some slow steps? If you cancel out of the child dialog, is the repainting faster? Is the child dialog doing loads of things in its destructor? Or in its OnDestroy method? Iain.

          Iain Clarke appears because CPallini still cares.

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

          Thanks your reply. What you mentioned is exactly correct. How Can i Avoid such trouble please clarify. Thanks Vicky

          I D 2 Replies Last reply
          0
          • V vicky00000

            Thanks your reply. What you mentioned is exactly correct. How Can i Avoid such trouble please clarify. Thanks Vicky

            I Offline
            I Offline
            Iain Clarke Warrior Programmer
            wrote on last edited by
            #5

            vicky00000 wrote:

            How Can i Avoid such trouble please clarify.

            By not doing complex work on returning from the dialog. There are a few choices I can think of (and millions others, I'm sure) - how useful each is depends on how long the pause is - a slightly irritating half second, or many seconds. I'm assuming it's not hoooooours. 1/ Do the work in the child dialogs OnOK window, and use CWaitCursor just before you do it. The child dialog will stick around, but it won't be a mystery. 2/ After the DoModal () returns, post a message to yourself, and do the long work in that message handler. this postpones the work until after the painting is done. 3/ After the DoModal () returns, start up a worker thread, and have that post a "I'm done" message. Iain.

            Iain Clarke appears because CPallini still cares.

            1 Reply Last reply
            0
            • V vicky00000

              Thanks your reply. What you mentioned is exactly correct. How Can i Avoid such trouble please clarify. Thanks Vicky

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

              vicky00000 wrote:

              What you mentioned is exactly correct.

              So are you calling the second dialog's destructor explicitly (in some button handler)?

              "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

              J 1 Reply Last reply
              0
              • D David Crow

                vicky00000 wrote:

                What you mentioned is exactly correct.

                So are you calling the second dialog's destructor explicitly (in some button handler)?

                "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

                J Offline
                J Offline
                JohnCz
                wrote on last edited by
                #7

                DavidCrow wrote:

                are you calling the second dialog's destructor explicitly

                I am not sure why calling destructor explicitly? It should never be done. In this case, dialog object is allocated on the frame and it dies when function goes out of scope; destructor is called automatically. vicky00000: Well, I fail to see child-parent relationship between dialogs. Both most likely are owned by main window (it could be the first dialog). As for doing long processing, follow Iain’s advice #3. Do the background processing in a worker thread. As for CWaitCursor, it is a legacy class from 16-bit Windows. In 32-bit it will disappear as soon as ne WM_SETCURSOR message is received. If you want to show hourglass, it is better to handle WM_SETCURSOR message and call SetCursor to change cursor for a dureation you need.

                JohnCz MS C++ MVP

                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