OnClick Event problem

  • Thread starter Anton Antonov via OfficeKB.com
  • 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?
 
A

Anton Antonov via OfficeKB.com

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.
 
A

Anton Antonov via OfficeKB.com

//*************************************************//
//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);
 
D

Dmitry Streblechenko

Hmmm... Looks perfectly fine to me. Did you try to put your button on your
own toolbar?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
A

Anton Antonov via OfficeKB.com

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top