Advatel Company
Posts: 11
Joined: 2006-05-15
|
Why is it that the OutlookApp.ActiveExplorer.Selection seems to have trouble the more items that are selected?
Thought we could be clever by checking the count for one item but even getting the count is slow.
Is there a quick way to know if there is only one Selected Item on SelectionChange? |
|
Dmitry Kostochko
Add-in Express team
Posts: 2887
Joined: 2004-04-05
|
Hi,
Please show me your code of the OnSelectionChange event handler.
|
|
Advatel Company
Posts: 11
Joined: 2006-05-15
|
procedure TAddInModule.OutlookAppEventsExplorerSelectionChange(
Sender: TObject);
var
SelectedMail : MailItem;
SelectedContact : ContactItem;
cntNumber : Integer;
Selection : Outlook2000.Selection;
LastCursor : TCursor;
EID: WideString;
begin
OutputDebugString('Explorer Selection Changed');
LastCursor := Screen.Cursor;
Screen.Cursor := crHourGlass;
CmdBarOE.Controls.Items[0].AsComboBox.Clear;
EID := OutlookApp.ActiveExplorer.CurrentFolder.EntryID;
if (EID = OutlookApp.Session.GetDefaultFolder(olFolderOutbox).EntryID)
or (EID = OutlookApp.Session.GetDefaultFolder(olFolderSentMail).EntryID)
or (EID = OutlookApp.Session.GetDefaultFolder(olFolderDrafts).EntryID)
or (EID = OutlookApp.Session.GetDefaultFolder(olFolderDeletedItems).EntryID)
then
Selection := nil
else
try
if OutlookApp.ActiveExplorer.Selection.Count = 1 then
Selection := OutlookApp.ActiveExplorer.Selection
else
Selection := nil;
except
on EOleException do Selection := nil;
on EAccessViolation do Selection := nil;
end;
if Assigned(Selection) then
begin
if (Selection.Item(1).QueryInterface(IID__MailItem, SelectedMail) = S_OK) then
begin
cntNumber := setMailControls(CmdBarOE.Controls, SelectedMail);
OlSecurityManager.DisableOOMWarnings := True;
if (cntNumber > 0) and (FLastEntryID <> SelectedMail.EntryID) then
begin
FLastEntryID := SelectedMail.EntryID;
OutputDebugString(PChar(string('EntryID: ' + FLastEntryID)));
parseMailItem(SelectedMail);
end;
OlSecurityManager.DisableOOMWarnings := False;
end
else if (Selection.Item(1).QueryInterface(IID__ContactItem, SelectedContact) = S_OK) then
begin
SetContact(CmdBarOE.Controls, SelectedContact);
end;
end
else
SetContactControls(CmdBarOE.Controls);
Screen.Cursor := LastCursor;
OutputDebugString('/Explorer Selection Changed');
end;
setMailControls, parseMailItem, SetContact and SetContactControls are our code that does the rest of our work and are not causing this problem. |
|
Dmitry Kostochko
Add-in Express team
Posts: 2887
Joined: 2004-04-05
|
Thank you. Everything looks ok and I don't see any ways to speed up your code. I know the Selection collection is slow but I didn't think that anyone would notice this fact.
|
|
Advatel Company
Posts: 11
Joined: 2006-05-15
|
My Boss was the one that noticed first just selecting a large group of e-mails.
Is there a quicker way to find out if only one item is selected? |
|
Dmitry Kostochko
Add-in Express team
Posts: 2887
Joined: 2004-04-05
|
Is there a quicker way to find out if only one item is selected?
The only way is:
if OutlookApp.ActiveExplorer.Selection.Count = 1 then begin
end; |
|