Click Event

  • Thread starter Thread starter cyan21
  • Start date Start date
C

cyan21

hello,

I would like to capture the event fired when I create a apppointment
with Outlook.
I used the class wrapper and looked for the CommandBarButtonEvent.h ( I
program in C++)and I found 1 method "Click".
However how do I recognize which button I pressed ?
 
Any newly opened item will fire the NewInspector event of the Inspectors
collection. That's what you'd handle. NewInspector passes an Item argument
that can be used to see if it's a new appointment item:

Item.Class = olAppointment would do it.
 
thanks again for your answer.

I have another question : I'm trying to trap the cancel event.
where can I find its declaration ?

Moreover in the ItemEvents.h, there is this method :
void Close(BOOL * Cancel)

what does "Cancel" used for ?

It could help me because I want to detect if a user saves his
modifications when he closes a window( for example, when you modify an
appointment and you close the window a messagebox asks you if you want
to save the modifications you've made )

yann
 
The Click event has a CancelDefault property that is a Boolean. If you set
that to True it will cancel the default action of the button.

In Close and some other events (Send for example), you have a Cancel
argument passed into the Click event handler. If you set Cancel = True that
will cancel the action of the event.
 
where can I set Cancel = true in the code ?

because what I'm doing is :

1. advise events
2. handle them
3. unadvise events

I don't fire myself the close event so how can I set the argument
"Cancel" to true ( or false)?
 
You set it inside the event handler. You were asking about the Close event,
which has a Cancel boolean argument passed into it. If you set Cancel = True
in that event handler it will cancel the close of the item.
 
well the void Close(BOOL * Cancel) , is in a type library that was
generated by a class Wizard and it's not my handler.

my handler is more like this :

void __stdcall COutlookEvents::OnItemClose(IDispatch* Item)
{
....
}
 
I don't know what's in your handler but it's not complete or correct if it
doesn't have a Cancel argument.
 
I don't really understand how it works, so could you clarify it for me.

I wrote this to trap the close event :
// OutlookEvents.h

BEGIN_SINK_MAP(COutlookEvents)
SINK_ENTRY_INFO(2,__uuidof(Outlook::ItemEvents),/*dispinterface*/,0xf004,OnItemClose,&OnItemCloseInfo)

END_SINK_MAP()

// handler
void __stdcall OnItemClose(IDispatch* Item);

// OutlookEvents.cpp

_ATL_FUNC_INFO OnItemCloseInfo={CC_STDCALL,VT_EMPTY,1,{VT_DISPATCH}};

void __stdcall COutlookEvents::OnItemClose(IDispatch* Item)
{ ......}


So when I click on close button, it launches this method, right ?

// generated by the class wrapper
void Close(BOOL * Cancel)
{
static BYTE parms[] = VTS_PBOOL ;
InvokeHelper(0xf004, DISPATCH_METHOD, VT_EMPTY, NULL, parms, Cancel);
}

Then It's my handler that catch this event.
if I add a parameter cancel like this :
void __stdcall COutlookEvents::OnItemClose(IDispatch* Item, BOOL *
Cancel )
{ ......}

Can I get back the value of Cancel( fired by void Close(BOOL * Cancel)
) in my handler ?
and if it's possible, isn't too late to set the value of Cancel to
true(or false) ?
 
I don't do C++ or ATL programming so I can't analyze your code for you. See
if there are any examples of what you are trying to do in the MSDN library.
 
Back
Top