![](/img/trans.png)
[英]WinForms control's child form doesn't respond to mouse events when control is on modal dialog
[英]Word dialog shown programmatically doesn't respond to mouse clicks
以下代碼顯示了一個“ 插入表”對話框:
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方式發生的),而是保持了焦點。
我怎么解決這個問題?
我解決了。
我不確定為什么,但這會有所幫助: 在顯示對話框之前 ,我禁用了主應用程序窗體,然后在顯示對話框之后,將其重新啟用 。
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();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.