【VC开源代码栏目提醒】:网学会员鉴于大家对VC开源代码十分关注,论文会员在此为大家搜集整理了“MyCapDoc.cpp”一文,供大家参考学习
// MyCapDoc.cpp : implementation of the CMyCapDoc class
//
#include "stdafx.h"
#include "MyCap.h"
#include "MyCapDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CMyCapDoc
IMPLEMENT_DYNCREATE(CMyCapDoc, CDocument)
BEGIN_MESSAGE_MAP(CMyCapDoc, CDocument)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
ON_COMMAND(ID_FILE_SAVE, OnFileSave)
END_MESSAGE_MAP()
// CMyCapDoc construction/destruction
CMyCapDoc::CMyCapDoc()
{
// TODO: add one-time construction code here
}
CMyCapDoc::~CMyCapDoc()
{
}
BOOL CMyCapDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
// CMyCapDoc serialization
void CMyCapDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
// CMyCapDoc diagnostics
#ifdef _DEBUG
void CMyCapDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CMyCapDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
// CMyCapDoc commands
void CMyCapDoc::OnFileOpen()
{
// TODO: Add your command handler code here
CString filename;
static char szFilter[]="BMP文件(*.bmp)|*.bmp||";
CFileDialog dlg(TRUE,"bmp",NULL,
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,szFilter);
if(dlg.DoModal()==IDOK)
{
filename=dlg.GetPathName();
if(!(m_dib.LoadBmp(filename)))
return;
UpdateAllViews(NULL);
}
}
void CMyCapDoc::OnFileSave()
{
// TODO: Add your command handler code here
CString filename;
static char szFilter[]="BMP文件(*.bmp)|*.bmp||";
CFileDialog dlg(false,"bmp",NULL,
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,szFilter);
if(dlg.DoModal()==IDOK)
{
filename=dlg.GetPathName();
if(!(m_dib.SaveBmp(filename)))
return;
UpdateAllViews(NULL);
}
}