Add CommandBarButton to Contacts form in C++

  • Thread starter Tobias Svensson
  • Start date
T

Tobias Svensson

Hello,
I am working on a Outlook client extension in VC++. I have a button added to
the standard toolbar in Outlook. Now I also would like to add the same
button when the user opens the Outlook form for contacts. (existing contact
or new contact)

How can I detect when a form containing contacts is opened and how do I add
the button?

Thanks...
 
D

Dmitry Streblechenko

You can do it in exactly same way, only context will be different
(EECONTEXT_VIEWER). Or you can use Outlook Object Model from your extension
(use IOutlookExtCallback) to add the buttons using OOM.

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

Tobias Svensson

Thanks for the answer.
In IExchExt::Install I only seem to get messages for the email form
(EECONTEXT_READNOTEMESSAGE and EECONTEXT_SENDNOTEMESSAGE). I need the
contact form. Also, I don't succeed in adding the button to the newly opened
form, only to the Outlook application.
I installed it in registry with
4.0;D:\Projects\VC\TextExt\Debug\TestExt.dll;1;11111111111111;1111111
I am using Outlook 2000.

Here is some code I am using, if you can tell me if I am on the right
track... Code here is without any error checking and releasing of the
interfaces.

// Member pointer
Outlook::_ApplicationPtr m_pOApp;

// In IExchExt::Install get the Outlook pointer and save it like this:
IOutlookExtCallback* IOut = NULL;
IUnknown * punk = NULL;
IDispatch *IDisp = NULL;
pmecb->QueryInterface(IID_IOutlookExtCallback,(LPVOID*)&IOut);
IOut->GetObject(&punk);
hr = punk->QueryInterface(IID_IDispatch,(LPVOID*)&IDisp);
hr =
IDisp->QueryInterface(__uuidof(Outlook::_Application),(LPVOID*)&m_pOApp);
OApp = m_pOApp;

// Then in IExchExtCommands::InstallCommands I add the button like this.
Outlook::_ApplicationPtr pOApp = OApp;
Outlook::_ExplorerPtr pExp = pOApp->ActiveExplorer();
Office::_CommandBarsPtr pCmdBars = pExp->CommandBars;
Office::CommandBarPtr pMainBar = pCmdBars->ActiveMenuBar;
Office::CommandBarPtr pToolBar = pCmdBars->GetItem("Standard");
Office::_CommandBarButtonPtr pItem =
pToolBar->Controls->Add((long)Office::msoControlButton,vtMissing, vtMissing,
vtMissing, true);

What rows should be changed here to add the button to the new form instead?

Regards Tobias
 
D

Dmitry Streblechenko

1. Your extension must be installed using an ECF file rather than registry
and have "MoreContexts" specified to receive IExchExt::Install() callbacks
for the messages other than IPM.Note
2. You need to track Application.Inspectors.NewInspector event. In the event
handler use the Inspctor object to access its Inspector.CommandBars
collection to add your toolbars/buttons.

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

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