Click here to Skip to main content
15,795,789 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
My project is a MFC project based on dialogs. The class name of my parent dialog is CdialogchangDlg and my child dialogs are CPicture2 and CPicture3. I can access my child dialogs. Now I want to go to another child dialog from one child dialog, I use buttons to do this.

The code is:
void CPicture2::OnBnClickedButton1()
	CPicture3 pic3;

void CPicture3::OnBnClickedButton1()
	CPicture2 pic2;

The program runs without problems. But when I click the button about 300 times to change dialog box between the two child dialogs the program is dead. When I click the button, I find the internal memory gave to the program go up with no stop until the program is dead. Some people said when I use DoModal() the current dialog is not really destroyed. Is that true? And how could I resolve this problem?
I am a freshman, thank you.
Updated 18-May-10 7:13am

1 solution

You are just filling the stack up with CPicture2 and CPicture3 dialogs. Eventually you will run out of resources. I would recommend that instead of switching from child to child, have the parent create modeless dialogs instead. :)
Share this answer
Jeson.DJ 18-May-10 20:43pm    
Thank you for your advise.

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