View Single Post
  #8  
Old November 6th 07, 10:47 AM posted to microsoft.public.outlook.program_addins
Zuber
external usenet poster
 
Posts: 6
Default Outlook 2007 crash

Hi Dimitry,

Your workaround solution of PostMessage() just seem to have worked for me too.

Looks like GetSelectionItem() does not work if used from OnSelectionChange()
for Outlook 2007.

I am doing some tests to check if it has really fixed the issue.

Thanks for all your help.

Thanks and Regards,

Zuber

"Dmitry Streblechenko" wrote:

Hmmm.. I stopped using ECE in Outlook 2007 (I still use them in the previous
versions of Outlook), so I can't really verify what is going on.
Does this happen for any folder or just the Calendar folders?
I remember a similar issue in Outlook 97 where GetSelectionItem() will choke
if called from OnSelectionChange.
I worked around that by posting 0xF449 command using

PostMessage(hwndExchange, WM_COMMAND, 0xF449, 0);

where hwndExchange comes from IEXCHEXTCALLBACK::GetWindow() and doing the
processing in DoCommand().

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

"Zuber" wrote in message
...
The variables have been initialized as follows:

UpdateSelection(LPEXCHEXTCALLBACK lpeecb)
{
TCHAR szMsgClass[SOTC_MSGCLASS_SIZE];
ULONG dwMsgFlags = 0;
LPENTRYID pEID = NULL;
ULONG ulSelect = 0;
ULONG cbEID = 0;
ULONG ulType = 0;

CComPtrIExchExtCallback m_spExchCallback;
m_spExchCallback = lpeecb;
m_spExchCallback-GetSelectionCount(&ulSelect);

for( int i=0 ; i ulSelect ; i++ )
{
m_spExchCallback-GetSelectionItem ( i ,&cbEID, &pEID, &ulType,
szMsgClass,

SOTC_MSGCLASS_SIZE, &dwMsgFlags, 0) );
if ( MAPI_MESSAGE == ulType )
{
AddItem(pNewSelection);
}
}
}

"Dmitry Streblechenko" wrote:

You never initialize the i variable in UpdateSelection(). Are you usre it
is
valid?

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

"Zuber" wrote in message
...
Hello Dmitry,

On further investigation I found that with Outlook 2003, the events are
fired the same way as for Outlook 2007. For OL2003, the events that are
fired
on folder change a

1. OnSelectionChange() for mail from previous folder
2. OnSelectionChange() for new folder
3. OnSelectionChange() form mail in new folder

On OL2007, only the first event is fired.

Here is a skeleton of the code:

OnSelectionChange( LPEXCHEXTCALLBACK lpeecb )
{
CComQIPtrIUnknown, &IID_IUnknown spUnk = lpeecb;
UpdateSelection(spUnk);
}

UpdateSelection(LPEXCHEXTCALLBACK lpeecb)
{
CComPtrIExchExtCallback m_spExchCallback;
m_spExchCallback = lpeecb;
m_spExchCallback-GetSelectionItem ( i ,&cbEID, &pEID, &ulType,
szMsgClass,

SOTC_MSGCLASS_SIZE,
&dwMsgFlags,
0) );
if ( MAPI_MESSAGE == ulType )
{
AddItem(pNewSelection);
}
}

If I comment out, GetSelectionItem() it works properly otherwise OL
crashes.

The "LPEXCHEXTCALLBACK" comes from the Exchange55 SDK. Is the
Exchange55
SDK
compatible with OL 2007 ?

Thanks and Regards,

Zuber

"Dmitry Streblechenko" wrote:

I don't think I have ever seen this. What is your code? How do you
declare
the variable assigned to the items in the SElection collection?

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

"Zuber" wrote in message
...
Hello,

I am working on an issue related with add-in for Outlook 2007. I
need
some
help fixing it.

The issue is,

I have written some code to handle the OnSelectionChange() event. I
am
calling a function from OnSelectionChange() which in turn invokes
GetSelectionItem() and works on that item.

The OnSelectionChange() event is fired twice or thrice when the
selection
changes. It works fine if I move between messages in the same
folder,
but
when I select a different folder Outlook 2K7 crashes. The reason
being;
when
folder selection changes the first event to get fired is for the
selected
message from the previous selected folder rather than for the new
selected
folder. The second event is for the folder.

The code expects the newly selected item to be a folder rather than
a
message item, the code crashes due to this.

FYI, the same code works on Outlook 2003. I am not sure if anything
changed
for Outlook 2007, or something more is required from my end.

Thanks in advance for any solution.

Thanks and Regards,

Zuber









Ads