
Please help on refreshing dialog after error
OK, i hope this will be more clear:
I call my mainprogram function (where the data file is tested for existence and
other calculations are performed), from the OnOK() function
void CDialog1Dlg::OnOK()
{
mainprogram(); //Calls the function mainprogram When this process ends, the
estimator finishes.
CDialog::OnOK();
MessageBox("The Estimator has finished.", "Simulation Finished", MB_OK |
MB_ICONINFORMATION);
Quote:
}
The check for the data file is in the main program as shown below:
if (!datafile.is_open())
{
MessageBox("The file was not opened.\n Please retry", "Error message",
MB_OK | MB_ICONINFORMATION);
}
So, i guess one solution would be to take it above before mainprogram is even called
but i prefer to have it in the main program since that is the place from where i
read the data from the file.
Do you have any suggestions on that? Can you show me some code as well so that i
will be sure i don't{*filter*}up?
Thanks,
Elias
Quote:
> > What i am trying to do is the following:
> > I have a dialog where the user can input the data file. When this is not
> > valid, he gets an output message through the message box like so:
> > if (!datafile.is_open())
> > {
> > MessageBox("The file was not opened.\n Please retry", "Error message",
> > MB_OK | MB_ICONINFORMATION);
> > }
> > Now, i want after i click OK on that message box, to get the original
> > dialog again to give me a chance to input another file. What happens
> > now, is that after i click OK on the message box, the program just
> > continues skipping the dialog.
> > How can i correct this?
> > Thanks,
> > Elias
> Why does it skip the dialog? Are you calling the dialog's OnOK or OnCancel? Do
> you close the dialog before displaying the message box? You are not explaining
> what is happening so it is difficult to help you stop it from happening.
> I could suggest that you try executing a return when the user clicks OK on the
> message box, but you are not revealing any code context so it is only a wild
> guess.
> --
> Scott McPhillips [VC++ MVP]