locked
Help please with the Spell Checking API RRS feed

  • Question

  • I have a number of questions about the spell-checking API that was added in the Windows 8 SDK.

    My application is built using Visual Studio 2010 with C++ (not managed) and MFC.  It currently supports Vista or later.  I want to add spell checking using the Windows 8 SDK spell checking API.  My idea is that I will say that my app runs under Vista and Windows 7, but that the spell checking feature requires Windows 8 or later.  Is that possible?  If so, how?  To try out the spell checking API (under Windows 10), I had to use one of the following bodges in my code:

    #define MIN_NTDDI_VERSION NTDDI_WIN8
    #include “spellcheck.h”
    

    or

    #define MIN_SPELLING_NTDDI 0

    #include “spellcheck.h”


    Both bodges worked.  The first one meant ignoring a warning message.  But presumably neither of these would work if I tried to run the same code under Vista or Windows 7?  Presumably the ‘right’ way to do it would be to define NTDDI_VERSION as NTDDI_WIN8 for my whole application – is that right?  But if I did that, presumably my code would then not run at all under Vista or Windows 7?  For that matter, if I simply build using the Windows 8 SDK, does that prevent my app from running under Vista?

    Do I need to more the whole spell-checking module into a DLL?  Would even that work?

    To try out the spell checking API under Windows 10, incidentally, I followed the instructions in https://blogs.msdn.microsoft.com/vcblog/2012/03/25/using-the-windows-software-development-kit-sdk-for-windows-8-consumer-preview-with-visual-studio-2010/.

    One other question:  I used the ISpellCheckerFactory::IsSupported method to test for supported languages.  I tried using “en-gb” and “en-us” and to my surprise, both appeared to be supported.  Which languages should I expect the spelling api to support?   Is en-us always supported everywhere?  They’re not just supported because I have MS Word are they?

    I want to use the spell checking API with CRichEditCtrl.  Is there an example of how to do this anywhere?  I’d like spell checking to run in the background – any suggestions about how to go about this?  Presumably one doesn’t want to spell check an entire document (which could be very big) in one go.  It might cause unacceptable delays.  But then how should one go about it?

    Finally – if a user wants certain words to be permanently ignored, how should I handle that?  I know I can call the ISpellChecker::Ignore method, but that is for the current session only.  Would it make more sense to keep my own list of ignored words?  That seems a bit inefficient given that presumably I will ask the API to check a whole section of text, and I don’t want to have to keep ‘snipping out’ words that I know are OK?  Should I just ignore any words that it tells me about if there on my own list of words to ignore?  Is there a better way? 

    Sorry – lots of questions.  But all help very much appreciated. 


    Simon

    Monday, June 20, 2016 5:39 PM

Answers

  • If you define the build macros for Win 8 and above for the spellchecking api you should still be able to run your app on Win7 and Vista as long as you structure the code to gracefully handle COM errors such as those returned by CoCreateInstance failing to create a spellchecking object on Win7 or Vista.

    However, you should also make sure that you don't use any Win32 API that was first introduced in Win8 because that will cause your app to fail on Win 7 and below.

    • Marked as answer by simon22 Thursday, June 30, 2016 3:45 PM
    Monday, June 20, 2016 8:02 PM
  • From the documentation I surmise that the spellchecking interfaces would support whatever providers/dictionaries are installed on a given system. See https://msdn.microsoft.com/en-us/library/windows/desktop/hh869748(v=vs.85).aspx
    • Proposed as answer by Baron Bi Tuesday, June 21, 2016 10:03 AM
    • Marked as answer by Baron Bi Thursday, June 30, 2016 1:38 AM
    Tuesday, June 21, 2016 9:52 AM

All replies

  • If you define the build macros for Win 8 and above for the spellchecking api you should still be able to run your app on Win7 and Vista as long as you structure the code to gracefully handle COM errors such as those returned by CoCreateInstance failing to create a spellchecking object on Win7 or Vista.

    However, you should also make sure that you don't use any Win32 API that was first introduced in Win8 because that will cause your app to fail on Win 7 and below.

    • Marked as answer by simon22 Thursday, June 30, 2016 3:45 PM
    Monday, June 20, 2016 8:02 PM
  • Thank you. That's very helpful and good news.  You don't also know the answer to the question about supported languages do you? i.e. -

    >> Which languages should I expect the spelling api to support?   Is en-us always supported everywhere?  They’re not just supported because I have MS Word are they? <<


    Simon

    Tuesday, June 21, 2016 8:46 AM
  • From the documentation I surmise that the spellchecking interfaces would support whatever providers/dictionaries are installed on a given system. See https://msdn.microsoft.com/en-us/library/windows/desktop/hh869748(v=vs.85).aspx
    • Proposed as answer by Baron Bi Tuesday, June 21, 2016 10:03 AM
    • Marked as answer by Baron Bi Thursday, June 30, 2016 1:38 AM
    Tuesday, June 21, 2016 9:52 AM