Making Child Dialogs?
-
So I'm making a dialog based app in MFC, and I'd like to make a child Dialog that is acts like a control and part of my parent dialog... Seems like a very easy task, but for some reason I must be doing something wrong... I see a tutorial here on CP explaining it (http://www.codeproject.com/KB/dialog/CRHChildDialog.aspx[^]), but I don't like that solution, I'd rather not have to include someone else's custom code in my project... Anyone know of any other tutorials? Sorry if this has been asked before; I searched and didn't find much.
-
So I'm making a dialog based app in MFC, and I'd like to make a child Dialog that is acts like a control and part of my parent dialog... Seems like a very easy task, but for some reason I must be doing something wrong... I see a tutorial here on CP explaining it (http://www.codeproject.com/KB/dialog/CRHChildDialog.aspx[^]), but I don't like that solution, I'd rather not have to include someone else's custom code in my project... Anyone know of any other tutorials? Sorry if this has been asked before; I searched and didn't find much.
Well, the mentionned article looks like a great tutorial, it probably wraps usual code for doing that sort of task : but it general it goes like that ( will not show you code since you do not want to use someone else's code ) - create parent dialog resource with a "placeholder" for the child dialog. - create dialog resource with the "control parent" style (and another flag that I forget the name ) - create the parent dialog as you would do normally. - in the OnInitDialog, get the
RECT
of the placeholder, create the child dialog (as a member of the parent dialog).Create
it in the appropriate position, using the RECT. normaly, that will be sufficent (as far as I can recall now )Maximilien Lincourt Your Head A Splode - Strong Bad
-
Well, the mentionned article looks like a great tutorial, it probably wraps usual code for doing that sort of task : but it general it goes like that ( will not show you code since you do not want to use someone else's code ) - create parent dialog resource with a "placeholder" for the child dialog. - create dialog resource with the "control parent" style (and another flag that I forget the name ) - create the parent dialog as you would do normally. - in the OnInitDialog, get the
RECT
of the placeholder, create the child dialog (as a member of the parent dialog).Create
it in the appropriate position, using the RECT. normaly, that will be sufficent (as far as I can recall now )Maximilien Lincourt Your Head A Splode - Strong Bad
Hmmm, I'm getting a crash/assert when I try and do it myself in void AFXAPI AfxHookWindowCreate(CWnd* pWnd) on the line: ASSERT(pWnd->m_hWnd == NULL); Any ideas why? I googled for an answer to this problem, and although I found 10 pages of other people having the problem, I didn't see any answers :-( This is what I'm doing: (following the tutorial minus the part about using his giant class) - I created a parent dialog, put a placeholder resource on it where the child will go - created the child dialog resource with Style: Child, Border: None, Control: True - created a normal parent dialog as I always do - in the parent's DoDataExchange i used the DDX_Control function to tie the placeholder resource to my Child member object - in the parent's OnInitDialog i call .Create for the child dialog, there is only 2 versions of create, wich both take the Template ID/Name, and a CWnd*, so i passed the child resource's ID (IDD_CHILDDIALOG), and "this" any ideas? :confused:
-
Hmmm, I'm getting a crash/assert when I try and do it myself in void AFXAPI AfxHookWindowCreate(CWnd* pWnd) on the line: ASSERT(pWnd->m_hWnd == NULL); Any ideas why? I googled for an answer to this problem, and although I found 10 pages of other people having the problem, I didn't see any answers :-( This is what I'm doing: (following the tutorial minus the part about using his giant class) - I created a parent dialog, put a placeholder resource on it where the child will go - created the child dialog resource with Style: Child, Border: None, Control: True - created a normal parent dialog as I always do - in the parent's DoDataExchange i used the DDX_Control function to tie the placeholder resource to my Child member object - in the parent's OnInitDialog i call .Create for the child dialog, there is only 2 versions of create, wich both take the Template ID/Name, and a CWnd*, so i passed the child resource's ID (IDD_CHILDDIALOG), and "this" any ideas? :confused: