pasteface method crashing outlook

  • Thread starter pasteface method crashing outlook
  • Start date
P

pasteface method crashing outlook

Hi,
I facing a problem while writing an Outllok addin in ATL COM. My Outlook
addin was throwing an Exception. Does
anyone has any idea why PasteFace() method is throwing an exception while
pasting a bitmap from clipboard on to the Button?

code:

hBmp =(HBITMAP)::LoadImage(_Module.GetResourceInstance(),
MAKEINTRESOURCE(IDB_WORKSMARTBAR),IMAGE_BITMAP,0,0,LR_LOADMAP3DCOLORS);

m_Clipboard.Backup();

::OpenClipboard(NULL);
::EmptyClipboard();
::SetClipboardData(CF_BITMAP, (HANDLE)hBmp);
::CloseClipboard();

spWSOpenBtn->PutStyle(Office::msoButtonIconAndCaption);

hr = spWSOpenBtn->PasteFace();
 
K

Ken Slovak - [MVP - Outlook]

This group is for custom Outlook forms programming, BTW.

What are the specs of the bitmap you are putting on the clipboard? Is it a
16x16x156 color bitmap? If you are doing any masking or manipulation of the
bitmap are you putting it on the clipboard as a packed dib and not a dib
section?




"pasteface method crashing outlook" <pasteface method crashing
(e-mail address removed)> wrote in message
news:[email protected]...
 
P

pasteface method crashing outlook

Thanks for the reply.

I'm using 16X16X256 bitmaps. It's work fine in my development system but
crashes the outlook in one of the client system(Vista Business Edition).

Thanks
Kiran. S
 
K

Ken Slovak - [MVP - Outlook]

If it works OK on one machine and not another you need to see what's
different and/or missing on the other machine. Look for any missing
dependencies also.




"pasteface method crashing outlook"
 
P

pasteface method crashing outlook

Ken

The OS version in which Outlook crashes on using Pasteface method is Vista
Business Edition. Do I need to add any additional Re-Distribution packages or
need to update .NET framework?

-Kiran
 
K

Ken Slovak - [MVP - Outlook]

I've never had PasteFace problems on any Vista edition, and I don't deploy
anything differently for Vista than Windows XP or Windows 2000.




"pasteface method crashing outlook"
 
P

pasteface method crashing outlook

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::DispEventAdvise((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();
::DeleteObject(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();
::DeleteObject(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::DispEventAdvise((IDispatch*)info->m_pSmartMeetingURLBtn);
if(FAILED(hr))
return;

m_pSmartMeetingStartupBtn = spSmartMeetingStartupBtn;
info->m_pSmartMeetingStartupBtn = m_pSmartMeetingStartupBtn;
hr =
newInspectorEvents->MeetingStartupEvent::DispEventAdvise((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
 
K

Ken Slovak - [MVP - Outlook]

I don't do C++ code so I won't even attempt to evaluate your code.




"pasteface method crashing outlook"
Thanks for the reply. Can you please go through the code below and let me
know if anything found wrong.
<snip>
 

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