R
Rami
Good afternoon,
I created a composite ATL control that is also a Word Add-in (by
implementing _IDTExtensibility2).
In OnConnection I add a toolband and a button.
/******************/
//spNewCmdBar points to the newly created toolband
spNewCmdBar = spCmdBars->Add(vName, vPos, vEmpty, vTemp);
//now get the toolband's CommandBarControls
CComPtr < Office2000::CommandBarControls> spBarControls;
spBarControls = spNewCmdBar->GetControls();
ATLASSERT(spBarControls);
//MsoControlType::msoControlButton = 1
CComVariant vToolBarType(1);
//show the toolbar?
CComVariant vShow(VARIANT_TRUE);
CComPtr < Office2000::CommandBarControl> spNewBar;
// add first button
spNewBar = spBarControls->Add(vToolBarType,vEmpty,vEmpty,vEmpty,vShow);
ATLASSERT(spNewBar);
/******************/
The problem is when trying to set up a handler for the button click.
As a simple ATL control, I just used
IDispEventSimpleImpl<1,CMyClass,&__uuidof(Office2000::_CommandBarButtonEvents)>
and
BEGIN_SINK_MAP(CMyClass)
//Make sure the Event Handlers have __stdcall calling convention
// SINK_ENTRY_INFO(1, __uuidof(Office2000::_CommandBarButtonEvents),
/*dispid*/ 0x01, OnClickButton, &OnClickButtonInfo)
END_SINK_MAP()
Which handles the event just fine.
The problem is that now the UID of 1 does not correspond to a child control,
which is a requirement since this is now a composite control.
I was wondering if you can show me how to handle the button click event in a
composite ATL control.
Thank you in advance.
Rami.
I created a composite ATL control that is also a Word Add-in (by
implementing _IDTExtensibility2).
In OnConnection I add a toolband and a button.
/******************/
//spNewCmdBar points to the newly created toolband
spNewCmdBar = spCmdBars->Add(vName, vPos, vEmpty, vTemp);
//now get the toolband's CommandBarControls
CComPtr < Office2000::CommandBarControls> spBarControls;
spBarControls = spNewCmdBar->GetControls();
ATLASSERT(spBarControls);
//MsoControlType::msoControlButton = 1
CComVariant vToolBarType(1);
//show the toolbar?
CComVariant vShow(VARIANT_TRUE);
CComPtr < Office2000::CommandBarControl> spNewBar;
// add first button
spNewBar = spBarControls->Add(vToolBarType,vEmpty,vEmpty,vEmpty,vShow);
ATLASSERT(spNewBar);
/******************/
The problem is when trying to set up a handler for the button click.
As a simple ATL control, I just used
IDispEventSimpleImpl<1,CMyClass,&__uuidof(Office2000::_CommandBarButtonEvents)>
and
BEGIN_SINK_MAP(CMyClass)
//Make sure the Event Handlers have __stdcall calling convention
// SINK_ENTRY_INFO(1, __uuidof(Office2000::_CommandBarButtonEvents),
/*dispid*/ 0x01, OnClickButton, &OnClickButtonInfo)
END_SINK_MAP()
Which handles the event just fine.
The problem is that now the UID of 1 does not correspond to a child control,
which is a requirement since this is now a composite control.
I was wondering if you can show me how to handle the button click event in a
composite ATL control.
Thank you in advance.
Rami.