A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Unable to receive events from Office::msoControlButton



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old September 22nd 09, 08:43 AM posted to microsoft.public.outlook.program_addins
KarthikonIT
external usenet poster
 
Posts: 2
Default Unable to receive events from Office::msoControlButton

I'm (trying to) program an addin in VC++ (VS 2005) for Outlook 2003


How do I catch the event when the user clicks a button within the menu? Is
there a way to DispEventAdvise for the Office::CommandBarControls or the
Office::CommandBarPopup which "owns" the menu items?


My addin has a toolbar, which has a menu (Office::msoControlPopup).
I am able to listen to events when the user clicks on a button in my toolbar,
but not when we clicks on a menu item(Office::msoControlPopup) in the toolbar
what should i do to listen to that event when user clicks on a menu in my
toolbar.


Here is my sample code:
I have created a CEventWrapper class which implements IDispEventSimpleImpl
Interface.

CEventWrapper.h

//Implemented a class from IDispEventSimpleImpl

class CEventWrapper ublic IDispEventSimpleImpl1,CEventWrapper ,&__uuidof(
Office::_CommandBarButtonEvents)
{

public:
CEventWrapper (void);
CEventWrapper ( Outlook::_ExplorerPtr spExplrPtr, Office::
_CommandBarButtonPtr spCmdBrBtnPtr);
CEventWrapper (void);


Office::_CommandBarButtonPtr m_spCmdBrBtnPtr;

}

typedef IDispEventSimpleImpl CEventWrapper.h&__uuidof(Office::
_CommandBarButtonEvents) CmdBarBtnEvnts;


//Implemented Sink map.
BEGIN_SINK_MAP CEventWrapper
SINK_ENTRY_INFO(1, __uuidof(Office::_CommandBarButtonEvents),0x1,
OnButtonClick , &OnButtonClickInfo)
END_SINK_MAP()

HRESULT __stdcall OnButtonClick(LPDISPATCH lpBtnDisp, VARIANT_BOOL
*vbCancelDefault)
{
//Event Handler

}




CEventWrapper.cpp

_ATL_FUNC_INFO OnButtonClickInfo ={CC_STDCALL,VT_EMPTY,2,{VT_DISPATCH,VT_BOOL}
};

CEventWrapper ( Outlook::_ExplorerPtr spExplrPtr, Office::
_CommandBarButtonPtr spCmdBrBtnPtr)
{
CmdBarBtnEvnts:ispEventAdvise((IDispatch*)m_spCm dBrBtnPtr); //Attaching
to the event source.
}


HRESULT __stdcall CButtonWrapper::OnButtonClick(LPDISPATCH lpBtnDisp,
VARIANT_BOOL *vbCancelDefault)
{
//B. Logic.
}


Adding "Office::msoControlPopup" to the toolbar.
{

//Added from a different class in "OnConnection"..

Office::CommandBarControlPtr spCmdBrCtrlPtr;
Office::CommandBarControlsPtr spCmdBrCtrlsPtr


spCmdBrCtrlPtr = spCmdBrCtrlsPtr-Add( vCtrlTyp, vMissng,vMissng,vMissng,
vIsTempry);


HRESULT hr = spCmdBrCtrlPtr-QueryInterface( __uuidof( Office::
CommandBarPopup),
(void**)&m_spCmdBrPopupPtr);

spCmdBrCtrlPtr = m_spCmdBrPopupPtr-Controls-Add(vCtrlTypBtn, vMissng,
vMissng, vMissng, vIsTempry);

CmdBarBtnEvnts:ispEventAdvise( (LPDISPATCH)m_spCmdBrBtnPtr );
}

Thanks in Advance.

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Capturing Send/Receive events in VSTO add-in Aakash Polra Outlook - General Queries 1 September 30th 08 05:49 PM
Unable to install Outlook 2007/unable to uninstall Office 97, 2000 Chezritz Outlook - Installation 3 November 4th 07 04:02 AM
Unable to dismiss recurring calendar events when using Outlook Con J Austin Outlook - Calandaring 0 December 24th 06 04:35 PM
I am unable to open existing or create new events within calendar joe f Outlook - Calandaring 0 July 25th 06 04:00 PM
unable to add events to my calendar. Lee Richardson Outlook - Calandaring 1 March 8th 06 07:09 PM


All times are GMT +1. The time now is 11:42 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.