使用 C# 在 Windows 应用程序中修复主窗口上的提示窗口 [英] Fixing a prompt window over the main window in a windows application using C#

查看:40
本文介绍了使用 C# 在 Windows 应用程序中修复主窗口上的提示窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在 Windows 应用程序中加入了拼写检查功能,这是我们面临的问题.

We have included a spell check feature in our windows application and here's the issue we are facing.

重现问题的步骤:

  1. 点击了拼写检查功能.
  2. 在拼写检查提示之前切换到另一个应用程序出现了.
  3. 返回时,应用程序无响应,因为拼写检查窗口失去焦点.

访问应用程序的唯一方法是使用 Alt + Tab,转到窗口并关闭它.我的问题是如何将提示窗口固定在应用程序窗口上,当从任务栏中选择应用程序时,应用程序附带提示窗口?(就像我关闭 Word 应用程序时发生的情况一样,它提示我保存,当我切换到另一个应用程序并返回到该单词时,提示仍然可以访问)

The only way to access the application after which is to use Alt + Tab, go to the window and close it. My question is how can the prompt window be fixed over the application window that when the application is selected from the Taskbar the application comes with the prompt window? (Like how it happens when I close a Word application, and it prompts me to save and when I tab to another application and back to the word the prompt is still accessible)

我如何制作来自 Document.CheckSpelling() 的提示 - 一个返回 void 的方法,一个模态提示.

How do I make the prompt that comes out of Document.CheckSpelling()- a method that returns void, a modal prompt.

代码如下:

 Microsoft.Office.Interop.Word.Application app = new     Microsoft.Office.Interop.Word.Application();
 app.Visible = false;

 object template = Missing.Value;
 object newTemplate = Missing.Value;
 object documentType = Missing.Value;
 object visible = false;
 object optional = Missing.Value;

 Microsoft.Office.Interop.Word.Document doc = app.Documents.Add(ref template, ref newTemplate, ref documentType, ref visible);

 doc.Words.First.InsertBefore(s);// s is the string containing the text
 doc.CheckSpelling(ref optional, ref optional, ref optional,
                ref optional, ref optional, ref optional, ref optional,
                ref optional, ref optional, ref optional,
                ref optional, ref optional);//This method gives the prompt window with the suggestions.

推荐答案

您的提示窗口必须是您的应用程序窗口的子窗口.如果您创建了一个窗口/或消息框或其他东西,但它没有父窗口,就会发生这种情况.找到您的应用程序的窗口句柄并将其作为父窗口/提示传递

YOur prompt window must be a child of your application window. If you create a window/ or a message box or something and it does not have a parent window, that's what would happen. FInd the window handle of your app and pass it as parent for your child window/prompt

这篇关于使用 C# 在 Windows 应用程序中修复主窗口上的提示窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆