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 to Check Spelling. -
Add the following code to the Clicked event of the menu item,
where windowName is the name of the window containing the
RichTextEdit and ActiveX controls:123456789string ls_selected//get the current band context, and leave select modewindowName.rte_1.selecttext(0,0,0,0)windowName.rte_1.SelectTextAll()ls_selected = windowName.rte_1.SelectedText()windowName.rte_1.SelectedTextLength = 0//assign the string content to the ActiveX controlwindowName.ole_1.object.text = ls_selectedwindowName.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:
123456string strstr = this.object.MisspelledWordrte_1.SelectedStartPos = this.object.WordOffsetrte_1.SelectedTextLength = Len(str)rte_1.ReplaceText(this.object.ReplacementWord)messagebox("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.