In my VSTO outlook app, why does calling SelectNamesDialog.Display() moves my form behind Outlook?

雨燕双飞 提交于 2020-01-16 18:38:01

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!