Parenting a modal CDialog
-
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.
-
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.
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
-
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.
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
-
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
Hi Sarath, Ur absolutely right, thats the first thing i tried and it completely hangs the entire application UI itslef
-
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
Hi David, That sample looks interesting....i`ll try tweaking the GetOwner and SetParent part right now :)
-
Hi David, That sample looks interesting....i`ll try tweaking the GetOwner and SetParent part right now :)
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.