Section-Row-Cell Filters i.e. SetEventFilterSRC

S

Scott Metzger

Hi,

Ok, what I want to do is have my 'mapped' event only fire when a
specific User Defined cell is changed in a Shape object. When I use the
following filter my function is still called for every Cell change.

void CVisioReadDlg::OnBnClickedCommandbar()
{// create an event map when the User.Listen cell changes
IUnknown FAR* pSink = NULL;
CVisioEventList vsoEList;
CVisioEvent vsoEvent;

if ( SUCCEEDED(vsoApp.EventList(vsoEList)) )
{
if (SUCCEEDED(CoCreateAddonSink(UserCellChanged, &pSink)) )
{
if ( SUCCEEDED(vsoEList.AddAdvise( (short)(visEvtShape |
visEvtCell | visEvtMod),VVariant(pSink),
VBstr(_T("")), VBstr(_T("")),
vsoEvent)))
{
vsoEvent.ID(&stclUserCellEventID);
VSafeArray filter(VT_I2, (ULONG)7, (LONG)0);
long index[7];
filter.PutElement(index, (void*)visSectionUser);
filter.PutElement(index, (void*)visRowUser);
filter.PutElement(index, (void*)visUserValue);
filter.PutElement(index, (void*)visSectionUser);
filter.PutElement(index, (void*)visRowUser);
filter.PutElement(index, (void*)visUserValue);
filter.PutElement(index, (void*)1);
vsoEvent.SetFilterSRC(filter);
}
} // end if created sink event
} // end if got list of events
}

I am unsure about a few things:
1) I am using the VSafeArray class because I couldn't figure out how to
use a SAFEARRAY, but am I using the VSafeArray class correctly? or
could someone post an example of setting up a SAFEARRAY filter?

2) Are my From Row and Cell and To Row and Cell constants correct? I
just want to 'trigger' off the 1st Value cell in a User-Defined section.

3) When I set the filter to True (1), that should indicate that I only
want to 'trigger' when this one specific condition occurs. Is that correct?

Thanks,
Scott Metzger
 
B

Bill K. [MSFT]

Scott,
Here is some sample code (taken out of context) that may help:


CHRESULT cHR; // throws an oleexception on failure code
VSafeArray1D vsa(VT_I2, 1 * 7, 0);
int n = 0;

// listen for cell formula changes in user section cells
cHR = vsa.PutShort(n++, visSectionUser);
cHR = vsa.PutShort(n++, visRowFirst);
cHR = vsa.PutShort(n++, visUserValue);
cHR = vsa.PutShort(n++, visSectionUser);
cHR = vsa.PutShort(n++, visRowLast);
cHR = vsa.PutShort(n++, visUserValue);
cHR = vsa.PutShort(n++, true);

pEvent->SetFilterSRC(vsa);


Hope this helps,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top