Reputation: 49
I would like to fill some fields of my dialog when it's shown. Consequently, I would like to follow those steps:
However, I can pass to the instruction following DoModal() only when the dialog is closed. Consequently, how can I initialize my dialog's fields?
I tried to override DoModal():
int MyDialog::DoModal()
{
int a = CDialogEx::DoModal();
InitDialog();
return a;
}
but it's the same issue: InitDialog() is called when the dialog is closed...
Upvotes: 0
Views: 2118
Reputation: 830
Create the dialog object, than add OnInitDialog
on your dialog, this method will calls before showing dialog (OnInitDialog msdn).
Add variables to your dialog (int a;)
Call dailog:
CDialog dlg;
dlg.a = 10;
dlg.DoModal();
Upvotes: 3