How to disable standard menus/buttons

  • Thread starter Thread starter robert dugal
  • Start date Start date
R

robert dugal

Is there a way to disable the buttons/menus for "Reply" and "Reply to All"?
I tried doing the following in IExchExtCommands::InitMenu() but this doesn't work.


STDMETHODIMP_(VOID) MyExchExt::InitMenu( LPEXCHEXTCALLBACK lpeecb )
{
HMENU hmenu;
HRESULT hr = lpeecb->GetMenu( &hmenu );
if ( hr == S_OK )
{
EnableMenuItem( hmenu, EECMDID_ComposeReplyToSender, MF_GRAYED );
EnableMenuItem( hmenu, EECMDID_ComposeReplyToAll, MF_GRAYED );
}
 
Try to use Outlook Object Model instead - use IOutlookExtCallback to get
Application object, then use
Application.ActiveExplorer.CommandBars.FindControl to find the button, then
set the CommandBarButton.Enabled property.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
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 <[email protected]>
Sender: MAPI Developers Forum <[email protected]>
From: Dmitry Streblechenko <[email protected]>
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(...){}
}
}
 
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
 
Back
Top