在我的VSTO Outlook应用程序中,为什么调用SelectNamesDialog.Display()将窗体移到Outlook后面? [英] In my VSTO outlook app, why does calling SelectNamesDialog.Display() moves my form behind Outlook?
问题描述
我有一个Outlook VSTO应用程序.我正在尝试从我加载的表单中调用SeletNamesDialog.出现的对话框很好,其模式也很好,但似乎将我的表单移到了Outlook应用程序的后面.因此,在我选择了一堆名称并单击确定"后,对话框消失了,但是除非我最小化外观(否则显然不理想),否则我的表单是不可见的.
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();
推荐答案
在显示通讯录时,Outlook不允许您指定表单的Windows句柄.
Outlook will not let you specify your form's windows handle when displaying the address book.
您可以使用扩展MAPI(仅C ++或Delphi)和 IAddrbook :: Address 方法或赎回"及其 RDOAddressBook.ShowAddressBook 方法(它具有ParentWindow参数)或 RDOSelectNamesDialog 对象(它将使用分配给RDOSession.ParentWindow属性)
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)
这篇关于在我的VSTO Outlook应用程序中,为什么调用SelectNamesDialog.Display()将窗体移到Outlook后面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!