
// CSingleDoc 명령
BOOL CSingleDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
// TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다.
CFile file;
CFileException fe;
CString temp;
temp = _T("\"Demo Page \"\r\n");
temp += _T("\"If you want show this page, you must save file\"\r\n");
int length = temp.GetLength();
if (!file.Open(lpszPathName, CFile::modeCreate |
CFile::modeReadWrite | CFile::shareExclusive, &fe))
{
ReportSaveLoadException(lpszPathName, &fe,
TRUE, AFX_IDP_INVALID_FILENAME);
return FALSE;
}
// replace calls to Serialize with SaveDIB function
BOOL bSuccess = FALSE;
TRY
{
BeginWaitCursor();
//bSuccess = ::SaveDIB(m_hDIB, file);
file.Write(temp,length*2);
bSuccess = TRUE;
file.Close();
}
CATCH (CException, eSave)
{
file.Abort(); // will not throw an exception
EndWaitCursor();
ReportSaveLoadException(lpszPathName, eSave,
TRUE, AFX_IDP_FAILED_TO_SAVE_DOC);
return FALSE;
}
END_CATCH
EndWaitCursor();
SetModifiedFlag(FALSE); // back to unmodified
if (!bSuccess)
{
// may be other-style DIB (load supported but not save)
// or other problem in SaveDIB
CString strMsg;
//strMsg.LoadString(IDS_CANNOT_SAVE_DIB);
strMsg = _T("저장중 에러가 발생했습니다.");
MessageBox(NULL, strMsg, NULL, MB_ICONINFORMATION | MB_OK);
}
return bSuccess;
//return CDocument::OnSaveDocument(lpszPathName);
}