Skype:TextControlSupport
Orders:877-462-4772
TX Text Control - word processing components.
What is this?Syndicate this content

Wintertree WSpell for TX Text Control ActiveX

This source code snippet requires TX Text Control ActiveX
Author:TX Text Control Support Department
Language:Visual Basic
Version:1.0
Released:August 06, 2004
Last modified:January 11, 2008
Requirements:TX Text Control ActiveX with Visual Basic 6.0
Download code:wspell_in_tx.zip Download [57.01 KB, ZIP]

Using the WSpell ActiveX Spelling Checker with TX Text Control

Click to enlarge

In this sample, we are going to show you how to add spell checking capabilities to your TX Text Control application, using the popular ActiveX spell checker, Wintertree WSpell

To use this sample, you need to have both of the following components (trial or full versions) installed on your PC:

  • TX Text Control ActiveX (any edition)
  • WSpell Spelling Checker ActiveX

The following sample is written for Visual Basic 6. It is however not difficult to make a few changes to get it working in Delphi or Internet Explorer, as our sample code has only been slightly modified from the shipped sample application from Wintertree.

The WSpell custom dialog uses a TextBox control, which can simply be replaced by TX Text Control. Having done that, there are only a few lines of code that need to be altered. The ReplaceWord callback method is called when WSpell wants to replace a misspelled word with a corrected one.

WSpell can only check raw text without formatting, we therefore need to be sure that the attributes of the replaced words are preserved. We do this with the following code:

  1. Private Sub WSpell1_ReplaceWord()
  2. Dim Start As Long
  3.  
  4. Start = WSpell1.WordOffset
  5.  
  6. ' Replace the misspelt word. Keep first character to preserve formatting
  7. TextControl.SelStart = WSpell1.WordOffset + 1
  8. TextControl.SelLength = Len(WSpell1.MisspelledWord) - 1
  9. TextControl.SelText = WSpell1.ReplacementWord
  10.  
  11. ' Now delete first character
  12. TextControl.SelStart = Start
  13. TextControl.SelLength = 1
  14. TextControl.SelText = ""
  15. End Sub

First of all, the the starting position of the misspelled word in the text is saved to a variable. Secondly, the word is selected in TXTextControl, but the first letter of the word is skipped. Thirdly, the selection is replaced with the new word. Finally, the first letter, which had been skipped, gets deleted.

UPDATE (July 24, 2003): The folks at Wintree Software have kindly posted a page describing the integration of WSpell in TX Text Control.

top

Top 10 Bestselling Product Award 2007Top 25 Publisher Product Award 2007Top 10 Bestselling Product Award 2007 in JapanTop 25 Bestselling Product Award 2006Top 25 Bestselling Publisher Award 2006Reader's Choice Award, dot.net magazin, 3rd place