以编程方式显示的 Word 对话框不响应鼠标单击
下面的代码显示了一个插入表格对话框:
Dialog d = WordApp.Dialogs[WdWordDialog.wdDialogTableInsertTable];
int result = d.Show(ref missing);
if (result == -1) // if user pressed OK
{
d.Execute();
}
问题是该对话框不响应鼠标点击。 不过,它响应键盘输入。
此外,如果我按 Alt+Tab(切换到其他正在运行的应用程序),然后再次按 Alt+Tab(切换回我的应用程序),它会响应鼠标和键盘输入。
我的猜测是,我的应用程序不“知道”显示了对话框(因为它不会以常规 Form.ShownDialog 方式发生),并且它会保持焦点。
我怎么解决这个问题?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我解决了。
我不太清楚为什么,但这有帮助:在显示对话框之前我禁用主申请表,然后之后显示对话框我启用它。
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.