hi
i have an application where the user need to save his information.
the first time he saves...a save dialog appears and the process goes as normal .
but here is my question..
if he add any modification to his info and press the save button again ...i dont want the save dialog appears for the second time (it is the job for save as)...how can i do that ??
i mean..how can i make the save dialog appears just if its the first time to save... and if there is more ...just save without any dialogs appearing.
i hope i make my self clear
thank u all

Recommended Answers

All 3 Replies

You will have to keep track of whether or not the user has supplied a filename yet.
If not, display the save dialog.
If he has, then don't bother displaying the dialog and just save the file.

Essentially, your OnClick handler for the button should work like this:

if (user has not supplied a filename)
  {
  get filename from user using the dialog;
  if user canceled, return;
  }
save the file;
return;

Hope this helps.

thanks
but do u know how could that code be written into this :

void CBmpDlgDlg::OnButton2() 
{
	// TODO: Add your control notification handler code here

this->UpdateData();

	CFile f;

	char strFilter[] = { "CCC Files (*.ccc)|*.ccc|All Files (*.*)|*.*||" };

	CFileDialog FileDlg(FALSE, ".ccc", NULL, 0, strFilter);

	if( FileDlg.DoModal() == IDOK )
	{
	f.Open(FileDlg.GetFileName(), CFile::modeCreate | CFile::modeWrite);
		CArchive ar(&f, CArchive::store);

		ar << m_EDIT1<<m_EDIT2;
		ar.Close();
	}
	else
		return;

	f.Close();


}

Yes. I know.

But you ought to be able to do it yourself.

You'll need a CString in your Form class to remember the name of the file. If there is no file, the string should be empty.

You'll need an if statement somewhere in the function to see whether or not to call the dialog. If you do, you'll have to update the remembered filename variable.

Then open the file and write it.

Good luck.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.