Click here to Skip to main content
15,923,910 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how are the editor programs created? Pin
lordgreg15-Mar-04 13:58
lordgreg15-Mar-04 13:58 
GeneralRe: how are the editor programs created? Pin
John M. Drescher16-Mar-04 7:41
John M. Drescher16-Mar-04 7:41 
GeneralRe: how are the editor programs created? Pin
lordgreg16-Mar-04 9:24
lordgreg16-Mar-04 9:24 
GeneralRe: how are the editor programs created? Pin
John M. Drescher16-Mar-04 9:29
John M. Drescher16-Mar-04 9:29 
GeneralRe: how are the editor programs created? Pin
lordgreg16-Mar-04 11:35
lordgreg16-Mar-04 11:35 
QuestionMFC: How to change the default filename in the Save As dialog at runtime? Pin
Davex_15-Mar-04 10:57
Davex_15-Mar-04 10:57 
AnswerRe: MFC: How to change the default filename in the Save As dialog at runtime? Pin
basementman15-Mar-04 11:17
basementman15-Mar-04 11:17 
AnswerRe: MFC: How to change the default filename in the Save As dialog at runtime? Pin
Roger Allen16-Mar-04 0:36
Roger Allen16-Mar-04 0:36 
If you take alook at the default MFC implementation of CDocument::DoSave():

BOOL CDocument::DoSave(LPCTSTR lpszPathName, BOOL bReplace)
	// Save the document data to a file
	// lpszPathName = path name where to save document file
	// if lpszPathName is NULL then the user will be prompted (SaveAs)
	// note: lpszPathName can be different than 'm_strPathName'
	// if 'bReplace' is TRUE will change file name if successful (SaveAs)
	// if 'bReplace' is FALSE will not change path name (SaveCopyAs)
{
	CString newName = lpszPathName;
	if (newName.IsEmpty())
	{
		CDocTemplate* pTemplate = GetDocTemplate();
		ASSERT(pTemplate != NULL);

		newName = m_strPathName;
		if (bReplace && newName.IsEmpty())
		{
			newName = m_strTitle;
			// check for dubious filename
			int iBad = newName.FindOneOf(_T(" #%;/\\"));
			if (iBad != -1)
				newName.ReleaseBuffer(iBad);

			// append the default suffix if there is one
			CString strExt;
			if (pTemplate->GetDocString(strExt, CDocTemplate::filterExt) &&
			  !strExt.IsEmpty())
			{
				ASSERT(strExt[0] == '.');
				newName += strExt;
			}
		}

		if (!AfxGetApp()->DoPromptFileName(newName,
		  bReplace ? AFX_IDS_SAVEFILE : AFX_IDS_SAVEFILECOPY,
		  OFN_HIDEREADONLY | OFN_PATHMUSTEXIST, FALSE, pTemplate))
			return FALSE;       // don't even attempt to save
	}

	CWaitCursor wait;

	if (!OnSaveDocument(newName))
	{
		if (lpszPathName == NULL)
		{
			// be sure to delete the file
			TRY
			{
				CFile::Remove(newName);
			}
			CATCH_ALL(e)
			{
				TRACE0("Warning: failed to delete file after failed SaveAs.\n");
				DELETE_EXCEPTION(e);
			}
			END_CATCH_ALL
		}
		return FALSE;
	}

	// reset the title and change the document name
	if (bReplace)
		SetPathName(newName);

	return TRUE;        // success
}


If you were to override this function in your MFC document copy/paste the above and replace the bold section with your own code to determine the default filename, it should do what you need.

Roger Allen - Sonork 100.10016
Roger Wright: Remember to buckle up, please, and encourage your friends to do the same. It's not just about saving your life, but saving the quality of life for those you may leave behind...
GeneralRe: MFC: How to change the default filename in the Save As dialog at runtime? Pin
Davex_16-Mar-04 4:23
Davex_16-Mar-04 4:23 
GeneralOpen Microsoft Access file from Visual C++ Pin
utowntaz15-Mar-04 10:40
utowntaz15-Mar-04 10:40 
GeneralRe: Open Microsoft Access file from Visual C++ Pin
JWood15-Mar-04 10:50
JWood15-Mar-04 10:50 
GeneralRe: Open Microsoft Access file from Visual C++ Pin
Steve S15-Mar-04 22:08
Steve S15-Mar-04 22:08 
GeneralRe: Open Microsoft Access file from Visual C++ Pin
David Crow16-Mar-04 2:50
David Crow16-Mar-04 2:50 
GeneralAbout Calling "Help file" using "::WinHelp" command Pin
eigen15-Mar-04 10:18
eigen15-Mar-04 10:18 
GeneralRe: About Calling "Help file" using "::WinHelp" command Pin
MeterMan15-Mar-04 20:48
MeterMan15-Mar-04 20:48 
GeneralURGENT! cannot open include file Pin
BlackDice15-Mar-04 10:03
BlackDice15-Mar-04 10:03 
GeneralRe: URGENT! cannot open include file Pin
David Crow15-Mar-04 10:09
David Crow15-Mar-04 10:09 
GeneralRe: URGENT! cannot open include file Pin
l a u r e n15-Mar-04 11:53
l a u r e n15-Mar-04 11:53 
GeneralRe: URGENT! cannot open include file Pin
BlackDice16-Mar-04 4:51
BlackDice16-Mar-04 4:51 
GeneralWin32 Console Process Command Status Pin
cgusler15-Mar-04 9:14
cgusler15-Mar-04 9:14 
GeneralRe: Win32 Console Process Command Status Pin
ian mariano15-Mar-04 18:44
ian mariano15-Mar-04 18:44 
GeneralBuilding outlook 2000 add-ins Pin
Bob Stanneveld15-Mar-04 8:59
Bob Stanneveld15-Mar-04 8:59 
GeneralRe: Building outlook 2000 add-ins Pin
ravjak15-Mar-04 10:41
ravjak15-Mar-04 10:41 
GeneralRe: Building outlook 2000 add-ins Pin
Bob Stanneveld15-Mar-04 11:13
Bob Stanneveld15-Mar-04 11:13 
GeneralRe: Building outlook 2000 add-ins Pin
bryce15-Mar-04 12:15
bryce15-Mar-04 12:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.