0

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

Steps in replicating the issue:

  1. Clicked on the spell check feature.
  2. Tabbed to another application before the spell check prompt appeared.
  3. On coming back, the application is unresponsive as the spell check window has gone out of focus.

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)

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

Here's the code:

 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.
  • Possible duplicate of [How do I make a form modal in Windows Forms?](http://stackoverflow.com/questions/2503079/how-do-i-make-a-form-modal-in-windows-forms) – Esko Dec 20 '16 at 06:04
  • How?! I am not getting how to control the prompt hat comes up from a method returning void. – Tryphena S. Augustine Dec 20 '16 at 06:07

1 Answers1

0

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

dgorti
  • 1,130
  • 2
  • 12
  • 22
  • Here I am stymied. After the execution of this particular line 'Microsoft.Interop.Word.Document.CheckSpelling(ref Object CustomDictionary, ref Object IgnoreUppercase, ref Object AlwaysSuggest,ref Object CustomDictionary2,ref Object CustomDictionary3, ref Object CustomDictionary4, ref Object CustomDictionary5, ref Object CustomDictionary6, ref Object CustomDictionary7, ref Object CustomDictionary8, ref Object CustomDictionary9, ref Object CustomDictionary10 )' the propmt appears. Now how do I set parent-child association? – Tryphena S. Augustine Dec 20 '16 at 06:02
  • Ah! I don't understand exactly what the code is doing or what the application is checking/invoking the spell checker. May be you can explain this a bit better. Sorry it was not very clear from your post – dgorti Dec 20 '16 at 06:54