A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Outlook 2000 is crashing while adding right click context menu.



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old August 17th 06, 04:08 PM posted to microsoft.public.outlook.program_addins
Vinayakc
external usenet poster
 
Posts: 22
Default Outlook 2000 is crashing while adding right click context menu.

Hi all,

I am facing one weired problem. I am adding one menu item to the right
click context menu for my add-in. I pasted my function below.
This function is working fine with Outlook 2002 and Outlook 2003. But
it is crashing on Outlook 2000 for one specific scenario.
After initializing Outlook if I right click on normal mail item and
then if I right click on meeting item Outlook just crashes with the
Access violation error.
Only difference between these two menus are for meeting item there are
more no of options in the context menu.
If user does it vice versa then it works fine. ( first right click on
meeting item and then mail item.)
I am not able to understand this behaviour of Outlook 2000. If anyone
knows about this issue, please let me know about the same.

I have noted down the crash line as "*******Crash occurring here.
*******" in the code.


void __stdcall CIPPlugin::OnContextMenuUpdate()
{
CComPtrOffice::CommandBar pCmdBar;
CComPtrOffice::CommandBarControls pMenuControls;
Office::MsoBarProtection oldProtectionLevel;
BOOL bFound =false;
int Count =0;

///
//m_spCommandbars is member variable of CIPPlugin class.
//We are getting it in OnStartupComplete
// result= pActiveExplorer-get_CommandBars(&pExplorerCommandBars);
///

if( m_spCommandbars )
m_spCommandbars-get_Count(&Count);

for(long i = 0; i Count; i++)
{
CComPtrOffice::CommandBar pTempBar;
CComVariant vItem(i+1);
m_spCommandbars-get_Item(vItem,&pTempBar);
if(pTempBar)
{
BSTR bstrName;
pTempBar-get_Name(&bstrName);

if(!wcscmp(L"Context Menu", bstrName))
{
pCmdBar = pTempBar;
bFound = true;
pCmdBar-Reset(); //*******Crash occurring here. *******
break;
}

::SysFreeString(bstrName);

}
}
if(!bFound)
return;

if(pCmdBar)
{
pCmdBar-get_Controls(&pMenuControls);
pCmdBar-get_Protection(&oldProtectionLevel);
pCmdBar-put_Protection(Office::msoBarNoProtection);
CComVariant vtType(Office::msoControlButton);

CComPtrOffice::CommandBarControl pContextMenuControl;
pSPAMContextMenuControl=pMenuControls-Add(CComVariant(
Office::msoControlButton),
CComVariant(1),
CComVariant(1),
CComVariant(1),
CComVariant(VARIANT_TRUE)
);
if(pContextMenuControl==NULL)
{
LOG_ERR_MESSAGE(_T("pMenuControls-Add") , GetLastError());
pCmdBar.Release();
return;
}
pContextMenuControl-QueryInterface(&m_pContextMenu);

bstrTemp.LoadString(IDS_BUTTON_CAPTION);
if( m_pContextMenu )
{
m_pContextMenu-put_Tag(bstrTemp);
m_pContextMenu-put_Caption(bstrTemp);
m_pContextMenu-put_Priority(1) ;
m_pContextMenu-put_Visible(TRUE);
m_pContextMenu-put_Style(Office::msoButtonIconAndCaption);

hr =
ContextMenuEvents:ispEventAdvise((IDispatch*)m_p SPAMContextMenu);
}

pCmdBar-put_Protection(oldProtectionLevel);
pCmdBar.Release();
}
}

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading Pane Context Menu VBA Help Paul Add-ins for Outlook 8 August 21st 06 03:15 PM
Add Contact context menu option Gene Chang Add-ins for Outlook 2 August 1st 06 03:31 PM
adding a context menu in Outlook donald Add-ins for Outlook 6 May 3rd 06 01:49 PM
How do I add a new option in the context menu(Outlook)? Outllok - context menus aad ins Outlook - Using Forms 5 March 16th 06 02:47 PM
Context Menu not present Mono Outlook Express 5 February 7th 06 06:22 PM


All times are GMT +1. The time now is 05:04 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.