// $impl_file$: 实现文件 // #include "pch.h" [!if PROJECT_NAME_HEADER] #include "$projectname$.h" [!endif] #include "$header_file$" // $class_name$ [!if CREATABLE] IMPLEMENT_DYNCREATE($class_name$, $base_class$) [!else] IMPLEMENT_DYNAMIC($class_name$, $base_class$) [!endif] $class_name$::$class_name$(COleServerDoc* pServerDoc, BOOL bAutoDelete) : COleServerItem( pServerDoc, bAutoDelete) { [!if AUTOMATION || CREATABLE] EnableAutomation(); [!endif] [!if CREATABLE] // 为了使应用程序在 OLE 自动化对象处于活动状态时保持 // 运行,构造函数调用 AfxOleLockApp。 AfxOleLockApp(); [!endif] } $class_name$::~$class_name$() { [!if CREATABLE] // 为了在用 OLE 自动化创建所有对象后终止应用程序, // 析构函数调用 AfxOleUnlockApp。 AfxOleUnlockApp(); [!endif] } [!if AUTOMATION || CREATABLE] void $class_name$::OnFinalRelease() { // 释放了对自动化对象的最后一个引用后,将调用 // OnFinalRelease。 基类将自动 // 删除该对象。 在调用该基类之前,请添加您的 // 对象所需的附加清理代码。 $base_class$::OnFinalRelease(); } [!endif] BOOL $class_name$::OnDraw(CDC* pDC, CSize& rSize) { // 由框架调用,以将 OLE 项呈现到 metafile 中。 // OLE 项的 metafile 表示形式用于显示 // 容器应用程序中的项。如果容器应用程序用 // Microsoft 基础类库编写,则 metafile 由相应 // COleClientItem 对象的 Draw 成员函数使用。 // 不存在任何默认的实现。必须重写此函数 // 以将项绘制到指定的设备上下文中。 ASSERT(FALSE); // 完成 TODO 后将此移除 return TRUE; } BEGIN_MESSAGE_MAP($class_name$, $base_class$) END_MESSAGE_MAP() [!if AUTOMATION || CREATABLE] BEGIN_DISPATCH_MAP($class_name$, $base_class$) END_DISPATCH_MAP() // 注意: 我们添加了对 IID_I$class_name_root$ 的支持来支持类型安全绑定 // 以支持来自 VBA 的类型安全绑定。 此 IID 必须同附加到 .IDL 文件中的 // 调度接口的 GUID 匹配。 // {$guid_dispiid$} static const IID IID_I$class_name_root$ = $guid_dispiid_staticconst$; BEGIN_INTERFACE_MAP($class_name$, $base_class$) INTERFACE_PART($class_name$, IID_I$class_name_root$, Dispatch) END_INTERFACE_MAP() [!endif] [!if CREATABLE] // {$guid_clsid$} IMPLEMENT_OLECREATE($class_name$, "$typeid$", $guid_clsid_olecreate$) [!endif] // $class_name$ 诊断 #ifdef _DEBUG void $class_name$::AssertValid() const { $base_class$::AssertValid(); } #ifndef _WIN32_WCE void $class_name$::Dump(CDumpContext& dc) const { $base_class$::Dump(dc); } #endif #endif //_DEBUG // $class_name$ 序列化 #ifndef _WIN32_WCE void $class_name$::Serialize(CArchive& ar) { if (ar.IsStoring()) { // TODO: 在此添加存储代码 } else { // TODO: 在此添加加载代码 } } #endif // $class_name$ 命令