Refreshing dialog 
Author Message
 Refreshing dialog

Dear friends,

I have a check if a data file is opened as shown in the code below. It
works ok, but my problem is that afterwards, instead of staying in the
same dialog and allow me to enter another data file, it proceeds to the
next dialog. How can i refresh the same dialog for a second chance to
enter another file?

 if (!datafile.is_open())  //checks to see if file opens successfully
 {
  MessageBox("The file was not opened.\n Please retry", "Error message",
MB_OK | MB_ICONINFORMATION);
 }

Thanks,
Elias



Sat, 16 Aug 2003 09:38:30 GMT  
 Refreshing dialog

Quote:
> same dialog and allow me to enter another data file, it proceeds to the
> next dialog. How can i refresh the same dialog..

What dialog are you using? Where is your handler for checking the validity
of file?

--
Ajay Kalra [MVP - VC++]

Note: Please post all replies to newsgroup only.


Quote:
> Dear friends,

> I have a check if a data file is opened as shown in the code below. It
> works ok, but my problem is that afterwards, instead of staying in the
> same dialog and allow me to enter another data file, it proceeds to the
> next dialog. How can i refresh the same dialog for a second chance to
> enter another file?

>  if (!datafile.is_open())  //checks to see if file opens successfully
>  {
>   MessageBox("The file was not opened.\n Please retry", "Error message",
> MB_OK | MB_ICONINFORMATION);
>  }

> Thanks,
> Elias



Sat, 16 Aug 2003 11:15:30 GMT  
 Refreshing dialog
Here is how i call my dialog:
void CDialog1Dlg::OnBrowse()
{
 CFileDialog dlg(
  true,
  NULL,
  NULL,
  OFN_HIDEREADONLY,
  _T("Text files (.txt)|*.txt|")
  _T("|")
  );
 if (IDOK!=dlg.DoModal())
  return;
 m_FileNameFull = dlg.GetPathName();
 m_filename = dlg.GetFileName();
 UpdateData(false);
 UpdateOKUI();

Quote:
}

I hope this makes more sense,
Elias
Quote:

> > same dialog and allow me to enter another data file, it proceeds to the
> > next dialog. How can i refresh the same dialog..

> What dialog are you using? Where is your handler for checking the validity
> of file?

> --
> Ajay Kalra [MVP - VC++]

> Note: Please post all replies to newsgroup only.



> > Dear friends,

> > I have a check if a data file is opened as shown in the code below. It
> > works ok, but my problem is that afterwards, instead of staying in the
> > same dialog and allow me to enter another data file, it proceeds to the
> > next dialog. How can i refresh the same dialog for a second chance to
> > enter another file?

> >  if (!datafile.is_open())  //checks to see if file opens successfully
> >  {
> >   MessageBox("The file was not opened.\n Please retry", "Error message",
> > MB_OK | MB_ICONINFORMATION);
> >  }

> > Thanks,
> > Elias



Sat, 16 Aug 2003 12:40:05 GMT  
 Refreshing dialog
Hi Elias!

Can't find your file check in the new code...
Need both to help you...

If you check after the "dlg.DoModal()" the file dialog is already closed...

ciao
Andreas



Sat, 16 Aug 2003 18:42:11 GMT  
 Refreshing dialog
What do you mean by file check? What should i look for?
Quote:

> Hi Elias!

> Can't find your file check in the new code...
> Need both to help you...

> If you check after the "dlg.DoModal()" the file dialog is already closed...

> ciao
> Andreas



Sun, 17 Aug 2003 07:22:17 GMT  
 Refreshing dialog
Why use UpdateData (which I consider really harmful). Instead, create
a control-type variable for whatever controls and call SetWindowText.
See my essays on dialog control management, avoiding UpdateData, and
avoiding GetDlgItem on my MVP Tips site. What I don't understand here
is where your test about the file open was done, and what the
consequence of doing it was. All I see in your previous message is a
statement that issues an error message, and all I see in this example
is a fairly normal file dialog being invoked in the context of another
dialog. How are the two examples connected?
                                joe

On Mon, 26 Feb 2001 21:40:05 -0700, Elias Kyriakides

Quote:

>Here is how i call my dialog:
>void CDialog1Dlg::OnBrowse()
>{
> CFileDialog dlg(
>  true,
>  NULL,
>  NULL,
>  OFN_HIDEREADONLY,
>  _T("Text files (.txt)|*.txt|")
>  _T("|")
>  );
> if (IDOK!=dlg.DoModal())
>  return;
> m_FileNameFull = dlg.GetPathName();
> m_filename = dlg.GetFileName();
> UpdateData(false);
> UpdateOKUI();
>}

>I hope this makes more sense,
>Elias


>> > same dialog and allow me to enter another data file, it proceeds to the
>> > next dialog. How can i refresh the same dialog..

>> What dialog are you using? Where is your handler for checking the validity
>> of file?

>> --
>> Ajay Kalra [MVP - VC++]

>> Note: Please post all replies to newsgroup only.



>> > Dear friends,

>> > I have a check if a data file is opened as shown in the code below. It
>> > works ok, but my problem is that afterwards, instead of staying in the
>> > same dialog and allow me to enter another data file, it proceeds to the
>> > next dialog. How can i refresh the same dialog for a second chance to
>> > enter another file?

>> >  if (!datafile.is_open())  //checks to see if file opens successfully
>> >  {
>> >   MessageBox("The file was not opened.\n Please retry", "Error message",
>> > MB_OK | MB_ICONINFORMATION);
>> >  }

>> > Thanks,
>> > Elias

Joseph M. Newcomer [MVP]

Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm


Sun, 17 Aug 2003 14:38:13 GMT  
 Refreshing dialog
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:

> Why use UpdateData (which I consider really harmful). Instead, create
> a control-type variable for whatever controls and call SetWindowText.
> See my essays on dialog control management, avoiding UpdateData, and
> avoiding GetDlgItem on my MVP Tips site. What I don't understand here
> is where your test about the file open was done, and what the
> consequence of doing it was. All I see in your previous message is a
> statement that issues an error message, and all I see in this example
> is a fairly normal file dialog being invoked in the context of another
> dialog. How are the two examples connected?
>                                 joe

> On Mon, 26 Feb 2001 21:40:05 -0700, Elias Kyriakides

> >Here is how i call my dialog:
> >void CDialog1Dlg::OnBrowse()
> >{
> > CFileDialog dlg(
> >  true,
> >  NULL,
> >  NULL,
> >  OFN_HIDEREADONLY,
> >  _T("Text files (.txt)|*.txt|")
> >  _T("|")
> >  );
> > if (IDOK!=dlg.DoModal())
> >  return;
> > m_FileNameFull = dlg.GetPathName();
> > m_filename = dlg.GetFileName();
> > UpdateData(false);
> > UpdateOKUI();
> >}

> >I hope this makes more sense,
> >Elias


> >> > same dialog and allow me to enter another data file, it proceeds to the
> >> > next dialog. How can i refresh the same dialog..

> >> What dialog are you using? Where is your handler for checking the validity
> >> of file?

> >> --
> >> Ajay Kalra [MVP - VC++]

> >> Note: Please post all replies to newsgroup only.



> >> > Dear friends,

> >> > I have a check if a data file is opened as shown in the code below. It
> >> > works ok, but my problem is that afterwards, instead of staying in the
> >> > same dialog and allow me to enter another data file, it proceeds to the
> >> > next dialog. How can i refresh the same dialog for a second chance to
> >> > enter another file?

> >> >  if (!datafile.is_open())  //checks to see if file opens successfully
> >> >  {
> >> >   MessageBox("The file was not opened.\n Please retry", "Error message",
> >> > MB_OK | MB_ICONINFORMATION);
> >> >  }

> >> > Thanks,
> >> > Elias

> Joseph M. Newcomer [MVP]

> Web: http://www.*-*-*.com/ ~newcomer
> MVP Tips: http://www.*-*-*.com/ ~newcomer/mvp_tips.htm



Sun, 17 Aug 2003 14:54:18 GMT  
 Refreshing dialog
Well, you say that if you get the message about the file not found you
don't want to exit the dialog. Yet the code you showed clearly does
this!  For example, if you did

if(!mainprogram())
    return;

and made mainprogram() a BOOL-returning function that returned FALSE
if the file was not found, your problem would go away.
                        joe

On Tue, 27 Feb 2001 23:54:18 -0700, Elias Kyriakides

Quote:

>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);
>}

>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


>> Why use UpdateData (which I consider really harmful). Instead, create
>> a control-type variable for whatever controls and call SetWindowText.
>> See my essays on dialog control management, avoiding UpdateData, and
>> avoiding GetDlgItem on my MVP Tips site. What I don't understand here
>> is where your test about the file open was done, and what the
>> consequence of doing it was. All I see in your previous message is a
>> statement that issues an error message, and all I see in this example
>> is a fairly normal file dialog being invoked in the context of another
>> dialog. How are the two examples connected?
>>                                 joe

>> On Mon, 26 Feb 2001 21:40:05 -0700, Elias Kyriakides

>> >Here is how i call my dialog:
>> >void CDialog1Dlg::OnBrowse()
>> >{
>> > CFileDialog dlg(
>> >  true,
>> >  NULL,
>> >  NULL,
>> >  OFN_HIDEREADONLY,
>> >  _T("Text files (.txt)|*.txt|")
>> >  _T("|")
>> >  );
>> > if (IDOK!=dlg.DoModal())
>> >  return;
>> > m_FileNameFull = dlg.GetPathName();
>> > m_filename = dlg.GetFileName();
>> > UpdateData(false);
>> > UpdateOKUI();
>> >}

>> >I hope this makes more sense,
>> >Elias


>> >> > same dialog and allow me to enter another data file, it proceeds to the
>> >> > next dialog. How can i refresh the same dialog..

>> >> What dialog are you using? Where is your handler for checking the validity
>> >> of file?

>> >> --
>> >> Ajay Kalra [MVP - VC++]

>> >> Note: Please post all replies to newsgroup only.



>> >> > Dear friends,

>> >> > I have a check if a data file is opened as shown in the code below. It
>> >> > works ok, but my problem is that afterwards, instead of staying in the
>> >> > same dialog and allow me to enter another data file, it proceeds to the
>> >> > next dialog. How can i refresh the same dialog for a second chance to
>> >> > enter another file?

>> >> >  if (!datafile.is_open())  //checks to see if file opens successfully
>> >> >  {
>> >> >   MessageBox("The file was not opened.\n Please retry", "Error message",
>> >> > MB_OK | MB_ICONINFORMATION);
>> >> >  }

>> >> > Thanks,
>> >> > Elias

>> Joseph M. Newcomer [MVP]

>> Web: http://www.*-*-*.com/ ~newcomer
>> MVP Tips: http://www.*-*-*.com/ ~newcomer/mvp_tips.htm

Joseph M. Newcomer [MVP]

Web: http://www.*-*-*.com/ ~newcomer
MVP Tips: http://www.*-*-*.com/ ~newcomer/mvp_tips.htm


Mon, 18 Aug 2003 09:43:50 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Refresh Dialog box???

2. Please help on refreshing dialog after error

3. Refreshing dialog

4. refreshing dialogs

5. Please help on refreshing dialog after error

6. Refreshing Dialogs - Urgent

7. Refresh Dialog????

8. Refresh one Dialog after pressing OK in an other dialog

9. Stop Refresh, Add Controls, Continue Refreshing WinForm.

10. How to refresh my dialog box whenever it gets focus after changes in Registry

11. Automatic dialog box refreshing

12. Problem using MFC modal dialog with long animation refresh

 

 
Powered by phpBB® Forum Software