Click here to Skip to main content
15,906,341 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear,

I built a default dialog project and added one more dialog to display when user presses OK button.
IDD_DIALOG1 has a few controls as button and editbox but it does not display the button and editbox if create modaless dialog as follow:
If somebody know why, please advice me.

void CTestDlg::OnOK()
{
   CDlgTest *dlg;

   dlg = new CDlgTest(this);
   dlg->Create(IDD_DIALOG1, this );
   dlg->ShowWindow(SW_SHOW);
   Sleep(10000);
   dlg->DestroyWindwo();
   delete dlg;
}
Posted
Updated 19-Oct-10 21:38pm
v3
Comments
Dalek Dave 20-Oct-10 3:38am    
Edited for Syntax.

1 solution

A dialog box needs a dialog procedure in which it processes message to draw its child controls. In MFC this is handled by the dialog class.
The way you're creating is to crate it and immediately destroy it after sleeping for some time.
You're not giving MFC a chance to draw the controls.

What you have to do is to create the dialog class pointer as a member of the parent class.
You will also need to remove the destruction of the dialog from the OnOK function.
This must happen from within the child dialog.
 
Share this answer
 
Comments
Dalek Dave 20-Oct-10 3:37am    
Good Call

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