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

📄 test2doc.cpp

📁 根据《VC++6.0 用户界面制作技术与应用实例》写的一些代码
💻 CPP
字号:
// test2Doc.cpp : implementation of the CTest2Doc class
//

#include "stdafx.h"
#include "test2.h"

#include "test2Doc.h"

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

/////////////////////////////////////////////////////////////////////////////
// CTest2Doc

IMPLEMENT_DYNCREATE(CTest2Doc, CDocument)

BEGIN_MESSAGE_MAP(CTest2Doc, CDocument)
	//{{AFX_MSG_MAP(CTest2Doc)
	ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
	ON_COMMAND(ID_FILE_SAVE_AS, OnFileSaveAs)
	ON_COMMAND(IDR_COLORDLG, OnColordlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTest2Doc construction/destruction

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

}

CTest2Doc::~CTest2Doc()
{
}

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

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

	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CTest2Doc serialization

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

/////////////////////////////////////////////////////////////////////////////
// CTest2Doc diagnostics

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

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

/////////////////////////////////////////////////////////////////////////////
// CTest2Doc commands

void CTest2Doc::OnFileOpen() 
{
	// TODO: Add your command handler code here
	CFileDialog dlg(TRUE) ;
	if(IDOK==dlg.DoModal())
	{
		CString strPathName = dlg.GetPathName();
		CString strFileName = dlg.GetFileName();

		char tubf[140] ;
		sprintf(tubf , "The %s file in the %s is opened!",strFileName,strPathName);
		AfxMessageBox(tubf);

	}
}

void CTest2Doc::OnFileSaveAs() 
{
	// TODO: Add your command handler code here
	CFileDialog dlg(false) ;
	if(IDOK==dlg.DoModal())
	{
		CString strPathName = dlg.GetPathName();
		CString strFileName = dlg.GetFileName();

		char tubf[140] ;
		sprintf(tubf , "The %s file in the %s is saved!",strFileName,strPathName);
		AfxMessageBox(tubf);

	}
}

void CTest2Doc::OnColordlg() 
{
	// TODO: Add your command handler code here
	CColorDialog dlg ;
	if(IDOK==dlg.DoModal())
	{
		COLORREF col = dlg.GetColor();
		char tubf[140] ;
		sprintf(tubf , "The(%d,%d,%d)color is selected!",GetRValue(col),GetGValue(col),GetBValue(col));
		AfxMessageBox(tubf);

	}
}

⌨️ 快捷键说明

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