Problem using RichView with LiveSpelling (MS Word)?
Posted: Fri Dec 15, 2006 10:12 am
Hi!
I am using spelling with TRichViewEdit. Because of customer's request I need to use MS Word speller through COM.
Now- my spellingcheck event looks something like this:
Spellchecker is object I created as a wrapper for using only spell-checking features of MS Word application.
Now- in order to make it work (since Word COM is being called from spelling thread I had to add following lines to unit which contains Spellchecker object):
Live spelling is working as a charm, but previous lines make RichViewEdit behave rather strange- sometimes it does not respond to mouse click event as it should (when you select part of text, than click anywhere in RichView it does not respond- only way you can bypass that is using keyboard). Is there a way to solve this problem?
BTW- if I comment initialization/finalization part of Spellchecker object live spelling obviously doesn't work, but RichView behaves as it should. So it's not a problem of properties assigned to RV...
LP, Primoz
I am using spelling with TRichViewEdit. Because of customer's request I need to use MS Word speller through COM.
Now- my spellingcheck event looks something like this:
Code: Select all
procedure TfmeTEXT.rveSpellingCheck(Sender: TCustomRichView;
const AWord: string; StyleNo: Integer; var Misspelled: Boolean);
var
ATemp: TStrings;
begin
if FNonVisible or not Self.Visible or (csDestroying in rve.ComponentState) then exit;
ATemp := TStringList.Create;
try
try
Misspelled := not dmMain.SpellChecker.CheckSpelling(AWord, ATemp, false, true);
except
Misspelled := false;
end;
finally
ATemp.Free;
end;
end;
Now- in order to make it work (since Word COM is being called from spelling thread I had to add following lines to unit which contains Spellchecker object):
Code: Select all
initialization
if Assigned(ComObj.CoInitializeEx) then
OleCheck(ComObj.CoInitializeEx(nil, COINIT_MULTITHREADED))
else
CoInitialize(nil)
finalization
CoUninitialize;
BTW- if I comment initialization/finalization part of Spellchecker object live spelling obviously doesn't work, but RichView behaves as it should. So it's not a problem of properties assigned to RV...
LP, Primoz