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

📄 testdoc.cpp

📁 电脑编程技巧和源码。很不错的。
💻 CPP
字号:
// TestDoc.cpp : implementation of the CTestDoc class
//

#include "stdafx.h"
#include "Test.h"

#include "TestDoc.h"

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

/////////////////////////////////////////////////////////////////////////////
// CTestDoc

IMPLEMENT_DYNCREATE(CTestDoc, CDocument)

BEGIN_MESSAGE_MAP(CTestDoc, CDocument)
	//{{AFX_MSG_MAP(CTestDoc)
	ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
	ON_COMMAND(IDM_PROC_HISTOGRAM, OnProcHistogram)
	ON_UPDATE_COMMAND_UI(IDM_PROC_HISTOGRAM, OnUpdateProcHistogram)
	ON_COMMAND(IDM_PROC_HIGHPASSFILTERING, OnProcHighpassfiltering)
	ON_UPDATE_COMMAND_UI(IDM_PROC_HIGHPASSFILTERING, OnUpdateProcHighpassfiltering)
	ON_COMMAND(IDM_PROC_MASKFILTERING, OnProcMaskfiltering)
	ON_UPDATE_COMMAND_UI(IDM_PROC_MASKFILTERING, OnUpdateProcMaskfiltering)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTestDoc construction/destruction

extern CScrollView* pView;

CTestDoc::CTestDoc()
{
	m_pDib = NULL;
	m_sizeDoc = CSize( 0, 0 );
}

CTestDoc::~CTestDoc()
{
}

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

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

	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CTestDoc serialization

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

/////////////////////////////////////////////////////////////////////////////
// CTestDoc diagnostics

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

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

/////////////////////////////////////////////////////////////////////////////
// CTestDoc commands

CSize CTestDoc::GetDocSize()
{
	return m_sizeDoc;
}

void CTestDoc::OnFileOpen() 
{
	CFileDialog dlg( TRUE, "BMP", "*.bmp" );
	if( dlg.DoModal() != IDOK )
		return;

	CString str = dlg.GetPathName();
	m_pDib = (CDib*)new CDib( str );

	if( !m_pDib->GetBmpInfoPtr() )
	{
		DeleteContents();
		return;
	}
	else
	{
		m_sizeDoc.cx = m_pDib->GetBmpWidth();
		m_sizeDoc.cy = m_pDib->GetBmpHeight();
		SetTitle( str );
	}
	pView->SetScrollSizes( MM_TEXT, GetDocSize() );
	pView->Invalidate();
}

void CTestDoc::DeleteContents() 
{
	if( m_pDib )
	{
		delete m_pDib;
		m_pDib = NULL;
	}
	CDocument::DeleteContents();
}

void CTestDoc::OnProcHistogram() 
{
	m_pDib->HistogramDialog();
}

void CTestDoc::OnUpdateProcHistogram(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	if( m_pDib == NULL )
	{
		pCmdUI->Enable( FALSE );
		return;
	}
	if( m_pDib->GetBmpNumColors() == 256 )
		pCmdUI->Enable();
	else
		pCmdUI->Enable( FALSE );	
}

void CTestDoc::OnProcHighpassfiltering() 
{
	m_pDib->HighpassFiltering();

	pView->SetScrollSizes( MM_TEXT, GetDocSize() );
	pView->Invalidate();

}

void CTestDoc::OnUpdateProcHighpassfiltering(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	if( m_pDib == NULL )
	{
		pCmdUI->Enable( FALSE );
		return;
	}
	if( m_pDib->GetBmpNumColors() == 256 )
		pCmdUI->Enable();
	else
		pCmdUI->Enable( FALSE );
	
}


void CTestDoc::OnProcMaskfiltering() 
{
	m_pDib->MaskFiltering();
	//UpdateAllViews( NULL );
	pView->SetScrollSizes( MM_TEXT, GetDocSize() );
	pView->Invalidate();
}



void CTestDoc::OnUpdateProcMaskfiltering(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	if( m_pDib == NULL )
	{
		pCmdUI->Enable( FALSE );
		return;
	}
	if( m_pDib->GetBmpNumColors() == 256 )
		pCmdUI->Enable();
	else
		pCmdUI->Enable( FALSE );	
}

⌨️ 快捷键说明

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