popup dialog box in word addin

旧时模样 提交于 2019-12-05 15:51:37

Add a new Form to your add-in project and design as desired.

In your button click handler you just need to do "new MyPopupDialog().Show();". If you want to make the Word window the parent of your dialog so you can centre it and make it modal to the word window you can make a window wrapper class that you can use in "new MyPopupDialog().ShowDialog(WordWindowWarper);". Something like this:

public class WindowWrapper : IWin32Window
{
    public WindowWrapper(IntPtr handle)
    {
        Handle = handle;
    }

    public IntPtr Handle { get; private set; }
}

The handle being the window handle of the Word application window.

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