Sorry... what I should have been more specific about is:
As the MSDN states:
"Being owned places several constraints on a window.
(1) An owned window is always above its owner in the z-order.
(2) The system automatically destroys an owned window when its owner is destroyed.
(3) An owned window is hidden when its owner is minimized."
I am trying to create a modeless dialog in MFC, but when i do, it has those behaviors, which are undesired.
My code to create the dialog is as follows:
[tt]CDialog::Create(IDD, NULL);[/tt]
The unfortunate problem with this is that somewhere in [tt]DLGCORE.CPP[/tt] lies the code
Ok so we are talking about the "parent" window and you want to change in dynamically.
The bottom line is that i have never had the need to do that. It makes me curious as to what your criteria is for needing to change the parent window.
It would certainly be possible to write a function in your dialog class that results in changing the assignment to the pParentWnd member of your class, however i would be dubious that the window subsystem would recognize the change in any meaninful way. At worst it might produce undesirable effects such as program termination.
Answer:
(in case anyone else was following the thread)
Well, after a bit more research into the innards of MFC, I found the undocumented function [tt]CWnd::CreateDlg(LPCTSTR lpszTemplateName, CWnd* pParentWnd)[/tt]. I think that basically this does the same thing as [tt]CDialog::Create[/tt], except that it lets you pass [tt]NULL[/tt] for [tt]pParentWnd[/tt]. At least that's what I assume, based on the results I've seen in my program.
>> It makes me curious as to what your criteria is for needing to change the parent window.
I thought I needed to change the parent window in order to set it to [tt]NULL[/tt], since [tt]CDialog::Create[/tt] is hardcoded to set the parent window to [tt]AfxGetMainWnd()[/tt] if you pass [tt]NULL[/tt] as an argument. But this [tt]CWnd::CreateDlg[/tt] function seems to work.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.