Customized dictionaries and thesaurus files in VSSPELL
So, another week has gone by and you have had a little more time to play with VSSPELL. How are you coming along? Did you know that VSSPELL offers a powerful utility that allows you to create custom-built dictionaries and thesaurus files that you may distribute with your application? At design-time, building a custom dictionary (or thesaurus) is as simple as launching the included DictUtil.exe utility (ThesUtil.exe, respectively) and "dumping" the specified dictionary file (.DCT) into a text file with a single button click.
Then once in the .TXT format, you may open and edit the file with any word processing editor to build up to five different custom libraries. The Dictionary Utility allows you to set read-only or read/write permissions to any dictionary file you create with the simple selection of a checkbox, allowing your end-users to add new words (or not) to your dictionary. Once you are finished modifying the .TXT file, you can use the Utility to convert it back to the .DCT format and distribute it with your application. Customized dictionaries and thesaurus files are particularly helpful for words and phrases specific to certain industries. So those of you who having been asking about getting you legal and medical dictionaries to work in TX Text Control should have no trouble at all.
Perhaps you would be willing to tell the rest of the world about your experiences? Don't forget that you can discuss your experiences with other TX Text Control Users on the TX Discussion Forum.
Top TX Tip: Adding Headers/Footers to your Document
With version 7 of TX Text Control the possibility of adding headers and footers to your documents has been implemented. A new kind of marked text field has also been added - the page number field. It is inserted in a header or footer and automatically displays the current page number. Some users mentioned that they would prefer a footer that also displays the total number of pages ("Page X of Y"), but they don't know how to realize that because there is no special field.
The following example shows how to display the total number of pages in your footer:
Have a look at the headers example and add a menu item. Add the following code to the click event:
Private Sub mnuPageNo_Click()
.Text = "Page: of "
.SelStart = Len("Page: ")
.FieldType(.FieldCurrent) = txFieldPageNumber
.SelStart = Len("Page: x of ")
fieldNo = .FieldCurrent
noPages = .CurrentPages
.FieldText = Str(noPages)
Add two global variables called noPages and fieldNo. Initialize noPages with -1.
Finally, add the following code to the TX's OnChange event:
Private Sub TXTextControl1_Change()
If (noPage <> -1) And (TXTextControl1.CurrentPages <> noPages) Then
noPages = TXTextControl1.CurrentPages
TXTextControl1.FieldCurrent = fieldNo
TXTextControl1.FieldText = Str(noPages)
The code above is very short and as the Delphi Headers example matches the VB one almost word-by-word, you should be able to port the above code to Delphi on your own.
What does the code do?
First of all, you need to insert a header. The code assumes that a header has already been inserted, so there might be some need for error checking. Also, some users might want to add the "page x of y" line to the footer and not to the header. Simply replace txHeader with txFooter then. Now let's take a look at the page number menu handler:
The first line set the text of the header to "Page: of ". Then a page number field is inserted between "Page: " and " Of". Finally, a usual field is inserted at the end of the line. Its text is set to the number of currently inserted pages. Now, when the contents of the TX change, we need to check if the number of pages has changed as well. This is done in the OnChange handler. If the number of pages is not equal to our variable noPages, a page has just been inserted. So, change the field in the header and update noPages. And that's all there is to it!
Errata to last week's newsletter
As several of you have mentioned, in the newsletter last week, there was an important link which did not work in Microsoft Internet Explorer. As 80% of you use MSIE, very few of you were able to get the intended web content, as all you saw when you clicked on the links was a MSIE 404 file not found error. Here is the revised link for the sample TX application page.
Sorry for the inconvenience.
Project Analyzer makes your code shine
What if you could automatically optimize, document and measure your source code? Or graphically browse through the code that your colleagues wrote? Now you can. Project Analyzer is a complete code review and quality control tool for Visual Basic. Get rid of unused code and turn your source into HTML in a minute. Free demo.
The Newsletter Team