使用VC++ ATL实现Office的COM插件

合集下载
相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

>> >> >>

6 [ 2353 ]

VC++ ATL Office COM

VC++ ATL(Active Template Library) IDTExtensibility2 Microsoft Word COM addin Office

Office VBA(Visual Basic for Application), ATL ATL Office

1 visual C++ WordAddin ATL COM Appwizard

server type Dynamic Link Library(DLL) Allow merging of proxy-stub code Finish ATL project

2 ATL object

Insert—>Insert new ATL object, new ATL object category object, simple object,

names “Short Name:” Addin

Attribute Support IsupportErrorInfo OK

WordAddin ATL COM object build

2 IDTExtensibility2 CAddin

IDTExtensibility2 MSADDin Designer typelibrary MSADDNDR.dll/MSADDNDR.tlb C:\Program Files/Common Files/Designer IDTExtensibility2 5 OnConnection OnDisconnection OnAddInsUpdate OnStartupComplete OnBeginShutdown IDTExtensibility2 classview Caddin Implement Interface Implement Interface Add Tylpelib

OK Browse Typelibraries Microsoft Add-in Designer(1.0)

OK, AddinDesignerObjects IDTExtensibility2

OK ATL COM object IDTExtensibility2 5 COM_INTERFACE_MAP()

4

FileView—>Resource File Addin.rgs

5 build

6 Executable File word 2000, word

7

Office Office Command Bar CommandBars CommandBars Add() CommandBar CommandBar CommandBarControls CommandBar Controls

word

office Word stdafx.h

office

Word Application GetCommandBars CommandBars CommandBars Word Add CommandBar GetControls CommandBarControls CommandBarControls CommandBarControls Add

CommandBars get_ActiveMenuBar CommandBar CommandBar GetControls Word “ ” 5 CommandBarControls GetItem(5) “ ” CommandBarControls Add

Word Word

8

ATL COM Idispatch IDispEventImpl<> IDispEventSimpleImpl <> IDispEventSimpleImpl<> IDispEventSimpleImpl<>

_ATL_SINK_INFO CAddin.h

extern _ATL_FUNC_INFO OnClickButtonInfo;

CAddin.cpp

CAddin OnConnection() OnDisconnection() DispEventAdvise() DispEventUnadvise()

COM "Clicked Button1"

VBA put_OnAction()

ATL ATL ATL Internals

相关文档
最新文档