To add a button to an Inspector (as opposed to Explorer), trap the
Application.Inspectors.NewInspector event, new Inspector will be passed as a
parameter, check if your button is already there (since Outlook reuses
inspectors), if yes, delete it, if no, add it as a temporary button
(Inspectors.CommandBars.Item("Standard").Controls.Add(...Temporary:=true,
....)) and sink the CommandBarButton.Click event.
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
"robert dugal" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> It took me a lot of work to get the Outlook Object Model working from
> C++. While trying to figure this out I saw this post from you:
>
> >Date: Thu, 23 Jan 2003 01:08:16 -0700
> >Reply-To: MAPI Developers Forum <MAPI-(E-Mail Removed)>
> >Sender: MAPI Developers Forum <MAPI-(E-Mail Removed)>
> >From: Dmitry Streblechenko <(E-Mail Removed)>
> >Subject: Re: Toolbar (complete)
> >Content-Type: text/plain; charset="utf-8"
> >
> >I usually do the following:
> >1. Grab Application in IExchExt::Install() when eecontext ==
> EECONTEXT_SESSION
>
> However, when I tried this code based on a post by Michael Tissington:
>
> if ( EECONTEXT_SESSION == eecontext )
> {
> if ( m_pOutlook == NULL )
> {
> HRESULT hr2;
> IOutlookExtCallback * pOutlookExt = NULL;
> hr2 = peecb->QueryInterface( IID_IOutlookExtCallback,
> (LPVOID *)&pOutlookExt );
> if ( SUCCEEDED( hr2 ) )
> {
> IUnknown * pUnk = NULL;
> hr2 = pOutlookExt->GetObject( &pUnk );
> if ( SUCCEEDED( hr2 ) )
> {
> LPDISPATCH pDispatch = NULL;
>
> hr2 = pUnk->QueryInterface( IID_IDispatch,
> (LPVOID *)&pDispatch );
> if ( SUCCEEDED( hr2 ) )
> {
> OLECHAR * szApplication = L"Application";
> DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0 };
> DISPID dspid;
> VARIANT vtResult;
>
> pDispatch->GetIDsOfNames(
> IID_NULL,
> &szApplication,
> 1,
> LOCALE_SYSTEM_DEFAULT,
> &dspid );
>
> pDispatch->Invoke(
> dspid,
> IID_NULL,
> LOCALE_SYSTEM_DEFAULT,
> DISPATCH_METHOD,
> &dispparamsNoArgs,
> &vtResult,
> NULL,
> NULL );
>
> pDispatch->Release();
>
> m_pOutlook = vtResult.pdispVal;
> }
>
> pUnk->Release();
> }
>
> pOutlookExt->Release();
> }
> }
> }
>
> pUnk->QueryInterface() returns 0x80004002. But it is successfull in
> EECONTEXT_VIEWER and EECONTEXT_SENDNOTEMESSAGE.
>
> Having gotten this far I'm now playing with OOM, trying to add my own
> buttons to the Standard toolbar. It's been very difficult because
> there is so little information relating to doing things in C++. I can
> now add a button with text and an image (I still need to figure out
> the transparency issue though) to the main viewer window but cannot
> figure out how to add it to the Send Note form. Instead I end up
> getting 2 copies of the button on the Standard toolbar of the main
> viewer window. Here's my code:
>
>
> CommandBarControlsPtr pCtls;
> try { pCtls = m_pOutlook->ActiveExplorer()->CommandBars->
> GetItem("Standard")->GetControls(); } catch (_com_error) {}
>
> if ( pCtls )
> {
> //CommandBarControlPtr pBtn;
> _CommandBarButtonPtr pBtn;
> try { pBtn = pCtls->Add ( (long)msoControlButton, vtMissing,
> vtMissing, vtMissing, true ); } catch (_com_error) {}
> if ( pBtn )
> {
> pBtn->Caption = "Test Caption";
> pBtn->Tag = "Test Tag";
> pBtn->TooltipText = "This is a test";
> pBtn->PutStyle( msoButtonIconAndCaption );
> pBtn->PutFaceId( 0 );
>
> try
> {
> OpenClipboard(NULL);
> EmptyClipboard();
> HBITMAP hBitmap = LoadBitmap( hInst,
> MAKEINTRESOURCE( IDB_TEST ) );
> SetClipboardData(CF_BITMAP, hBitmap);
> CloseClipboard();
> pBtn->PasteFace();
> OpenClipboard(NULL);
> EmptyClipboard();
> CloseClipboard();
> }
> catch(...){}
> }
> }