Click here to Skip to main content
15,886,919 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionproblem using ADO with C++ Pin
Herr_Ernst11-Nov-05 13:15
Herr_Ernst11-Nov-05 13:15 
AnswerRe: problem using ADO with C++ Pin
Herr_Ernst11-Nov-05 13:33
Herr_Ernst11-Nov-05 13:33 
QuestionMDI Application Pin
masnu11-Nov-05 12:10
masnu11-Nov-05 12:10 
AnswerRe: MDI Application Pin
Cool Ju13-Nov-05 22:31
Cool Ju13-Nov-05 22:31 
GeneralRe: MDI Application Pin
masnu14-Nov-05 2:56
masnu14-Nov-05 2:56 
Questionwhy this is not called? CMyDoc::Serialize(CMyArchive& ar) Pin
lucy11-Nov-05 10:39
lucy11-Nov-05 10:39 
AnswerRe: why this is not called? CMyDoc::Serialize(CMyArchive& ar) Pin
Cool Ju13-Nov-05 22:52
Cool Ju13-Nov-05 22:52 
GeneralRe: why this is not called? CMyDoc::Serialize(CMyArchive& ar) Pin
lucy14-Nov-05 9:07
lucy14-Nov-05 9:07 
hi Cool Ju, Thank you for the direction, but I didn't quite follow.

How do I override Serialize(CArchive& ar)? I tried to replace
virtual void Serialize(CArchive& ar)
with
virtual void Serialize(CMyArchive& ar)
in myDoc.h, but it doesn't work.

Now what I do is in myDoc.h, add
virtual BOOL OnSaveDocument(LPCTSTR lpszPathName);

and in myDoc.cpp, implemented it as follows:
<br />
	// TODO: copied from CDocument::OnSaveDocument(lpszPathName);,<br />
    // but instead of using the default CArchive, <br />
    // use CMyArchive<br />
	<br />
	CFileException fe;<br />
	CFile* pFile = NULL;<br />
	pFile = GetFile(lpszPathName, CFile::modeCreate |<br />
		CFile::modeReadWrite | CFile::shareExclusive, &fe);<br />
<br />
	if (pFile == NULL)<br />
	{<br />
		ReportSaveLoadException(lpszPathName, &fe,<br />
			TRUE, AFX_IDP_INVALID_FILENAME);<br />
		return FALSE;<br />
	}<br />
<br />
	//CArchive saveArchive(pFile, CArchive::store | CArchive::bNoFlushOnDelete);<br />
	CMyArchivesaveArchive(pFile, CArchive::store | CArchive::bNoFlushOnDelete);<br />
	saveArchive.m_pDocument = this;<br />
	saveArchive.m_bForceFlat = FALSE;<br />
	TRY<br />
	{<br />
		CWaitCursor wait;<br />
		Serialize(saveArchive);     // save me<br />
		saveArchive.Close();<br />
		ReleaseFile(pFile, FALSE);<br />
	}<br />
	CATCH_ALL(e)<br />
	{<br />
		ReleaseFile(pFile, TRUE);<br />
#if 0<br />
		TRY<br />
		{<br />
			ReportSaveLoadException(lpszPathName, e,<br />
				TRUE, AFX_IDP_FAILED_TO_SAVE_DOC);<br />
		}<br />
		END_TRY<br />
		DELETE_EXCEPTION(e);<br />
#endif<br />
		return FALSE;<br />
	}<br />
	END_CATCH_ALL<br />
<br />
	SetModifiedFlag(FALSE);     // back to unmodified<br />
<br />
	return TRUE;        // success<br />
	//return CDocument::OnSaveDocument(lpszPathName);<br />
<br />



but I got a new problem here, I have to #if 0 some of the code out, cause the compiler complains that DELETE_EXCEPTION is not defined.

more hints please? Rose | [Rose] Rose | [Rose] Rose | [Rose]
AnswerRe: why this is not called? CMyDoc::Serialize(CMyArchive&amp;amp;amp;amp; ar) Pin
Cool Ju14-Nov-05 16:53
Cool Ju14-Nov-05 16:53 
GeneralRe: why this is not called? CMyDoc::Serialize(CMyArchive&amp;amp;amp;amp;amp; ar) Pin
lucy15-Nov-05 3:44
lucy15-Nov-05 3:44 
QuestionSelective iterator over STL vector. Pin
Maximilien11-Nov-05 10:08
Maximilien11-Nov-05 10:08 
AnswerRe: Selective iterator over STL vector. Pin
Chris Losinger11-Nov-05 10:27
professionalChris Losinger11-Nov-05 10:27 
AnswerRe: Selective iterator over STL vector. Pin
S. Senthil Kumar11-Nov-05 23:24
S. Senthil Kumar11-Nov-05 23:24 
GeneralRe: Selective iterator over STL vector. Pin
Jeremy Thornton12-Nov-05 5:39
Jeremy Thornton12-Nov-05 5:39 
Questionthe knight's tour, solution in cpp Pin
codologyst11-Nov-05 9:06
codologyst11-Nov-05 9:06 
AnswerRe: the knight's tour, solution in cpp Pin
Maximilien11-Nov-05 9:29
Maximilien11-Nov-05 9:29 
QuestionFindFirstPrinterChangeNotification fails on XP laptop. Pin
Flit11-Nov-05 7:35
Flit11-Nov-05 7:35 
QuestionRe: FindFirstPrinterChangeNotification fails on XP laptop. Pin
David Crow11-Nov-05 8:44
David Crow11-Nov-05 8:44 
AnswerRe: FindFirstPrinterChangeNotification fails on XP laptop. Pin
Flit11-Nov-05 19:38
Flit11-Nov-05 19:38 
AnswerRe: FindFirstPrinterChangeNotification fails on XP laptop. Pin
Graham Bradshaw11-Nov-05 8:53
Graham Bradshaw11-Nov-05 8:53 
GeneralRe: FindFirstPrinterChangeNotification fails on XP laptop. Pin
Flit11-Nov-05 20:01
Flit11-Nov-05 20:01 
QuestionNavigate2 issue Pin
Hans Ruck11-Nov-05 6:56
Hans Ruck11-Nov-05 6:56 
AnswerRe: Navigate2 issue Pin
ThatsAlok13-Nov-05 18:08
ThatsAlok13-Nov-05 18:08 
GeneralRe: Navigate2 issue Pin
Hans Ruck13-Nov-05 21:00
Hans Ruck13-Nov-05 21:00 
Questionimporting template classes from dll Pin
Themis11-Nov-05 6:32
Themis11-Nov-05 6:32 

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.