⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 barrecogdoc.cpp

📁 采用Visual C++开发平台开发了一个条形码识别系统。该系统采用图像处理技术对条形码图像的噪声进行处理
💻 CPP
字号:
// BarRecogDoc.cpp : implementation of the CBarRecogDoc class
//

#include "stdafx.h"
#include "BarRecog.h"

#include "BarRecogDoc.h"

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

/////////////////////////////////////////////////////////////////////////////
// CBarRecogDoc

IMPLEMENT_DYNCREATE(CBarRecogDoc, CDocument)

BEGIN_MESSAGE_MAP(CBarRecogDoc, CDocument)
	//{{AFX_MSG_MAP(CBarRecogDoc)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CBarRecogDoc construction/destruction

CBarRecogDoc::CBarRecogDoc()
{
	// TODO: add one-time construction code here

}

CBarRecogDoc::~CBarRecogDoc()
{
}

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

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

	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CBarRecogDoc serialization

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

/////////////////////////////////////////////////////////////////////////////
// CBarRecogDoc diagnostics

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

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

/////////////////////////////////////////////////////////////////////////////
// CBarRecogDoc commands

BOOL CBarRecogDoc::OnOpenDocument(LPCTSTR lpszPathName) 
{
	if (!CDocument::OnOpenDocument(lpszPathName))
		return FALSE;
	
	// TODO: Add your specialized creation code here
	CFile file;
	CFileException fe;
	if(!file.Open(lpszPathName,CFile::modeRead|CFile::shareDenyWrite,&fe)) // no notion***
	{
		ReportSaveLoadException(lpszPathName,&fe,FALSE,AFX_IDP_FAILED_TO_OPEN_DOC);
		return FALSE;
	}

	DeleteContents();
	BeginWaitCursor();

	TRY
	{
		m_DIB.Read(file);
	}
	CATCH(CFileException,eLoad)
	{
		file.Abort();
		EndWaitCursor();
		ReportSaveLoadException(lpszPathName,eLoad,FALSE,AFX_IDP_FAILED_TO_OPEN_DOC);
		return FALSE;
	}
	END_CATCH
	
	EndWaitCursor();

	if(!m_DIB.IsValid())
	{
		CString strMsg="File can't open!";
		MessageBox(NULL,strMsg,NULL,MB_ICONINFORMATION|MB_OK);
		return FALSE;
	}
	SetPathName(lpszPathName);
	SetModifiedFlag(FALSE);
	return TRUE;
}

BOOL CBarRecogDoc::OnSaveDocument(LPCTSTR lpszPathName) 
{
	CFile file;
	CFileException fe;

	if(!file.Open(lpszPathName,CFile::modeCreate|CFile::modeReadWrite|CFile::shareExclusive,&fe))
	{
		ReportSaveLoadException(lpszPathName,&fe,TRUE,AFX_IDP_INVALID_FILENAME);
		return FALSE;
	}

	BOOL bSuccess=FALSE;
	TRY
	{
		BeginWaitCursor();  
		bSuccess=m_DIB.Save(file);
		file.Close();
	}
	CATCH(CException,eSave)
	{
		file.Abort();
		EndWaitCursor();
		ReportSaveLoadException(lpszPathName,eSave,TRUE,AFX_IDP_FAILED_TO_SAVE_DOC);
		return FALSE;
	}
	END_CATCH

	EndWaitCursor();
	SetModifiedFlag(FALSE);

	if(!bSuccess)
	{
		CString strMsg;
		strMsg="不能打开";
		MessageBox(NULL,strMsg,NULL,MB_ICONINFORMATION|MB_OK);
	}
	return TRUE;
}

⌨️ 快捷键说明

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