T
tsract
I'm using ATL and c++ to develop an Add-in for Microsoft Word. The problem
that I'm having is that the parameters for the events that I'm trying to
capture aren't being filled with data. They're essentially null. The
problem is only happening with events that pass back more than one parameter.
The events that I am trapping are DocumentOpen, NewDocument,
DocumentBeforePrint, and DocumentBeforeSave
DocumentOpen, and NewDocument event trapping work fine.
The dispinterface is ApplicationEvents2; I've also tried using
ApplicationEvents3, and ApplicationEvents4 with the same results.
/***********************************************
* IDL for DocumentOpen, NewDocument and DocumentBeforePrint
* and DocumentBeforeSave
************************************************/
[id(0x00000004), helpcontext(0x00061a84)]
void DocumentOpen([in] Document* Doc);
[id(0x00000009), helpcontext(0x00061a88)]
void NewDocument([in] Document* Doc);
[id(0x00000007), helpcontext(0x00061a86)]
void DocumentBeforePrint(
[in] Document* Doc,
[in] VARIANT_BOOL* Cancel);
[id(0x00000008), helpcontext(0x00061a87)]
void DocumentBeforeSave(
[in] Document* Doc,
[in] VARIANT_BOOL* SaveAsUI,
[in] VARIANT_BOOL* Cancel);
/**********************************************
* Here is the SINK_MAP
***********************************************/
BEGIN_SINK_MAP(MyAddin)
SINK_ENTRY_INFO(1,__uuidof
(Word::ApplicationEvents2),4,DocumentOpen,&DocumentOpenInfo
SINK_ENTRY_INFO(1,__uuidof(Word::ApplicationEvents2),9,NewDocument,&NewDocumentInfo
SINK_ENTRY_INFO(1,__uuidof(Word::ApplicationEvents2),7,DocumentBeforePrint,&DocumentBeforePrintInfo
SINK_ENTRY_INFO(1,__uuidof(Word::ApplicationEvents2),8,DocumentBeforeSave,&DocumentBeforeSaveInfo)
END_SINK_MAP()
/******************************************************
* Here are the ATL_FUNC_INFO structures I've declared
*******************************************************/
_ATL_FUNC_INFO NewDocumentInfo = {CC_STDCALL,VT_EMPTY,1,
{VT_DISPATCH|VT_BYREF}};
_ATL_FUNC_INFO DocumentBeforePrintInfo = {CC_STDCALL,VT_EMPTY,2,
{VT_DISPATCH|VT_BYREF, VT_BOOL|VT_BYREF}};
_ATL_FUNC_INFO DocumentOpenInfo = {CC_STDCALL,VT_EMPTY,1,
VT_DISPATCH|VT_BYREF}};
_ATL_FUNC_INFO DocumentBeforeSaveInfo = {CC_STDCALL,VT_EMPTY,3,
{VT_DISPATCH|VT_BYREF, VT_BOOL|VT_BYREF, VT_BOOL|VT_BYREF}};
void __stdcall MyAddin:ocumentOpen(IDispatchPtr ptr)
{
//Process DocumentOpen Event
}
void __stdcall MyAddin::NewDocument(IDispatchPtr ptr)
{
//Process NewDocument Event
}
void __stdcall MyAddin:ocumentBeforePrint(IDispatchPtr ptr, VARIANT_BOOL*
pvtCancel )
{
//The __vfPtr in ptr comes back as 0x00000000. I don't know why
}
void __stdcall MyAddin:ocumentBeforeSave(IDispatchPtr ptr, VARIANT_BOOL*
pSaveAsUI, VARIANT_BOOL* pCancel )
{
//The __vfPtr in ptr comes back as 0x00000000. I don't know why
}
Was this post helpful
that I'm having is that the parameters for the events that I'm trying to
capture aren't being filled with data. They're essentially null. The
problem is only happening with events that pass back more than one parameter.
The events that I am trapping are DocumentOpen, NewDocument,
DocumentBeforePrint, and DocumentBeforeSave
DocumentOpen, and NewDocument event trapping work fine.
The dispinterface is ApplicationEvents2; I've also tried using
ApplicationEvents3, and ApplicationEvents4 with the same results.
/***********************************************
* IDL for DocumentOpen, NewDocument and DocumentBeforePrint
* and DocumentBeforeSave
************************************************/
[id(0x00000004), helpcontext(0x00061a84)]
void DocumentOpen([in] Document* Doc);
[id(0x00000009), helpcontext(0x00061a88)]
void NewDocument([in] Document* Doc);
[id(0x00000007), helpcontext(0x00061a86)]
void DocumentBeforePrint(
[in] Document* Doc,
[in] VARIANT_BOOL* Cancel);
[id(0x00000008), helpcontext(0x00061a87)]
void DocumentBeforeSave(
[in] Document* Doc,
[in] VARIANT_BOOL* SaveAsUI,
[in] VARIANT_BOOL* Cancel);
/**********************************************
* Here is the SINK_MAP
***********************************************/
BEGIN_SINK_MAP(MyAddin)
SINK_ENTRY_INFO(1,__uuidof
(Word::ApplicationEvents2),4,DocumentOpen,&DocumentOpenInfo
SINK_ENTRY_INFO(1,__uuidof(Word::ApplicationEvents2),9,NewDocument,&NewDocumentInfo
SINK_ENTRY_INFO(1,__uuidof(Word::ApplicationEvents2),7,DocumentBeforePrint,&DocumentBeforePrintInfo
SINK_ENTRY_INFO(1,__uuidof(Word::ApplicationEvents2),8,DocumentBeforeSave,&DocumentBeforeSaveInfo)
END_SINK_MAP()
/******************************************************
* Here are the ATL_FUNC_INFO structures I've declared
*******************************************************/
_ATL_FUNC_INFO NewDocumentInfo = {CC_STDCALL,VT_EMPTY,1,
{VT_DISPATCH|VT_BYREF}};
_ATL_FUNC_INFO DocumentBeforePrintInfo = {CC_STDCALL,VT_EMPTY,2,
{VT_DISPATCH|VT_BYREF, VT_BOOL|VT_BYREF}};
_ATL_FUNC_INFO DocumentOpenInfo = {CC_STDCALL,VT_EMPTY,1,
VT_DISPATCH|VT_BYREF}};
_ATL_FUNC_INFO DocumentBeforeSaveInfo = {CC_STDCALL,VT_EMPTY,3,
{VT_DISPATCH|VT_BYREF, VT_BOOL|VT_BYREF, VT_BOOL|VT_BYREF}};
void __stdcall MyAddin:ocumentOpen(IDispatchPtr ptr)
{
//Process DocumentOpen Event
}
void __stdcall MyAddin::NewDocument(IDispatchPtr ptr)
{
//Process NewDocument Event
}
void __stdcall MyAddin:ocumentBeforePrint(IDispatchPtr ptr, VARIANT_BOOL*
pvtCancel )
{
//The __vfPtr in ptr comes back as 0x00000000. I don't know why
}
void __stdcall MyAddin:ocumentBeforeSave(IDispatchPtr ptr, VARIANT_BOOL*
pSaveAsUI, VARIANT_BOOL* pCancel )
{
//The __vfPtr in ptr comes back as 0x00000000. I don't know why
}
Was this post helpful