提交 | 用户 | age
|
4b03ae
|
1 |
|
0ed438
|
2 |
// MTerm1Doc.cpp: CMTerm1Doc 类的实现
|
4b03ae
|
3 |
//
|
Q |
4 |
|
|
5 |
#include "pch.h"
|
|
6 |
#include "framework.h"
|
|
7 |
// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的
|
|
8 |
// ATL 项目中进行定义,并允许与该项目共享文档代码。
|
|
9 |
#ifndef SHARED_HANDLERS
|
0ed438
|
10 |
#include "MTerm1.h"
|
4b03ae
|
11 |
#endif
|
Q |
12 |
|
0ed438
|
13 |
#include "MTerm1Doc.h"
|
4b03ae
|
14 |
|
Q |
15 |
#include <propkey.h>
|
|
16 |
|
|
17 |
#ifdef _DEBUG
|
|
18 |
#define new DEBUG_NEW
|
|
19 |
#endif
|
|
20 |
|
0ed438
|
21 |
// CMTerm1Doc
|
4b03ae
|
22 |
|
0ed438
|
23 |
IMPLEMENT_DYNCREATE(CMTerm1Doc, CDocument)
|
4b03ae
|
24 |
|
0ed438
|
25 |
BEGIN_MESSAGE_MAP(CMTerm1Doc, CDocument)
|
4b03ae
|
26 |
END_MESSAGE_MAP()
|
Q |
27 |
|
|
28 |
|
0ed438
|
29 |
// CMTerm1Doc 构造/析构
|
4b03ae
|
30 |
|
0ed438
|
31 |
CMTerm1Doc::CMTerm1Doc() noexcept
|
4b03ae
|
32 |
{
|
Q |
33 |
// TODO: 在此添加一次性构造代码
|
|
34 |
|
|
35 |
}
|
|
36 |
|
0ed438
|
37 |
CMTerm1Doc::~CMTerm1Doc()
|
4b03ae
|
38 |
{
|
Q |
39 |
}
|
|
40 |
|
0ed438
|
41 |
BOOL CMTerm1Doc::OnNewDocument()
|
4b03ae
|
42 |
{
|
Q |
43 |
if (!CDocument::OnNewDocument())
|
|
44 |
return FALSE;
|
|
45 |
|
|
46 |
// TODO: 在此添加重新初始化代码
|
|
47 |
// (SDI 文档将重用该文档)
|
0ed438
|
48 |
|
4b03ae
|
49 |
return TRUE;
|
Q |
50 |
}
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
0ed438
|
55 |
// CMTerm1Doc 序列化
|
4b03ae
|
56 |
|
0ed438
|
57 |
void CMTerm1Doc::Serialize(CArchive& ar)
|
4b03ae
|
58 |
{
|
Q |
59 |
if (ar.IsStoring())
|
|
60 |
{
|
|
61 |
// TODO: 在此添加存储代码
|
|
62 |
}
|
|
63 |
else
|
|
64 |
{
|
|
65 |
// TODO: 在此添加加载代码
|
|
66 |
}
|
|
67 |
}
|
|
68 |
|
|
69 |
#ifdef SHARED_HANDLERS
|
|
70 |
|
|
71 |
// 缩略图的支持
|
0ed438
|
72 |
void CMTerm1Doc::OnDrawThumbnail(CDC& dc, LPRECT lprcBounds)
|
4b03ae
|
73 |
{
|
Q |
74 |
// 修改此代码以绘制文档数据
|
|
75 |
dc.FillSolidRect(lprcBounds, RGB(255, 255, 255));
|
|
76 |
|
|
77 |
CString strText = _T("TODO: implement thumbnail drawing here");
|
|
78 |
LOGFONT lf;
|
|
79 |
|
|
80 |
CFont* pDefaultGUIFont = CFont::FromHandle((HFONT) GetStockObject(DEFAULT_GUI_FONT));
|
|
81 |
pDefaultGUIFont->GetLogFont(&lf);
|
|
82 |
lf.lfHeight = 36;
|
|
83 |
|
|
84 |
CFont fontDraw;
|
|
85 |
fontDraw.CreateFontIndirect(&lf);
|
|
86 |
|
|
87 |
CFont* pOldFont = dc.SelectObject(&fontDraw);
|
|
88 |
dc.DrawText(strText, lprcBounds, DT_CENTER | DT_WORDBREAK);
|
|
89 |
dc.SelectObject(pOldFont);
|
|
90 |
}
|
|
91 |
|
|
92 |
// 搜索处理程序的支持
|
0ed438
|
93 |
void CMTerm1Doc::InitializeSearchContent()
|
4b03ae
|
94 |
{
|
Q |
95 |
CString strSearchContent;
|
|
96 |
// 从文档数据设置搜索内容。
|
|
97 |
// 内容部分应由“;”分隔
|
|
98 |
|
|
99 |
// 例如: strSearchContent = _T("point;rectangle;circle;ole object;");
|
|
100 |
SetSearchContent(strSearchContent);
|
|
101 |
}
|
|
102 |
|
0ed438
|
103 |
void CMTerm1Doc::SetSearchContent(const CString& value)
|
4b03ae
|
104 |
{
|
Q |
105 |
if (value.IsEmpty())
|
|
106 |
{
|
|
107 |
RemoveChunk(PKEY_Search_Contents.fmtid, PKEY_Search_Contents.pid);
|
|
108 |
}
|
|
109 |
else
|
|
110 |
{
|
|
111 |
CMFCFilterChunkValueImpl *pChunk = nullptr;
|
|
112 |
ATLTRY(pChunk = new CMFCFilterChunkValueImpl);
|
|
113 |
if (pChunk != nullptr)
|
|
114 |
{
|
|
115 |
pChunk->SetTextValue(PKEY_Search_Contents, value, CHUNK_TEXT);
|
|
116 |
SetChunkValue(pChunk);
|
|
117 |
}
|
|
118 |
}
|
|
119 |
}
|
|
120 |
|
|
121 |
#endif // SHARED_HANDLERS
|
|
122 |
|
0ed438
|
123 |
// CMTerm1Doc 诊断
|
4b03ae
|
124 |
|
Q |
125 |
#ifdef _DEBUG
|
0ed438
|
126 |
void CMTerm1Doc::AssertValid() const
|
4b03ae
|
127 |
{
|
Q |
128 |
CDocument::AssertValid();
|
|
129 |
}
|
|
130 |
|
0ed438
|
131 |
void CMTerm1Doc::Dump(CDumpContext& dc) const
|
4b03ae
|
132 |
{
|
Q |
133 |
CDocument::Dump(dc);
|
|
134 |
}
|
|
135 |
#endif //_DEBUG
|
|
136 |
|
|
137 |
|
0ed438
|
138 |
// CMTerm1Doc 命令
|