问题
I have an outlook VSTO app. I am trying to call the SeletNamesDialog from a form that i load. The dialog comes up which is great and its modal which is fine but it seems to move my form behind the outlook app. So after I select a bunch of names and click ok, the dialog disappears but my form is not visible unless i minimize outlook (which is obviously not ideal).
Is there anyway to avoid this happening?. Here is the code i am using to load the dialog:
var app = new Application();
AddressList gal = app.ActiveExplorer().Session.GetGlobalAddressList();
var dlg = app.Session.GetSelectNamesDialog();
dlg.InitialAddressList = gal;
bool b = dlg.Display();
var sb = new StringBuilder();
foreach (Recipient r in dlg.Recipients)
{
sb.Append(r.Name + ";");
}
txtPeople.Text = sb.ToString();
回答1:
Outlook will not let you specify your form's windows handle when displaying the address book.
You can either use the Extended MAPI (C++ or Delphi only) and the IAddrbook::Address method or Redemption and its RDOAddressBook.ShowAddressBook method (it has ParentWindow parameter) or the RDOSelectNamesDialog object (it will use the window handle assigned to the RDOSession.ParentWindow property)
来源:https://stackoverflow.com/questions/15423081/in-my-vsto-outlook-app-why-does-calling-selectnamesdialog-display-moves-my-fo