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. Parenting a modal CDialog

Parenting a modal CDialog

Scheduled Pinned Locked Moved C / C++ / MFC
databasequestionlounge
6 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.
  • T Offline
    T Offline
    TyrionTheImp
    wrote on last edited by
    #1

    Hi All, I had a general query regarding modal dialogs and child windows. Is there any way by which I can restrict a CDialog instance to be within the client area of a parent window and yet also allow DoModal method to work correctly ? From what i`ve seen so far, such dialogs show the CWnd value passed to them in the constructor as the parent/owner in Spy++ but can still be moved out of it when the modal loop starts. Doing a SetParent causes both the parent and dialog to hang when i call DoModal. Thanks in Advance.

    S D 2 Replies Last reply
    0
    • T TyrionTheImp

      Hi All, I had a general query regarding modal dialogs and child windows. Is there any way by which I can restrict a CDialog instance to be within the client area of a parent window and yet also allow DoModal method to work correctly ? From what i`ve seen so far, such dialogs show the CWnd value passed to them in the constructor as the parent/owner in Spy++ but can still be moved out of it when the modal loop starts. Doing a SetParent causes both the parent and dialog to hang when i call DoModal. Thanks in Advance.

      S Offline
      S Offline
      Sarath C
      wrote on last edited by
      #2

      Hello, Change the style of the dialog as "Child" from the property window and now try. but DoModal won't work fine I think because when you do "DoModal()". the parent window being disabled thus the all of it's child windows will be disabled and you will not be able to operate anything within the new window you're showing. But the dialog will be restricted inside the parent's client area. Why you can't use Modeless dialog?

      -Sarath. "Great hopes make everything great possible" - Benjamin Franklin

      My blog - Sharing My Thoughts

      T 1 Reply Last reply
      0
      • T TyrionTheImp

        Hi All, I had a general query regarding modal dialogs and child windows. Is there any way by which I can restrict a CDialog instance to be within the client area of a parent window and yet also allow DoModal method to work correctly ? From what i`ve seen so far, such dialogs show the CWnd value passed to them in the constructor as the parent/owner in Spy++ but can still be moved out of it when the modal loop starts. Doing a SetParent causes both the parent and dialog to hang when i call DoModal. Thanks in Advance.

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

        TyrionTheImp wrote:

        Is there any way by which I can restrict a CDialog instance to be within the client area of a parent window and yet also allow DoModal method to work correctly ?

        Something like this?

        "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

        T 1 Reply Last reply
        0
        • S Sarath C

          Hello, Change the style of the dialog as "Child" from the property window and now try. but DoModal won't work fine I think because when you do "DoModal()". the parent window being disabled thus the all of it's child windows will be disabled and you will not be able to operate anything within the new window you're showing. But the dialog will be restricted inside the parent's client area. Why you can't use Modeless dialog?

          -Sarath. "Great hopes make everything great possible" - Benjamin Franklin

          My blog - Sharing My Thoughts

          T Offline
          T Offline
          TyrionTheImp
          wrote on last edited by
          #4

          Hi Sarath, Ur absolutely right, thats the first thing i tried and it completely hangs the entire application UI itslef

          1 Reply Last reply
          0
          • D David Crow

            TyrionTheImp wrote:

            Is there any way by which I can restrict a CDialog instance to be within the client area of a parent window and yet also allow DoModal method to work correctly ?

            Something like this?

            "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

            T Offline
            T Offline
            TyrionTheImp
            wrote on last edited by
            #5

            Hi David, That sample looks interesting....i`ll try tweaking the GetOwner and SetParent part right now :)

            T 1 Reply Last reply
            0
            • T TyrionTheImp

              Hi David, That sample looks interesting....i`ll try tweaking the GetOwner and SetParent part right now :)

              T Offline
              T Offline
              TyrionTheImp
              wrote on last edited by
              #6

              Hey Guys, Thanks to David`s sample I found a "fix" for this issue... u need to set the owner in the initdialog function and also manage the visibility state urself. This, along with the code to restrict the dialog`s movements makes it feel as though its an actual child window and also keeps DoModal working. Thanks to all for the help. Appreciate it I do.

              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