📄 imagedwtdoc.cpp
字号:
// ImageDWTDoc.cpp : implementation of the CImageDWTDoc class
//
#include "stdafx.h"
#include "ImageDWT.h"
#include "ImageDWTDoc.h"
#include "ImageDWTView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CImageDWTDoc
IMPLEMENT_DYNCREATE(CImageDWTDoc, CDocument)
BEGIN_MESSAGE_MAP(CImageDWTDoc, CDocument)
//{{AFX_MSG_MAP(CImageDWTDoc)
ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CImageDWTDoc construction/destruction
CImageDWTDoc::CImageDWTDoc()
{
// TODO: add one-time construction code here
InitDocVariable();
}
CImageDWTDoc::~CImageDWTDoc()
{
FreeDocVariable();
}
BOOL CImageDWTDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CImageDWTDoc serialization
void CImageDWTDoc::Serialize(CArchive& ar)
{
m_pDibSrc->Serialize(ar);
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CImageDWTDoc diagnostics
#ifdef _DEBUG
void CImageDWTDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CImageDWTDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CImageDWTDoc commands
int CImageDWTDoc::InitDocVariable()
{
m_pDibSrc = new CDib;
return 0;
}
int CImageDWTDoc::FreeDocVariable()
{
delete m_pDibSrc;
m_pDibSrc = NULL;
return 0;
}
void CImageDWTDoc::OnFileSaveAs()
{
// TODO: Add your command handler code here
CString strSaveFileType = "位图文件 (*.bmp;*.dib)|*.bmp; *.dib|All Files (*.*)|*.*||";
CFileDialog FileDlg(FALSE, "*.bmp", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, strSaveFileType);
CFile fileOpen ;
if( FileDlg.DoModal() == IDOK )
{
if(!fileOpen.Open( FileDlg.GetPathName() , CFile::modeCreate|CFile::modeWrite ))
{
AfxMessageBox("cannot create the file to save");
return;
}
if( !m_pDibSrc->Write( &fileOpen ) )
{
return;
}
fileOpen.Close();
}
}
void CImageDWTDoc::ReplaceHDIB(HDIB hDIB)
{
// 替换DIB,在功能粘贴中用到该函数
// 判断DIB是否为空
if (m_pDibSrc->m_hDib != NULL)
{
// 非空,则清除
::GlobalFree((HGLOBAL) m_pDibSrc->m_hDib );
}
// 替换成新的DIB对象
m_pDibSrc->m_hDib = hDIB;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -