?? cdpcmdemodoc.cpp
字號:
// CDpcmDemoDoc.cpp : implementation of the CCDpcmDemoDoc class
//
#include "stdafx.h"
#include "CDpcmDemo.h"
#include "CDpcmDemoDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCDpcmDemoDoc
IMPLEMENT_DYNCREATE(CCDpcmDemoDoc, CDocument)
BEGIN_MESSAGE_MAP(CCDpcmDemoDoc, CDocument)
//{{AFX_MSG_MAP(CCDpcmDemoDoc)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCDpcmDemoDoc construction/destruction
CCDpcmDemoDoc::CCDpcmDemoDoc()
{
// TODO: add one-time construction code here
InitDocVariable();
}
CCDpcmDemoDoc::~CCDpcmDemoDoc()
{
FreeDocVariable();
}
BOOL CCDpcmDemoDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CCDpcmDemoDoc serialization
void CCDpcmDemoDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CCDpcmDemoDoc diagnostics
#ifdef _DEBUG
void CCDpcmDemoDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CCDpcmDemoDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCDpcmDemoDoc commands
int CCDpcmDemoDoc::InitDocVariable()
{
m_pDibInit = new CDib;
// added by tanhc in 2002-7-30, used to test some function
m_pDibTest = new CDib;
m_nColorIndex = 0;
//--------------------------------------------
return 0;
}
int CCDpcmDemoDoc::FreeDocVariable()
{
delete m_pDibInit;
m_pDibInit = NULL;
// added by tanhc in 2002-7-30, used to test some function
delete m_pDibTest ;
m_pDibTest = NULL ;
//--------------------------------------------
return 0;
}
void CCDpcmDemoDoc::OnFileOpen()
{
CString strOpenFileType = "位圖文件 (*.bmp;*.dib)|*.bmp; *.dib|All Files (*.*)|*.*||";
CFileDialog FileDlg(TRUE, "*.bmp", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, strOpenFileType);
if (FileDlg.DoModal() == IDOK)
{
// 判斷當前圖像是否已經被改動
if (IsModified())
{
// 提示用戶該操作將丟失所有當前的修改
if (MessageBox(NULL, "重新打開圖像將丟失所有改動!是否繼續?", "系統提示", MB_ICONQUESTION | MB_YESNO) == IDNO)
{
// 用戶取消操作,直接返回
return;
}
}
CFile file;
CString strPathName;
CFileException fe;
strPathName = FileDlg.GetPathName();
// 重新打開文件
if( !file.Open(strPathName, CFile::modeRead | CFile::shareDenyWrite, &fe))
{
// 失敗
ReportSaveLoadException(strPathName, &fe, FALSE, AFX_IDP_FAILED_TO_OPEN_DOC);
// 返回
return;
}
// 更改光標
BeginWaitCursor();
// 重新讀取圖象
if(!m_pDibInit->Read(&file)){
// 恢復光標形狀
EndWaitCursor();
// 返回
return;
}
// 初始化脹標記為FALSE
// 刷新
UpdateAllViews(NULL);
// 恢復光標形狀
EndWaitCursor();
// 返回
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -