Using an ActiveX spell checking control
ActiveX controls
can be used to spell check text in a RichTextEdit control. The supported
ActiveX spell checking controls include VSSpell from ComponentOne
and WSpell from Wintertree Software.
You can use the SelectedStartPos and SelectedTextLength properties
of the RichTextEdit control to highlight the current position of
a misspelled word in a text string that you are parsing with a supported
ActiveX spell checking control. The following procedure uses an
ActiveX control to spell check the entire text of the current band
of a RichTextEdit control.
To spell check selected text in a RichTextEdit
control:
-
On a window with a RichTextEdit control,
select Insert>Control>OLE from the window menu. -
Click the Insert Control tab of the Insert Object
dialog box, select the installed ActiveX spell checking control,
and click OK. -
Click inside the window in the Window painter
to insert the ActiveX control.By default, the name of the inserted control is ole_n,
where n = 1 when there are no other
OLE controls on the window. -
Add a menu item to a menu that you associate with
the current window and change its Text label toCheck
.
Spelling -
Add the following code the the Clicked event of
the menu item, where windowName is the name
of the window containing the RichTextEdit and ActiveX controls:1string ls_selected1//get the current band context, and leave select mode1<span>windowName</span>.rte_1.selecttext(0,0,0,0)1<span>windowName</span>.rte_1.SelectTextAll()1ls_selected = <span>windowName</span>.rte_1.SelectedText()1<span>windowName</span>.rte_1.SelectedTextLength = 01//assign the string content to the ActiveX control1<span>windowName</span>.ole_1.object.text = ls_selected1<span>windowName</span>.ole_1.object.start() -
Select the ActiveX control in the Window painter
and select ReplaceWord from the event list for the control. -
Add the following code to the ReplaceWord event
script:1string str1str = this.object.MisspelledWord1rte_1.SelectedStartPos = this.object.WordOffset1rte_1.SelectedTextLength = Len(str)1rte_1.ReplaceText(this.object.ReplacementWord)1messagebox("misspelled word", "replaced")The next time you run the application, you can click the Check
Spelling menu item to spell check the entire contents of the current
band of the RichTextEdit control.