V
Victor Feintuch
The Microsoft Dso Framer control is a container that can house Office
documents. The control is really great. However I needed to trap the
events that it fired in C#. They worked fine in VB6, not in C# or
VB.NET.
The issue was the way the events were fired. The fix required only
minor changes to the code.
How do I get Microsoft to integrate these changes into the next version
of the framer control?
Thanks,
Victor Feintuch
DST International
HiRisk Risk Management Division
There are changes to 3 .cpp files
The main change is to utilities.cpp
The code to DsoDispatchInvoke was changed and all calls to it it were
changed:
Change to utilities.cpp
////////////////////////////////////////////////////////////////////////
// DsoDispatchInvoke
//
// Wrapper for IDispatch::Invoke calls to event sinks, or late bound
call
// to embedded object to get ambient property.
//
STDAPI DsoDispatchInvoke(LPDISPATCH pdisp, LPOLESTR pwszname, DISPID
dspid, WORD wflags, DWORD cargs, VARIANT* rgargs, VARIANT* pvtret)
{
HRESULT hr = S_FALSE;
DISPID dspidPut = DISPID_PROPERTYPUT;
DISPPARAMS dspparm = {NULL, NULL, 0, 0};
CHECK_NULL_RETURN(pdisp, E_POINTER);
dspparm.rgvarg = rgargs;
dspparm.cArgs = cargs;
if ((wflags & DISPATCH_PROPERTYPUT) || (wflags &
DISPATCH_PROPERTYPUTREF))
{
dspparm.rgdispidNamedArgs = &dspidPut;
dspparm.cNamedArgs = 1;
}
SEH_TRY
hr = pdisp->Invoke(dspid, IID_NULL, LOCALE_USER_DEFAULT,
(WORD)(DISPATCH_METHOD | wflags), &dspparm, pvtret, NULL, NULL);
if (!SUCCEEDED(hr)) {
if (pwszname)
hr = pdisp->GetIDsOfNames(IID_NULL, &pwszname, 1,
LOCALE_USER_DEFAULT, &dspid);
if (SUCCEEDED(hr))
hr = pdisp->Invoke(dspid, IID_NULL, LOCALE_USER_DEFAULT,
(WORD)(DISPATCH_METHOD | wflags), &dspparm, pvtret, NULL, NULL);
}
SEH_EXCEPT(hr)
return hr;
}
Changes to dsofauto.cpp
DsoDispatchInvoke(m_dispEvents, L"OnDocumentOpened",
DSOF_DISPID_DOCOPEN, 0, 2, rgargs, NULL);
DsoDispatchInvoke(m_dispEvents, L"BeforeDocumentSaved",
DSOF_DISPID_DOCOPEN, 0, 2, rgargs, NULL);
DsoDispatchInvoke(m_dispEvents, L"OnDocumentOpened",
DSOF_DISPID_BDOCSAVE, 0, 3, rgargs, NULL);
DsoDispatchInvoke(m_dispEvents, L"BeforeDocumentClosed",
DSOF_DISPID_BDOCCLOSE, 0, 2, rgargs, NULL);
DsoDispatchInvoke(m_dispEvents, L"OnDocumentClosed",
DSOF_DISPID_DOCCLOSE, 0, 0, NULL, NULL);
Changes to dsofcontrol.cpp
DsoDispatchInvoke(m_dispEvents, L"OnPrintPreviewExit",
DSOF_DISPID_ENDPREVIEW, 0, 0, NULL, NULL);
hr = DsoDispatchInvoke(m_dispEvents, L"OnFileCommand",
DSOF_DISPID_FILECMD, 0, 2, rgargs, NULL);
DsoDispatchInvoke(m_dispEvents, L"OnActivationChange",
DSOF_DISPID_ACTIVATE, 0, 1, rgargs, NULL);
documents. The control is really great. However I needed to trap the
events that it fired in C#. They worked fine in VB6, not in C# or
VB.NET.
The issue was the way the events were fired. The fix required only
minor changes to the code.
How do I get Microsoft to integrate these changes into the next version
of the framer control?
Thanks,
Victor Feintuch
DST International
HiRisk Risk Management Division
There are changes to 3 .cpp files
The main change is to utilities.cpp
The code to DsoDispatchInvoke was changed and all calls to it it were
changed:
Change to utilities.cpp
////////////////////////////////////////////////////////////////////////
// DsoDispatchInvoke
//
// Wrapper for IDispatch::Invoke calls to event sinks, or late bound
call
// to embedded object to get ambient property.
//
STDAPI DsoDispatchInvoke(LPDISPATCH pdisp, LPOLESTR pwszname, DISPID
dspid, WORD wflags, DWORD cargs, VARIANT* rgargs, VARIANT* pvtret)
{
HRESULT hr = S_FALSE;
DISPID dspidPut = DISPID_PROPERTYPUT;
DISPPARAMS dspparm = {NULL, NULL, 0, 0};
CHECK_NULL_RETURN(pdisp, E_POINTER);
dspparm.rgvarg = rgargs;
dspparm.cArgs = cargs;
if ((wflags & DISPATCH_PROPERTYPUT) || (wflags &
DISPATCH_PROPERTYPUTREF))
{
dspparm.rgdispidNamedArgs = &dspidPut;
dspparm.cNamedArgs = 1;
}
SEH_TRY
hr = pdisp->Invoke(dspid, IID_NULL, LOCALE_USER_DEFAULT,
(WORD)(DISPATCH_METHOD | wflags), &dspparm, pvtret, NULL, NULL);
if (!SUCCEEDED(hr)) {
if (pwszname)
hr = pdisp->GetIDsOfNames(IID_NULL, &pwszname, 1,
LOCALE_USER_DEFAULT, &dspid);
if (SUCCEEDED(hr))
hr = pdisp->Invoke(dspid, IID_NULL, LOCALE_USER_DEFAULT,
(WORD)(DISPATCH_METHOD | wflags), &dspparm, pvtret, NULL, NULL);
}
SEH_EXCEPT(hr)
return hr;
}
Changes to dsofauto.cpp
DsoDispatchInvoke(m_dispEvents, L"OnDocumentOpened",
DSOF_DISPID_DOCOPEN, 0, 2, rgargs, NULL);
DsoDispatchInvoke(m_dispEvents, L"BeforeDocumentSaved",
DSOF_DISPID_DOCOPEN, 0, 2, rgargs, NULL);
DsoDispatchInvoke(m_dispEvents, L"OnDocumentOpened",
DSOF_DISPID_BDOCSAVE, 0, 3, rgargs, NULL);
DsoDispatchInvoke(m_dispEvents, L"BeforeDocumentClosed",
DSOF_DISPID_BDOCCLOSE, 0, 2, rgargs, NULL);
DsoDispatchInvoke(m_dispEvents, L"OnDocumentClosed",
DSOF_DISPID_DOCCLOSE, 0, 0, NULL, NULL);
Changes to dsofcontrol.cpp
DsoDispatchInvoke(m_dispEvents, L"OnPrintPreviewExit",
DSOF_DISPID_ENDPREVIEW, 0, 0, NULL, NULL);
hr = DsoDispatchInvoke(m_dispEvents, L"OnFileCommand",
DSOF_DISPID_FILECMD, 0, 2, rgargs, NULL);
DsoDispatchInvoke(m_dispEvents, L"OnActivationChange",
DSOF_DISPID_ACTIVATE, 0, 1, rgargs, NULL);