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

📄 htextdoc.cpp

📁 VisualC++多媒体开发指南》一书的光盘源代码
💻 CPP
字号:
// htextdoc.cpp : implementation of the CHtext2Doc class
//

#include "stdafx.h"
#include "htext2.h"

#include "htextdoc.h"

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CHtext2Doc

IMPLEMENT_DYNCREATE(CHtext2Doc, CDocument)

BEGIN_MESSAGE_MAP(CHtext2Doc, CDocument)
	//{{AFX_MSG_MAP(CHtext2Doc)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CHtext2Doc construction/destruction

CHtext2Doc::CHtext2Doc()
{
	// TODO: add one-time construction code here
	for (int i = 0 ; i < 12 ; i++)
		{
		m_data += "This is the sample ##hypertext data. ";
		m_data += "It is used to test the ##links. ";
		m_data += "Click on a ##topic that is displayed in red. ";
		m_data += "You'll see a message box pop up with the ";
		m_data += "name of the ##topic displayed.\n\n";
		}
	m_nextLink=0;
}

void CHtext2Doc::InitLinkArray()
{
//Initializes the link array by pointing at element 0.
	m_nextLink = 0;
}

void CHtext2Doc::CreateLink(CString name, CRect Rect)
{
//Creates an entry in the link array for the link whose text is in
//the argument name and whose coordinates are in the argument Rect.
	m_LinkRect[m_nextLink] = &Rect;
	m_LinkText[m_nextLink] = name;
	m_nextLink += 1;
}																				   

CString CHtext2Doc::IsLink(CPoint point)
{
//Detemines if the screen location specified by the argument point belongs
//to one of the links in the link array. If so, returns the array name. If
//not, returns an empty string.
	for (int i = 0 ; i < m_nextLink ; i++)
		{
		if (m_LinkRect[i].PtInRect(point))
			return (m_LinkText[i]);
		}
	return ("");
}

CHtext2Doc::~CHtext2Doc()
{
}

CString CHtext2Doc::GetTopic()
{
	return m_data;
}

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

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

	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CHtext2Doc serialization

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

/////////////////////////////////////////////////////////////////////////////
// CHtext2Doc diagnostics

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

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

/////////////////////////////////////////////////////////////////////////////
// CHtext2Doc commands

⌨️ 快捷键说明

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