Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've got a dialog and a button on that. And once I click the button, a child dialog should pop up.
I use some data inside the main dialog to initialise the child dialog's caption and its list box like the following.
C++
CChildDlg dlg;
dlg.SetWindowTextW(wszTitle);
dlg.m_ctrlLB.AddString(wszLBEntry);  // m_ctrlLB is a variable of type CListBox
dlg.DoModal();

But this just gives a runtime error. Anyone could help?
Thanks in advance.
Posted

You have to override OnInitDialog()[^] in your dialog class and do those updates there.

Soren Madsen
 
Share this answer
 
Well, you shouldn't be accessing the dialogs controls directly, rather, try initialiazing some public members (either using member variables or access methods) then update the controls within the dialog at the proper time. In the case of a CDialog, that would be OnInitDialog().

In the future, post what the assertion is telling you and what line within your code is triggering the assertion. Usually if you look closely at the assertion, it will tell you exactly what you need to know about what triggered it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900