Thanks for the reply. Can you please go through the code below and let me
know if anything found wrong.
Code:
::NewInspector(IDispatch* pdispInspector)
{
try
{
CComQIPtr<Outlook::_Inspector> spInspector(pdispInspector);
ATLASSERT(spInspector);
CComQIPtr<Outlook::_AppointmentItem> spAppointmentItem;
spInspector->get_CurrentItem((IDispatch **)&spAppointmentItem);
ATLASSERT(spAppointmentItem);
OlObjectClass itemclass;
spAppointmentItem->get_Class(&itemclass);
m_spAppointmentItem = spAppointmentItem;
if (itemclass == olAppointment)
{
CWSNewInspectorEvents *newInspectorEvents = new
CWSNewInspectorEvents(this);
OutlookNewInspectotInfo *info = new OutlookNewInspectotInfo;
info->newInspectorEvents = newInspectorEvents;
info->m_spAppointmentItem = spAppointmentItem;
HRESULT hr;
hr = newInspectorEvents->CloseInspectEvents:
ispEventAdvise((IDispatch*)
info->m_spAppointmentItem);
if( FAILED (hr))
return;
CComPtr < Office::_CommandBars> spCmdBars;
spInspector->get_CommandBars(&spCmdBars);
ATLASSERT(spCmdBars);
m_pCmdBars = spCmdBars;
// now we add a new toolband to Outlook
// to which we'll add 2 buttons
CComVariant vName("WorldSmart OutlookAddin");
CComPtr <Office::CommandBar> spNewCmdBar;
// position it below all toolbands
//MsoBarPosition::msoBarTop = 1
CComVariant vPos(1);
CComVariant vTemp(VARIANT_TRUE); // menu is temporary
CComVariant vEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR);
//Add a new toolband through Add method
// vMenuTemp holds an unspecified parameter
//spNewCmdBar points to the newly created toolband
spNewCmdBar = spCmdBars->Add(vName, vPos, vEmpty, vTemp);
ATLASSERT(spNewCmdBar);
m_pCmdBar = spNewCmdBar;
//now get the toolband's CommandBarControls
CComPtr < Office::CommandBarControls> spBarControls;
spBarControls = spNewCmdBar->GetControls();
ATLASSERT(spBarControls);
//MsoControlType::msoControlButton = 1
CComVariant vButtonType(1);
CComVariant vPopupType(msoControlPopup);
//show the toolbar?
CComVariant vShow(VARIANT_TRUE);
//SmartMeetingURL
CComPtr < Office::CommandBarControl> spSmartMeetingURL;
spSmartMeetingURL = spBarControls->Add(vButtonType, vEmpty, vEmpty,
vEmpty, vShow);
ATLASSERT(spSmartMeetingURL);
CComQIPtr < Office::_CommandBarButton>
spSmartMeetingURLBtn(spSmartMeetingURL);
ATLASSERT(spSmartMeetingURLBtn);
spSmartMeetingURLBtn->PutStyle(Office::msoButtonIconAndCaption);
HICON hIco =(HICON)::LoadImage(_Module.GetResourceInstance(),
MAKEINTRESOURCE(IDI_ICON_COPYURL),IMAGE_ICON,0,0,LR_LOADTRANSPARENT |
LR_LOADMAP3DCOLORS);
ICONINFO oIconInfo;
GetIconInfo(hIco, &oIconInfo);
m_Clipboard.Backup();
// put Icon into Clipboard
::OpenClipboard(NULL);
::EmptyClipboard();
::SetClipboardData(CF_BITMAP, oIconInfo.hbmColor);
::CloseClipboard();
:
eleteObject(hIco);
hr = spSmartMeetingURLBtn->PasteFace();
fprintf(fileptr,"[NewInspector]spSmartMeetingURLBtn->PasteFace()
success\r\n");
fflush(fileptr);
m_Clipboard.Restore();
if (FAILED(hr))
return;
spSmartMeetingURLBtn->PutVisible(VARIANT_TRUE);
spSmartMeetingURLBtn->PutCaption(OLESTR("Copy Conference Link"));
spSmartMeetingURLBtn->PutEnabled(VARIANT_TRUE);
spSmartMeetingURLBtn->PutTooltipText(OLESTR("Copy Conference Link"));
spSmartMeetingURLBtn->PutTag(OLESTR("CopyMeetingLink"));
spSmartMeetingURLBtn->PutVisible(VARIANT_TRUE);
//SmartMeetingStartup
CComPtr < Office::CommandBarControl> spSmartMeetingStartup;
spSmartMeetingStartup = spBarControls->Add(vButtonType, vEmpty, vEmpty,
vEmpty, vShow);
ATLASSERT(spSmartMeetingStartup);
CComQIPtr < Office::_CommandBarButton>
spSmartMeetingStartupBtn(spSmartMeetingStartup);
ATLASSERT(spSmartMeetingStartupBtn);
HICON hIcon =(HICON)::LoadImage(_Module.GetResourceInstance(),
MAKEINTRESOURCE(IDI_ICON_METTING),IMAGE_ICON,0,0,LR_LOADTRANSPARENT |
LR_LOADMAP3DCOLORS);
ICONINFO IconInfo;
GetIconInfo(hIcon, &IconInfo);
spSmartMeetingStartupBtn->PutStyle(Office::msoButtonIconAndCaption);
m_Clipboard.Backup();
// put Icon into Clipboard
::OpenClipboard(NULL);
::EmptyClipboard();
::SetClipboardData(CF_BITMAP, IconInfo.hbmColor);
::CloseClipboard();
:
eleteObject(hIcon);
hr = spSmartMeetingStartupBtn->PasteFace();
fprintf(fileptr,"[NewInspector]spSmartMeetingStartupBtn->PasteFace()
success\r\n");
fflush(fileptr);
m_Clipboard.Restore();
if (FAILED(hr))
return;
spSmartMeetingStartupBtn->PutVisible(VARIANT_TRUE);
spSmartMeetingStartupBtn->PutCaption(OLESTR("Start Conference"));
spSmartMeetingStartupBtn->PutTooltipText(OLESTR("Start Conference"));
spSmartMeetingStartupBtn->PutTag(OLESTR("StartConference"));
spSmartMeetingStartupBtn->PutVisible(VARIANT_TRUE);
spSmartMeetingStartupBtn->PutEnabled(VARIANT_TRUE);
m_pSmartMeetingURLBtn = spSmartMeetingURLBtn;
info->m_pSmartMeetingURLBtn = m_pSmartMeetingURLBtn;
hr =
newInspectorEvents->CopyURLEvent:
ispEventAdvise((IDispatch*)info->m_pSmartMeetingURLBtn);
if(FAILED(hr))
return;
m_pSmartMeetingStartupBtn = spSmartMeetingStartupBtn;
info->m_pSmartMeetingStartupBtn = m_pSmartMeetingStartupBtn;
hr =
newInspectorEvents->MeetingStartupEvent:
ispEventAdvise((IDispatch*)info->m_pSmartMeetingStartupBtn);
if(FAILED(hr))
return;
m_VInspectorInfo->push_back(*info);
spNewCmdBar->PutVisible(VARIANT_TRUE);
fprintf(fileptr,"[NewInspector]Return Success\r\n");
fflush(fileptr);
}
else
{
}
}
catch(...)
{
DWORD dError = GetLastError();
fprintf(fileptr,"[NewInspector]Exception::%ld",dError);
fflush(fileptr);
}
}
In a new appointment page I'm trying to add a tool bar with two buttons.
-Kiran