Sinking events from previous and next buttons

M

Matt Fletcher

I'm trying to sink events from the previous and next buttons in the Outlook
mail item window. I can successfully sink events from the menu-item style
buttons in the popup menu (e.g. Item, Unread Item etc), but I cannot work
out how to sink events from the msoControlSplitButtonPopup itself. Is there
any way to sink the click event that is generated when you click on the
button (LH) half of these type of controls?

thanks
Matt Fletcher
 
K

Ken Slovak - [MVP - Outlook]

Previous and Next are ID's 359 and 360 in an open Inspector. If you
assign a CommandBarButton object to those Id's you can handle their
Click events. I don't know of a way to handle the click that occurs if
you use the Previous or Next menus and select an item from there.
 
M

Matt Fletcher

Forgive my ignorance, I'm fairly new to both OOM and COM connection points,
but how do I "assign a CommandBarButton object to those Id's"? Is this a VB
way of doing things - I'm working on a C++ addin.

Note that I have, since my initial posting, managed to trap clicks on the
actual Next and Previous controls (of type msoControlSplitButtonPopup) in
the command bar, but only by subclassing the command bar and hit testing.
This works but strikes me as somewhat crude. So the rest of this posting is
for my education.

The way the code I inherited works (and therefore the way I have learnt to
trap OOM events) is to obtain a pointer to the control (possibly using
FindControl) and then call DispEventAdvise on that pointer.

Therefore, my route into this particular problem was to loop through all the
controls on the Standard toolbar, logging their caption, type and ID. From
this I saw that the Next and Previous controls were of type
msoControlSplitButtonPopup (with the IDs you specified) - if I look at
either the help file or my type library headers, I can see no events
associated with this type of control, and no way to get at the buttons they
appear to contain.

When I loop through the controls owned by these msoControlSplitButtonPopups,
then I can see CommandBarButtons with IDs 359 and 360 (and 6 x 2 others) -
however, sinking events from these traps clicks on the first (&Item) items
in the popup menus (which I think is what you say you don't know how to do),
rather than the button on the command bar - sample code snippet:

CommandBarPopupPtr spPopup
= m_spCommandBar->FindControl((long)msoControlSplitButtonPopup, 360L);

if (spPopup)
{
m_spNextPopupItem1 = spPopup->Controls->Item[1L];
NextPopupItem1EventsImpl::DispEventAdvise(m_spNextPopupItem1);
}

Any help in diverting me from the evil ways of subclassing to the true path
of OOM appreciated!

Thanks
Matt Fletcher
 
K

Ken Slovak - [MVP - Outlook]

I don't do C++ coding for COM addins so I can't address some of your
issues. In VB to assign a button using an Id would be done as follows:
Set oButton = oCommandBarControls.Add(msoControlButton, id number, , ,
True)

The first argument is control type, second is the Id number if you are
adding a built-in button and third is the Temporary argument.

For what you want you most likely will have to live with subclassing.
 

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