The following piece of code shows an Insert table dialog:
Dialog d = WordApp.Dialogs[WdWordDialog.wdDialogTableInsertTable];
int result = d.Show(ref missing);
if (result == -1) // if user pressed OK
{
d.Execute();
}
The problem is that the dialog does not respond to mouse clicks. It responds to keyboard input, though.
Moreover, if I press Alt+Tab (to switch to some other running app) and then press Alt+Tab again (to switch back to my app), it responds to both mouse and keyboard input.
My guess is that my application doesn't 'know' that a dialog box was shown (because it doesn't happen in a regular Form.ShownDialog way) and it keeps the focus.
How can I solve this problem?
I worked it out.
I'm not exactly sure why but this helps: before displaying the dialog I disable the main application form, then after the dialog is displayed I enable it back.
Dialog d = WordApp.Dialogs[WdWordDialog.wdDialogTableInsertTable];
MainApplicationFormInstance.Enabled = false;
int result = d.Display(ref missing);
MainApplicationFormInstance.Enabled = true;
if (result == -1) // user pressed OK
{
d.Execute();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.