Can't get HunSpell to work C++ Builder

General TRichView support forum. Please post your questions here
Post Reply
AndyBell
Posts: 30
Joined: Thu Jul 29, 2010 11:38 am
Location: Surrey, UK

Can't get HunSpell to work C++ Builder

Post by AndyBell »

Hi

I'm using C++ Builder 11.3, TRichView 20.3

I have put the hunspelldll.dll in the in the same folder as my .exe, en_GB.dic also in that folder.

I call Speller->LoadAllDictionaries(); when my form opens. The debuggers shows it creates a TDictionary item in the TDictionaries collection.

But Speller->Check(RichViewEdit1, rvesFromStart); flags every word as wrong and offers no suggestions.

I downloaded the dictionary file from https://cgit.freedesktop.org/libreoffic ... es/tree/en (which is where the HunSpell (https://hunspell.github.io) points to. I suspect this is the error as it is full of html and other non-dictionary things. But I don't know what the format should be...

Any suggestions would be appreciated.

Andy

This is my code:

Code: Select all

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit11.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "RichView"
#pragma link "RVEdit"
#pragma link "RVScroll"
#pragma link "RVStyle"
#pragma link "RVUniscribeGrIn"
#pragma link "RVHunSpell"
#pragma resource "*.dfm"
TForm11 *Form11;
//---------------------------------------------------------------------------
__fastcall TForm11::TForm11(TComponent* Owner) : TForm(Owner) {

}
//---------------------------------------------------------------------------

void __fastcall TForm11::FormShow(TObject *Sender)
{
	Speller->LoadAllDictionaries();
}
//---------------------------------------------------------------------------

void __fastcall TForm11::Button1Click(TObject *Sender)
{
	Speller->Check(RichViewEdit1, rvesFromStart);
}
//---------------------------------------------------------------------------



standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

Re: Can't get HunSpell to work C++ Builder

Post by standay »

Andy,

I did a test app a while ago to test spelling. I found I had to have the right DLL (I used the one that came in the richview demos), and it had to be in the same folder as the exe. I used a dictionary called en_US.dic. Not sure where I got that from but it can't be one of the fancier multi language dictionary files. I use Delphi but I'll add the code I used in form create to set things up:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  RVAHunSpellInterface1.AutoCorrect(rve);
  //RVAHunSpellInterface1.
  RVAHunSpellInterface1.HunSpell.DictDir := ExtractFilePath(Application.ExeName);
  RVAHunSpellInterface1.HunSpell.DllDir := ExtractFilePath(Application.ExeName);
  RVAHunSpellInterface1.HunSpell.DllName := 'Hunspelldll';
//  RVAHunSpellInterface1.HunSpell.Dictionaries.Create(RVAHunSpellInterface1.HunSpell);
//  RVAHunSpellInterface1.HunSpell.Dictionaries.Add;
//  RVAHunSpellInterface1.HunSpell.Dictionaries[0].Load;
  RVAHunSpellInterface1.HunSpell.LoadAllDictionaries;
  RVAHunSpellInterface1.HunSpell.Active := true;
  RVAHunSpellInterface1.HunSpell.Dictionaries[0].Active := true;
  ShowMessage( RVAHunSpellInterface1.HunSpell.Dictionaries.Count.ToString );
  rve.LiveSpellingMode := rvlspOnChange;
  rve.StartLiveSpelling;
end;
Not sure if this will help but my intial attempts resulted in the same problem you are having, and by making sure the DLL and dict were correct it finally worked.

In my current app that I've been working on for some time, I use hunspell but it was a different DLL than the one that comes with the rve demo, and I coded my app to use multi- language dictionaries (dict-en.oxt). But that's a much more complex undertaking.

Stan
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Can't get HunSpell to work C++ Builder

Post by Sergey Tkachenko »

I am not sure why, but it seems that the problem happens if the project is linked with runtime packages.
I turned runtime package off, and it worked.

Here is a copy of <TRichView Dir>\ThirdParty\HunSpell\Demos\Plain\ demo for C++Builder 11:
https://www.trichview.com/support/files ... llCB11.zip
AndyBell
Posts: 30
Joined: Thu Jul 29, 2010 11:38 am
Location: Surrey, UK

Re: Can't get HunSpell to work C++ Builder

Post by AndyBell »

Thanks everyone

Unfortunately, my app requires runtime packages as it's using the free embedded NexusDB, which won't work in C++ Builder unless I'm using runtime packages :-(

Looking further through my many purchased components, I found that I could make the LMD Spell checker work with TRichView - both the dynamic checking and the generation of suggestions that I'll add to the popup menu on right-click.

I'd have to do some work to get the spell check dialog to work with it, but I don't use that in my app - just getting the red underline beneath wrongly spelt words is enough...

Andy
Sergey Tkachenko
Site Admin
Posts: 17602
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Can't get HunSpell to work C++ Builder

Post by Sergey Tkachenko »

You can try to exclude only RvHunSpellPkgD11 from the list of runtime packages.
Post Reply