OnClick Event problem

  • Thread starter Thread starter Anton Antonov via OfficeKB.com
  • Start date Start date
A

Anton Antonov via OfficeKB.com

When not sufficient place for my toolbar one of my buttons is hidden in the
pop-up menu.

I press an arrow button (in the right part of my toolbar), see my
CommandBarButton but when I click it "OnClick" event does not come to my
extension... I catch only toolbar "OnUpdate" event.

What I should do to catch my button "OnClick" event?
 
But I'm still have a problem on Outlook 2000 without service packs with
buttons that are hidden in the pop-up menu. Sometimes Outlook drop down
with access violation when I'm click on an arrow button (in the right part
of my toolbar), another time I'm click on my button in the pop-up menu but
OnClick event does not come to my extension.

But when I'm click on arrow button of OutSpy toolbar no problems occurrs.
 
//*************************************************//
//Code that handle the click events
//ExchangeExtension.h Some parts of code are omitted...

/...
extern _ATL_FUNC_INFO OnClickButtonInfo;
/...
class CExchangeExtension: public IExchExt,
public CComObjectRootEx<CComSingleThreadModel>,
public IQSDispEvent<1,CExchangeExtension,&__uuidof
(Office::_CommandBarButtonEvents)>
//....

public:
typedef IQSDispEvent</*nID =*/1,CExchangeExtension, &__uuidof
(Office::_CommandBarButtonEvents)> BtnEvents;

BEGIN_SINK_MAP(CExchangeExtension)
SINK_ENTRY_INFO(1,__uuidof(Office::_CommandBarButtonEvents),/*dispid*/
0x01, OnClickMyButton, &OnClickButtonInfo)
END_SINK_MAP()

void __stdcall OnClickMyButton(IDispatch * /*Office::_CommandBarButton**/
Ctrl,VARIANT_BOOL * CancelDefault);


private:
CComPtr<Office::_CommandBarButton> m_cbMyButton;

//************************************************************
// sample of source code
//************************************************************

//....
hRes = pBarControls->Add(CComVariant(Office::msoControlButton),
vtMissing,
vtMissing,
vtMissing,
CComVariant(TRUE),
&m_cbMyButton);
hRes = m_cbMyButton->put_Caption( bstrCaption.GetBSTR() );
if ( bSeparator )
hRes = m_cbMyButton->put_BeginGroup (VARIANT_TRUE);

/*code which prepare image for my button omitted*/
hRes = m_cbMyButton->PasteFace();

m_cbMyButton->put_Tag(bstrCaptionTag.GetBSTR()); //bstrCaptionTag - GUID

//... After that I'm create my button
//...

hRes = pExchExt->BtnEvents::DispEventAdvise((IDispatch*)m_cbMyButton);
 
Yes, I'm create my own toolbar

I want draw attention on fact that I'm have problems with "OnClick" event
from my buttons only when some of my buttons are hidden in the pop-up menu
which become visible when user click on the arrow button in right part of
my toolbar and after that user click on my button...

I have problems only on Outlook 2000 without servise packs, and it drop
down sometimes with access violation when I'm click on the arrow button in
right part of my toolbar, may be this is well-known "bug" of Outlook 2000
without sp's?

On Outlook 2003 or Outlook 2002 I have no problems now with my buttons...

The sample code of creating my own toolbar is:

//*****************
//....
CComPtr < Outlook::_Explorer> spExplorer;
hRes = pExchExt->m_OLAppPtr->ActiveExplorer(&spExplorer);
if (!spExplorer)
hRes = E_FAIL;

if ( m_bIsOutlook2K )
hRes = pExchExt->ExplEvents::DispEventAdvise((IDispatch*)spExplorer);

if (!m_pCmdBars)
hRes = spExplorer->get_CommandBars(&m_pCmdBars);
if ( m_bIsOutlook2K )
hRes = pExchExt->CommandBarsEvents::DispEventAdvise((IDispatch*)
m_pCmdBars);

CComVariant vName(strToolbarName);
Office::MsoBarPosition BarPosition;
bool bToolbarVisible;

//this function returns saved toolbar position
GetToolbarState(bToolbarVisible, BarPosition);
if (!m_cbOfflineToolbar)
hRes = spCmdBars->Add(vName, CComVariant(BarPosition), vtMissing,
CComVariant(TRUE), &m_cbOfflineToolbar);

CComPtr <Office::CommandBarControls> pBarControls = NULL;
hRes = m_cbOfflineToolbar->get_Controls(&pBarControls);

VARIANT_BOOL bLargeButtons;
hRes = spCmdBars->get_LargeButtons(&bLargeButtons);

//after that I'm create my buttons, sample code of it above in previous
//post
 
Back
Top