Unable to receive events from Office::msoControlButton

Status
Not open for further replies.
K

KarthikonIT

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 :public IDispEventSimpleImpl<1,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::DispEventAdvise((IDispatch*)m_spCmdBrBtnPtr); //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::DispEventAdvise( (LPDISPATCH)m_spCmdBrBtnPtr );

}

Thanks in Advance.
 
There are no such events for popups or CommandBarControls. You have Click()

for buttons and Change() for combos, that's it.

"KarthikonIT" <u54961@uwe> wrote in message news:9c7d2a52bb94c@uwe...
> 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 :public IDispEventSimpleImpl<1,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::DispEventAdvise((IDispatch*)m_spCmdBrBtnPtr);
> //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::DispEventAdvise( (LPDISPATCH)m_spCmdBrBtnPtr );
> }

> Thanks in Advance.
>
 
Hi Ken Thanks you so much! for answering.




Using a different login now.




I am able to receive the events now from the menu that I have added in my toolbar.


But my current problem is in the lpDispatch parameter i m getting vfptr as NULL(0x0000000).




I m sorry i was wrong by saying a POPUP Menu.




Please check this link for reference:




http://www.supinfo-projects.com/fr/2006/add_in_outlook_2007_en/2/


I m trying out 2.3.5 msoControlPopup in that link






If there no POP ctrl what is this all about.




Please help me...








Here is my sample:


OnDataChange fn()


{




Office::CommandBarControlsPtr spCmdBrCtrlsPtr


Office::CommandBarControlPtr spCmdBrCtrlPtr;




Office::CommandBarPopupPtr m_spCmdBrPopupPtr;


Office::_CommandBarButtonPtr m_spCmdBrPOPUPBtnPtr;










//Adding msocontrolpopup to Office::CommandBarControlsPtr


CComVariant vCtrlTyp(Office::msoControlPopup);


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




spCmdBrCtrlPtr->QueryInterface( __uuidof( Office::CommandBarPopup), (void**)&m_spCmdBrPopupPtr); //retrieving the Office::CommandBarPopupPtr




CComVariant vCtrlTypBtn(Office::msoControlButton);


m_spCmdBrPOPUPBtnPtr = m_spCmdBrPopupPtr->Controls->Add(vCtrlTypBtn, vMissng, vMissng, vMissng, vIsTempry); //Adding a Button.






//Setting the properties


m_spCmdBrPOPUPBtnPtr->Visible =VarTrue;


m_spCmdBrPOPUPBtnPtr->Tag = bsTag;






CmdBarBtnEvnts::DispEventAdvise( (LPDISPATCH)m_spCmdBrPOPUPBtnPtr ); //Attaching the event dispatch


}




> h file




public IDispEventSimpleImpl<3,CGrabExplorer,&__uuidof( Office::_CommandBarButtonEvents)




typedef IDispEventSimpleImpl< 3,CGrabExplorer,&__uuidof( Office::_CommandBarButtonEvents)> CmdBarBtnEvnts;






SINK_ENTRY_INFO(3, __uuidof(Office::_CommandBarButtonEvents),0x1, OnDataChange, &OnDataChangeInfo)




_ATL_FUNC_INFO OnDataChangeInfo ={CC_STDCALL,VT_EMPTY,1,{VT_DISPATCH}};
 
I am able to receive the events now from the menu that I have added in my toolbar.


But my current problem is in the lpDispatch parameter i m getting vfptr as NULL(0x0000000).




I m sorry i was wrong by saying a POPUP Menu.




Please check this link for reference:


http://www.supinfo-projects.com/fr/2006/add_in_outlook_2007_en/2/


I m trying out 2.3.5 msoControlPopup






If there no POP ctrl what is this all about.




Please help me...






Here is my sample:


OnDataChange fn()


{




Office::CommandBarControlsPtr spCmdBrCtrlsPtr


Office::CommandBarControlPtr spCmdBrCtrlPtr;




Office::CommandBarPopupPtr m_spCmdBrPopupPtr;


Office::_CommandBarButtonPtr m_spCmdBrPOPUPBtnPtr;










//Adding msocontrolpopup to Office::CommandBarControlsPtr


CComVariant vCtrlTyp(Office::msoControlPopup);


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




spCmdBrCtrlPtr->QueryInterface( __uuidof( Office::CommandBarPopup), (void**)&m_spCmdBrPopupPtr); //retrieving the Office::CommandBarPopupPtr




CComVariant vCtrlTypBtn(Office::msoControlButton);


m_spCmdBrPOPUPBtnPtr = m_spCmdBrPopupPtr->Controls->Add(vCtrlTypBtn, vMissng, vMissng, vMissng, vIsTempry); //Adding a Button.






//Setting the properties


m_spCmdBrPOPUPBtnPtr->Visible =VarTrue;


m_spCmdBrPOPUPBtnPtr->Tag = bsTag;






CmdBarBtnEvnts::DispEventAdvise( (LPDISPATCH)m_spCmdBrPOPUPBtnPtr ); //Attaching the event dispatch


}




> h file




public IDispEventSimpleImpl<3,CGrabExplorer,&__uuidof( Office::_CommandBarButtonEvents)




typedef IDispEventSimpleImpl< 3,CGrabExplorer,&__uuidof( Office::_CommandBarButtonEvents)> CmdBarBtnEvnts;






SINK_ENTRY_INFO(3, __uuidof(Office::_CommandBarButtonEvents),0x1, OnDataChange, &OnDataChangeInfo)




_ATL_FUNC_INFO OnDataChangeInfo ={CC_STDCALL,VT_EMPTY,1,{VT_DISPATCH}};
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
A unable to receive email Using Outlook 1
D Unable to change AppointmentItem.Start property Outlook VBA and Custom Forms 4
D VBA - unable to set rule condition 'on this computer only' Outlook VBA and Custom Forms 5
L Unable to Use Alias as From Address Using Outlook 2
R unable to filter tasks when start date is on or before today Using Outlook 3
J Unable to delete folders in Outlook 2019 / Windows Using Outlook 0
D Unable to view older emails in desktop app Using Outlook 0
M Issues with templates - unable to find in old web app Using Outlook 3
Commodore Unable to move message Using Outlook 3
S Unable to change Message Class Outlook VBA and Custom Forms 0
O Unable to make changes to an existing Calendar entry Using Outlook 11
C Outlook 2016 Unable to delete Gmail IMAP calendar Using Outlook 2
S Unable to extract text from an Outlook email message Using Outlook 2
B Outlook 2016 Unable to view images or logos on the outlook 2016 emails the same html code works well when i use outlook 2010 Using Outlook 0
M Unable to share 2019 calendar Using Outlook 0
D Outlook 2016 Unable to load Outlook data pst file Using Outlook 5
L Unable to Sync Web/Android MS To Do with Windows Outlook Tasks Using Outlook 3
A Unable to save recurring Meeting to Documents folder due to error Using Outlook 2
O Outlook 365 - suddenly unable to send using Gmail POP3 Using Outlook 10
S Outlook 2010 unable to change default font Using Outlook 7
Q Unable to Sync Quicken reminder with Outlook 2016 64Bit Using Outlook 1
S Unable to remove rule outlook 2010 Using Outlook 0
L Wierd Office 365 Contact unable to edit body of random contacts Using Outlook 5
X Unable to send an email from one account to another on same PC Using Outlook 2
Mark Foley Unable to subscribe to published calendar in Outlook 2010 Using Outlook 4
S Unable to Edit Contact Information in Certain Contact Folders Using Outlook 3
P Deleted Items - Unable to Iterate All of Items Outlook VBA and Custom Forms 1
G Unable to dismiss reminders from share point list calendar shared in Outlook Using Outlook 2
R Unable to install without email account Using Outlook 4
E Unable to open Outlook 2010 after adding new email account Using Outlook 4
A Outlook 2016- unable to have all subfolders expanded when opening outlook Using Outlook 11
avant-guvnor Unable to view certain emails in Outlook 2016 Using Outlook 16
M Unable to Configure Gmail Account in Outlook 2007 Using Outlook 1
D Unable to Send On Behalf of Another User Exchange Server Administration 0
J Unable to link email messages in BCM using a single microsoft office 365 account in outlook 2013 BCM (Business Contact Manager) 1
Tim King Outlook 365 unable to change accounts Using Outlook 0
R Unable to send mail using Cox.net Using Outlook 1
T Unable to 'Upload a file' using popup 'Browse' button Using Outlook 0
D Unable to add email address to contact Using Outlook 3
G Outlook calendar entry corrupted. Constant pop up when you open outlook. Unable to delete or remove. Using Outlook 2
O OL2000: Unable to create IMAP account Using Outlook 2
wallisellener Unable to reply/post/create new thread using Chrome BCM (Business Contact Manager) 5
Rupert Dragwater unable to change font sizes in some replies Using Outlook 3
C Unable to see meeting attendees Outlook 2010 Using Outlook 5
M Unable to email from Word or Excel Using Outlook 11
O Unable to check name. Using Outlook 3
T Unable to create contacts subfolder in EAS profile Using Outlook.com accounts in Outlook 6
UncleBill Unable to delete items from gmail IMAP Trash using Outlook 2010 Outlook VBA and Custom Forms 5
B Unable to search delegated mailfile Using Outlook 3
K Unable to activate QueryBuilder in Outlook 2010 (32bit) with Windows 7 (64bit) Using Outlook 1

Similar threads

Back
Top