Your class must implement IDTCommandTarget interface (typelib: Program
File\Common Files\Microsoft Shared\MSEnv\dte.olb).
Exec() and QueryStatus() will pass in 'cmdName', which is the full qualified
command name of a command -- "Addins.%progid%.%name%" (e.g.
progid:"MyAddin", name:"MyCmd", full name: "Addins.MyAddin.MyCmd").
You should check this name by comparing it with supported commands, then do
anything you like.
"Ahmad Jalil Qarshi" <ahmaddearNO@SPAMhotmail.com> дÈëÏûÏ¢ÐÂÎÅ:uNfSuEwKFHA.732@TK2MSFTNGP12.phx.gbl...
> hi!
>
[quoted text clipped - 11 lines]
>
> Ahmad Jalil Qarshi
1. If you want to handle event from a Word button, you must implement
_CommandBarButtonEvents as ICommandBarButtonEvents.
------------------------------------------------
// sample code VC++:
class ATL_NO_VTABLE CEventSink :
public CComObjectRootEx<CComSingleThreadModel>,
public IDispatchImpl<ICommandBarButtonEvents,
&__uuidof(ICommandBarButtonEvents), &LIBID_Office, /*wMajor =*/ 2, /*wMinor
=*/ 3> // 2.3 = office 11.0
{
...
BEGIN_COM_MAP(CEventSink)
COM_INTERFACE_ENTRY_IID(__uuidof(_CommandBarButtonEvents),
ICommandBarButtonEvents)
END_COM_MAP()
...
STDMETHOD_(void, Click)(_CommandBarButton *Ctrl, VARIANT_BOOL
*CancelDefault);
};
------------------------------------------------
Then advise the event sink for the button (e.g. inside
_IDTExtensibility2::OnConnection()).
2. I think the problem is a custom button in a popup menu doesn't raise
events when it's clicked (bug?). The function _CommandBarButton::Execute()
will raise the event, however.
I created a word document and added a button to the "Inline Picture" popup
menu, and I created a VBA class to handle the 'click' event of the button
which simply shows a msgbox. The instance of the class is created during
document loading. But sadly, the event was not raised when I clicked the
button. Instead, I had a macro to invoke the 'Execute' method of the button,
the event is raised. I also tried to handle events from the build-in
"Cut(&T)" buttons, and the event was raised when it was clicked.
"Ahmad Jalil Qarshi" <ahmaddearNO@SPAMhotmail.com> дÈëÏûÏ¢ÐÂÎÅ:uNfSuEwKFHA.732@TK2MSFTNGP12.phx.gbl...
> hi!
>
[quoted text clipped - 11 lines]
>
> Ahmad Jalil Qarshi