Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

popup dialog box in word addin

I am creating a ms office word addin using c#. I have a ribbon with several button. On clicking one of the button I need a popup with few textboxes. Question: How to create a popup dialog in word addin?

like image 647
maX Avatar asked Oct 24 '22 05:10

maX


1 Answers

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.

like image 79
Chris Lindsay Avatar answered Nov 03 '22 04:11

Chris Lindsay