WSpell ActiveX Spelling Checker |
|
Home Site index Contact us Catalog Shopping Cart Products Support Search |
|
You are here: Home > Support > WSpell > Using WSpell with TX Text Control |
|
|
Applies to: WSpell Version 5.15 and later
WSpell's TextControlHWnd and background-checking features can be used directly with TX Text Control. See the "How to check rich-text controls and TX Text Control in the background" topic in the WSpell Programmer's Guide for instructions.
TX Text Control Version 13: In order for WSpell to know how to communicate with this version of TX Text Control, it is necessary to define a mapping entry in the system registry (see Mapping text control class names). Create a string value named "TX13" (without the quotes) and set its value to "TX32". The string value must be defined in HKEY_LOCAL_MACHINE\Software\Wintertree\WSpell.
TX Text Control Version 12: (Applies to WSpell version 5.15.2 and earlier only): In order for WSpell to know how to communicate with this version of TX Text Control, it is necessary to define a mapping entry in the system registry (see Mapping text control class names). Create a string value named "TX12" (without the quotes) and set its value to "TX32". The string value must be defined in HKEY_LOCAL_MACHINE\Software\Wintertree\WSpell.
TX Text Control Version 11: Click here to download a patch file that corrects a problem in WSpell version 5.15 that prevented WSpell from working with TX Text Control Version 11.
Using WSpell with TX Text Control .NET Version 11: (Applies to WSpell version 5.15.2 and earlier only): WSpell does not recognize the window class name used by the .NET version of TX Text Control, so it does not know how to communicate with the control. However, you can define a mapping entry in the system registry (see Mapping text control class names) so WSpell will recognize the control. Create a string value named "WindowsForms10.TX11.appa" (without the quotes), and set its value to "TX32". The string value must be defined in HKEY_LOCAL_MACHINE\Software\Wintertree\WSpell.
Applies to: WSpell Version 5.14 and earlier
WSpell's TextControlHWnd feature works directly with text and rich-text controls which are part of the Windows standard controls (i.e., which are part of the Windows operating system). TX Text Control from The Imaging Source Europe does not fall into this category, so it will not work with the TextControlHWnd feature. However, it is still possible to use WSpell to check the text contained by TX Text Control, as this topic explains.
Two approaches can be used, depending on the needs of your application.
Approach 1: Using WSpell's built-in Spelling dialog box:
If you want to use WSpell's built-in spelling dialog box to interact with the user to dispose of spelling errors, follow this approach.
The approach is based on the "Check 3rd Party" demo in the WSpell examples. This demo provides a technique for checking the spelling of text contained by third-party text controls using WSpell. The technique involves obtaining the unformatted text from the control via its Text property, submitting that text to WSpell's Text property, then responding to events fired by WSpell to highlight misspelled words in the text control, replace misspelled words, etc. Usually, words are highlighted in the text control by selecting them, using the text control's SelStart and SelLength properties (or equivalent). Words in the text control are replaced by selecting them (using SelStart and SelLength), then replacing the selected text with the correct word.
This approach will in fact work with TX Text Control as is, with one minor exception: additional steps need to be taken to preserve the formatting of the word when a misspelled word is replaced. This is done in the event handler for WSpell's ReplaceWord event. The modified approach for TX Text Control does the following: 1) Select the word starting at its second letter to the end of the word; 2) Replace the selected text with the correct word; 3) Delete the first letter of the original word by selecting just that letter and replacing it with an empty string. Here is some Visual Basic code to accomplish these steps:
Private Sub WSpell1_ReplaceWord()
Dim Start As Long
Start = WSpell1.WordOffset
' Replace the misspelt word. Keep first character to preserve formatting
TextControl.SelStart = WSpell1.WordOffset + 1
TextControl.SelLength = Len(WSpell1.MisspelledWord) - 1
TextControl.SelText = WSpell1.ReplacementWord
' Now delete first character
TextControl.SelStart = Start
TextControl.SelLength = 1
TextControl.SelText = ""
End Sub
Approach 2: Using a custom spelling dialog box:
If you want to use a custom spelling dialog box to interact with the user to dispose of spelling errors, follow this approach.
The approach is based on the "Custom dialog box" demo in the WSpell examples. This demo shows how to check the spelling of text contained by a text control, and interact with the user via a dialog box of your own design and implementation. The demo is coded to work with standard edit controls/text boxes, but it can easily be modified to work with TX Text Control.
The Start method in SpellingDialogForm accepts as a parameter a reference to the TextBox object which is to be spell-checked. Modify the Start method to accept a TX Text Control object:
Public Function Start(theTextBox As TXTextControl) As Boolean
The Start method saves a private reference to the text control being spell-checked. Modify the declaration of this private reference as follows:
' Text box to check
Private checkTextBox As TXTextControl
When a misspelled word is replaced in a TX Text Control, additional steps need to be taken to preserve the formatting of the word. This is done in the event handler for WSpell's ReplaceWord event. The modified approach for TX Text Control does the following: 1) Select the word starting at its second letter to the end of the word; 2) Replace the selected text with the correct word; 3) Delete the first letter of the original word by selecting just that letter and replacing it with an empty string. Here is some Visual Basic code to accomplish these steps:
Private Sub WSpell1_ReplaceWord()
Dim Start As Long
Start = WSpell1.WordOffset
' Replace the misspelt word. Keep first character to preserve formatting
TextControl.SelStart = WSpell1.WordOffset + 1
TextControl.SelLength = Len(WSpell1.MisspelledWord) - 1
TextControl.SelText = WSpell1.ReplacementWord
' Now delete first character
TextControl.SelStart = Start
TextControl.SelLength = 1
TextControl.SelText = ""
End Sub
|
Home Site index Contact us Catalog Shopping Cart Products Support Search |
|
Copyright © 2015 Wintertree Software Inc. |