www.pudn.com > SobelKirsch.rar > SobelKirschDoc.cpp


// SobelKirschDoc.cpp : implementation of the CSobelKirschDoc class 
// 
 
#include "stdafx.h" 
#include "SobelKirsch.h" 
 
#include "SobelKirschDoc.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
 
///////////////////////////////////////////////////////////////////////////// 
// CSobelKirschDoc 
 
IMPLEMENT_DYNCREATE(CSobelKirschDoc, CDocument) 
 
BEGIN_MESSAGE_MAP(CSobelKirschDoc, CDocument) 
	//{{AFX_MSG_MAP(CSobelKirschDoc) 
	ON_COMMAND(ID_FILE_OPEN, OnFileOpen) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CSobelKirschDoc construction/destruction 
 
CSobelKirschDoc::CSobelKirschDoc() 
{ 
	// TODO: add one-time construction code here 
	m_pDib = NULL; 
} 
 
CSobelKirschDoc::~CSobelKirschDoc() 
{ 
	if(m_pDib) delete m_pDib; 
} 
 
BOOL CSobelKirschDoc::OnNewDocument() 
{ 
	if (!CDocument::OnNewDocument()) 
		return FALSE; 
 
	// TODO: add reinitialization code here 
	// (SDI documents will reuse this document) 
 
	return TRUE; 
} 
 
 
 
///////////////////////////////////////////////////////////////////////////// 
// CSobelKirschDoc serialization 
 
void CSobelKirschDoc::Serialize(CArchive& ar) 
{ 
	if (ar.IsStoring()) 
	{ 
		// TODO: add storing code here 
	} 
	else 
	{ 
		// TODO: add loading code here 
	} 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CSobelKirschDoc diagnostics 
 
#ifdef _DEBUG 
void CSobelKirschDoc::AssertValid() const 
{ 
	CDocument::AssertValid(); 
} 
 
void CSobelKirschDoc::Dump(CDumpContext& dc) const 
{ 
	CDocument::Dump(dc); 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CSobelKirschDoc commands 
 
void CSobelKirschDoc::OnFileOpen()  
{ 
	// TODO: Add your command handler code here 
	CFileDialog fileOpenDlg(TRUE,"bmp","*.bmp",NULL,"Bitmap Files(*.bmp)",NULL); 
	int nRespond = fileOpenDlg.DoModal(); 
	if(nRespond == IDOK) 
	{ 
		CString filePath = fileOpenDlg.GetPathName(); 
		m_pDib = new CDib(filePath); 
		if(m_pDib->IsValid()) 
			SetTitle(filePath); 
		else	 
			DeleteContents(); 
	} 
	UpdateAllViews(0);	 
} 
 
void CSobelKirschDoc::DeleteContents()  
{ 
	// TODO: Add your specialized code here and/or call the base class 
	if (m_pDib) 
    { 
        delete m_pDib; 
        m_pDib = NULL; 
    } 
	CDocument::DeleteContents(); 
}