J
Jonathan Spane
Hello all,
I am trying to use the visio event system to listen for formula changes on a
per cell basis in the Custom Properties section of a shape. I cannot seem to
get a callback to work. I can get a callback to work at the shape level for
a cell being changed. The following is the code I am using to register a
callback with a shape which works and the code to register a callback for a
cell which doesn't seem to work. I have checked for a valid event so
AddAdvise is successful. Any ideas what I am doing wrong. I can clearly see
the event of formula changed in the generic Event Listener.
///=============================================================================
///
/// FUNCTION: RegisterCallbackForShape
///
/// This assigns the callback to listen for the cell changed
event
/// for the shape that is passed in.
///
///=============================================================================
bool
VisioEventManager::RegisterCallbackForShape(CVisioShape &visioShape,
LPVISEVENTPROC pCallback)
{
if(!visioShape.IsSet()) return false;
if(pCallback == NULL) return false;
//Ths sink object that gets created by Visio
IUnknown FAR *pSink = NULL;
//The list events from the shape that will be added to
CVisioEventList eList;
//Event that will be created.
CVisioEvent visioEvent;
if(SUCCEEDED(visioShape.EventList(eList)))
{
if(SUCCEEDED(CoCreateAddonSink(pCallback, &pSink)))
{
VBstr vbBlankStr(_T(""));
if(SUCCEEDED(eList.AddAdvise((short)(visEvtCell|visEvtMod),
VVariant(pSink),
vbBlankStr,
vbBlankStr,
visioEvent)))
{
}
//If AddAdvise succeeded, Visio now holds a reference to the
sink
//object via the event object, and pSink can be released.
pSink->Release();
pSink = NULL;
return true;
}
}
return false;
}
///=============================================================================
///
/// FUNCTION: RegisterCallbackForCell
///
/// This assigns the callback to listen for the cell changed
event
/// for the cell that is passed in.
///
///=============================================================================
bool
VisioEventManager::RegisterCallbackForCell(CVisioCell &visioCell,
LPVISEVENTPROC pCallback)
{
if(!visioCell.IsSet()) return false;
if(pCallback == NULL) return false;
//Ths sink object that gets created by Visio
IUnknown FAR *pSink = NULL;
//The list events from the shape that will be added to
CVisioEventList eList;
//Event that will be created.
CVisioEvent visioEvent;
if(SUCCEEDED(visioCell.EventList(eList)))
{
if(SUCCEEDED(CoCreateAddonSink(pCallback, &pSink)))
{
VBstr vbBlankStr(_T(""));
if(SUCCEEDED(eList.AddAdvise((short)(visEvtFormula|visEvtMod),
VVariant(pSink),
vbBlankStr,
vbBlankStr,
visioEvent)))
{
}
//If AddAdvise succeeded, Visio now holds a reference to the
sink
//object via the event object, and pSink can be released.
pSink->Release();
pSink = NULL;
return true;
}
}
return false;
}
Thanks for any help.
JP
P.S. I have substitude the or symbol | with a + sign... no help.
I am trying to use the visio event system to listen for formula changes on a
per cell basis in the Custom Properties section of a shape. I cannot seem to
get a callback to work. I can get a callback to work at the shape level for
a cell being changed. The following is the code I am using to register a
callback with a shape which works and the code to register a callback for a
cell which doesn't seem to work. I have checked for a valid event so
AddAdvise is successful. Any ideas what I am doing wrong. I can clearly see
the event of formula changed in the generic Event Listener.
///=============================================================================
///
/// FUNCTION: RegisterCallbackForShape
///
/// This assigns the callback to listen for the cell changed
event
/// for the shape that is passed in.
///
///=============================================================================
bool
VisioEventManager::RegisterCallbackForShape(CVisioShape &visioShape,
LPVISEVENTPROC pCallback)
{
if(!visioShape.IsSet()) return false;
if(pCallback == NULL) return false;
//Ths sink object that gets created by Visio
IUnknown FAR *pSink = NULL;
//The list events from the shape that will be added to
CVisioEventList eList;
//Event that will be created.
CVisioEvent visioEvent;
if(SUCCEEDED(visioShape.EventList(eList)))
{
if(SUCCEEDED(CoCreateAddonSink(pCallback, &pSink)))
{
VBstr vbBlankStr(_T(""));
if(SUCCEEDED(eList.AddAdvise((short)(visEvtCell|visEvtMod),
VVariant(pSink),
vbBlankStr,
vbBlankStr,
visioEvent)))
{
}
//If AddAdvise succeeded, Visio now holds a reference to the
sink
//object via the event object, and pSink can be released.
pSink->Release();
pSink = NULL;
return true;
}
}
return false;
}
///=============================================================================
///
/// FUNCTION: RegisterCallbackForCell
///
/// This assigns the callback to listen for the cell changed
event
/// for the cell that is passed in.
///
///=============================================================================
bool
VisioEventManager::RegisterCallbackForCell(CVisioCell &visioCell,
LPVISEVENTPROC pCallback)
{
if(!visioCell.IsSet()) return false;
if(pCallback == NULL) return false;
//Ths sink object that gets created by Visio
IUnknown FAR *pSink = NULL;
//The list events from the shape that will be added to
CVisioEventList eList;
//Event that will be created.
CVisioEvent visioEvent;
if(SUCCEEDED(visioCell.EventList(eList)))
{
if(SUCCEEDED(CoCreateAddonSink(pCallback, &pSink)))
{
VBstr vbBlankStr(_T(""));
if(SUCCEEDED(eList.AddAdvise((short)(visEvtFormula|visEvtMod),
VVariant(pSink),
vbBlankStr,
vbBlankStr,
visioEvent)))
{
}
//If AddAdvise succeeded, Visio now holds a reference to the
sink
//object via the event object, and pSink can be released.
pSink->Release();
pSink = NULL;
return true;
}
}
return false;
}
Thanks for any help.
JP
P.S. I have substitude the or symbol | with a + sign... no help.