diffusedoc.cpp

来自「visual c++数字图像与图形处理中的光盘内容」· C++ 代码 · 共 115 行

CPP
115
字号
// DiffuseDoc.cpp : implementation of the CDiffuseDoc class
//

#include "stdafx.h"
#include "Diffuse.h"

#include "DiffuseDoc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


/////////////////////////////////////////////////////////////////////////////
// CDiffuseDoc

IMPLEMENT_DYNCREATE(CDiffuseDoc, CDocument)

BEGIN_MESSAGE_MAP(CDiffuseDoc, CDocument)
	//{{AFX_MSG_MAP(CDiffuseDoc)
	ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDiffuseDoc construction/destruction

CDiffuseDoc::CDiffuseDoc()
{
	// TODO: add one-time construction code here
	m_pDib = NULL;
}

CDiffuseDoc::~CDiffuseDoc()
{
	if(m_pDib) delete m_pDib;
}

BOOL CDiffuseDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	// TODO: add reinitialization code here
	// (SDI documents will reuse this document)

	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CDiffuseDoc serialization

void CDiffuseDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		// TODO: add storing code here
	}
	else
	{
		// TODO: add loading code here
	}
}

/////////////////////////////////////////////////////////////////////////////
// CDiffuseDoc diagnostics

#ifdef _DEBUG
void CDiffuseDoc::AssertValid() const
{
	CDocument::AssertValid();
}

void CDiffuseDoc::Dump(CDumpContext& dc) const
{
	CDocument::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CDiffuseDoc commands

void CDiffuseDoc::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 CDiffuseDoc::DeleteContents() 
{
	// TODO: Add your specialized code here and/or call the base class
	if (m_pDib)
    {
        delete m_pDib;
        m_pDib = NULL;
    }	
	CDocument::DeleteContents();
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?