Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a dialog for Word Addin

How can I create a Settings dialog for a Word Addin.

I have already creating a Windows Form and I'm calling 'form.Show()`. But It's creating a new Window.

How can I pass the owner by form.ShowDialog(owner)?

I've solve my question creating a Helper for open the Dialog, but I don't know if is the best way

public static DialogResult ShowDialog(Form dialog)
{
    NativeWindow mainWindow = new NativeWindow();
    mainWindow.AssignHandle(Process.GetCurrentProcess().MainWindowHandle);
    DialogResult dialogResult = dialog.ShowDialog(mainWindow);
    mainWindow.ReleaseHandle();
    return dialogResult;
}
like image 463
Victor Avatar asked Sep 24 '12 16:09

Victor


People also ask

How do I create a dialogue in Word?

Box simply click the Home tab in the ribbon. And then click the paragraph dialogue box launcher button in the lower right corner of the paragraph.

How do you make a dialog box?

To create a new dialog box In Resource View, right-click your . rc file and select Add Resource. In the Add Resource dialog box, select Dialog in the Resource Type list, then choose New. If a plus sign (+) appears next to the Dialog resource type, it means that dialog box templates are available.

What is a Word dialog box?

A: A dialog box is a small window that a program pops open to request input from the user. For example, in Word if you click on the Save icon and the document hasn't already been named, Word will pop open a dialog box that prompts you to name the file and tell the program where to save it.


1 Answers

I solve the question creating the code:

public static DialogResult ShowDialog(Form dialog)
{
    NativeWindow mainWindow = new NativeWindow();
    mainWindow.AssignHandle(Process.GetCurrentProcess().MainWindowHandle);
    DialogResult dialogResult = dialog.ShowDialog(mainWindow);
    mainWindow.ReleaseHandle();
    return dialogResult;
}
like image 128
Victor Avatar answered Sep 30 '22 11:09

Victor