1
votes

I simply want to open a child dialog and have it print a result from the parent dialog in one of the child's static text controls. Using breakpoints I noticed that both DoDataExchange and my overloaded OnInitDialog are never called in the child so the static text control crashes any time i try to print something to it. The child dialog does display itself fine otherwise.

What could be the problem ?

//in parent.cpp
CResultsDlg childResultsDlg = this;
childResultsDlg.DoModal(15.7); //overloaded to pass value to a child member var

more information from my previous post Child Dialog - SetWindowTextA or SendMessageA crashes program - MFC

1
What is the meaning of "CResultsDlg childResultsDlg = this"? It does not appear to make sense to assign one dialog to another.ScottMcP-MVP
I did it to enable messages to be sent from the child back to the parent. I don't know another way...Soran
If I take the 'this' off the child crashes on the return of the overloaded DoModal which is "return CDialogEx::DoModal();"Soran
You have several errors and misunderstandings, but we can't see the code. Reporting that it "crashes" is insufficient information.ScottMcP-MVP
I provided a link containing several details to another question of mine with the same underlying problem...Soran

1 Answers

1
votes

All of the basics of MFC are covered in the SCRIBBLE tutorial.

http://msdn.microsoft.com/en-us/library/f35t8fts(v=vs.90).aspx

An example of passing data into a dialog and displaying that data in dialog controls is provided in the tutorial with the CPenWidthsDlg.