提交 | 用户 | age
|
4b03ae
|
1 |
|
Q |
2 |
// MFCApplication3Doc.cpp: CMFCApplication3Doc 类的实现
|
|
3 |
//
|
|
4 |
|
|
5 |
#include "pch.h"
|
|
6 |
#include "framework.h"
|
|
7 |
// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的
|
|
8 |
// ATL 项目中进行定义,并允许与该项目共享文档代码。
|
|
9 |
#ifndef SHARED_HANDLERS
|
|
10 |
#include "MFCApplication3.h"
|
|
11 |
#endif
|
|
12 |
|
|
13 |
#include "MFCApplication3Doc.h"
|
|
14 |
|
|
15 |
#include <propkey.h>
|
|
16 |
|
|
17 |
#ifdef _DEBUG
|
|
18 |
#define new DEBUG_NEW
|
|
19 |
#endif
|
|
20 |
|
|
21 |
// CMFCApplication3Doc
|
|
22 |
|
|
23 |
IMPLEMENT_DYNCREATE(CMFCApplication3Doc, CDocument)
|
|
24 |
|
|
25 |
BEGIN_MESSAGE_MAP(CMFCApplication3Doc, CDocument)
|
|
26 |
END_MESSAGE_MAP()
|
|
27 |
|
|
28 |
|
|
29 |
// CMFCApplication3Doc 构造/析构
|
|
30 |
|
|
31 |
CMFCApplication3Doc::CMFCApplication3Doc() noexcept
|
|
32 |
{
|
|
33 |
// TODO: 在此添加一次性构造代码
|
|
34 |
|
|
35 |
}
|
|
36 |
|
|
37 |
CMFCApplication3Doc::~CMFCApplication3Doc()
|
|
38 |
{
|
|
39 |
}
|
|
40 |
|
|
41 |
BOOL CMFCApplication3Doc::OnNewDocument()
|
|
42 |
{
|
|
43 |
if (!CDocument::OnNewDocument())
|
|
44 |
return FALSE;
|
|
45 |
|
|
46 |
// TODO: 在此添加重新初始化代码
|
|
47 |
// (SDI 文档将重用该文档)
|
|
48 |
|
|
49 |
return TRUE;
|
|
50 |
}
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
// CMFCApplication3Doc 序列化
|
|
56 |
|
|
57 |
void CMFCApplication3Doc::Serialize(CArchive& ar)
|
|
58 |
{
|
|
59 |
if (ar.IsStoring())
|
|
60 |
{
|
|
61 |
// TODO: 在此添加存储代码
|
|
62 |
}
|
|
63 |
else
|
|
64 |
{
|
|
65 |
// TODO: 在此添加加载代码
|
|
66 |
}
|
|
67 |
}
|
|
68 |
|
|
69 |
#ifdef SHARED_HANDLERS
|
|
70 |
|
|
71 |
// 缩略图的支持
|
|
72 |
void CMFCApplication3Doc::OnDrawThumbnail(CDC& dc, LPRECT lprcBounds)
|
|
73 |
{
|
|
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 |
// 搜索处理程序的支持
|
|
93 |
void CMFCApplication3Doc::InitializeSearchContent()
|
|
94 |
{
|
|
95 |
CString strSearchContent;
|
|
96 |
// 从文档数据设置搜索内容。
|
|
97 |
// 内容部分应由“;”分隔
|
|
98 |
|
|
99 |
// 例如: strSearchContent = _T("point;rectangle;circle;ole object;");
|
|
100 |
SetSearchContent(strSearchContent);
|
|
101 |
}
|
|
102 |
|
|
103 |
void CMFCApplication3Doc::SetSearchContent(const CString& value)
|
|
104 |
{
|
|
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 |
|
|
123 |
// CMFCApplication3Doc 诊断
|
|
124 |
|
|
125 |
#ifdef _DEBUG
|
|
126 |
void CMFCApplication3Doc::AssertValid() const
|
|
127 |
{
|
|
128 |
CDocument::AssertValid();
|
|
129 |
}
|
|
130 |
|
|
131 |
void CMFCApplication3Doc::Dump(CDumpContext& dc) const
|
|
132 |
{
|
|
133 |
CDocument::Dump(dc);
|
|
134 |
}
|
|
135 |
#endif //_DEBUG
|
|
136 |
|
|
137 |
|
|
138 |
// CMFCApplication3Doc 命令
|