Fog Creek Software
Discussion Board




Hyphenation Library

Can anyone recommend a hyphenation library that works with the Visual Basic RichTextBox control.  I'm looking for one that will automatically hyphenate words in the control. 

As an example, let's suppose that at the end of a line the word 'anything' is being typed.  This library would look up the word and know that it could be hyphenated as 'any-thing' therefore 'any-' would remain on the line I am typing and 'thing' would wrap to the following line.

I have found one library named 'Dashes' that may or may not suite my needs.  I have yet to inquire of them.

Any suggestions would be greatly appreciated.

Dave B.
Sunday, October 05, 2003

Is this for VB6 or VB.Net?  Getting hyphenation to work with a standard RichTextBox sounds like a difficult task.  If you're looking for word processor-like functionality, you might want to look at this one third party component instead:

http://www.textcontrol.com/

Robert Jacobson
Sunday, October 05, 2003

Thanks for your response Robert.

I may have to resort to using a control like the TX Text Control. 

The reason I am persisting with the RichTextBox control is that I need to be able to print the formatted contents using the EM_FORMATRANGE message and it's associated structures.  This allows placement of the RichTextBox's contents anywhere on the physical page.

A hyphenation library combined with full text justification would make the text stand out as being professionally formatted and would not waste space on the page.

You may use a newspaper as an example.  I don't believe you'll find too many newspapers that simply left justify the text in their columns, instead the text is fully justified and hyphenated. ( Probably using Adobe Pagemaker or QuarkExpress.  Both of which use hyphenation libraries. )

Dave B.
Monday, October 06, 2003

I am currently coding in VB6 with several C++ DLLs.

Dave B.
Monday, October 06, 2003

It sounds like a good project.  The main difficulty (apart from finding a hyphenation library) is that your code will have to detect the end of each line to decide where to insert the hyphens.  The standard RichTextBox isn't very capable of providing you with that detailed level of information. 

However, you might be able to work around this with API calls to the underlying richedit control.  The HyphenateProc function might help.  Good luck!

Robert Jacobson
Monday, October 06, 2003

One other thought... have you considered using Microsoft Word for printing your documents?  It would be rather simple to copy the RTF to the clipboard, and then use Word's automation model to paste it into a Word document, format it (including hyphenation) and print it.

Robert Jacobson
Monday, October 06, 2003

Unfortunately the customized style of the formatted page won't allow me to use MS-Word.  This is why I am forced to use the RichTextBox control to print the page.  The RichTextBox's formatting and printing capabilities are amazing, although it does take some work and time/research to understand the underlying API.  It's has actually made me think quite a bit.  I've developed a rather nifty (hierarchical) algorithm for formatting and printing the pages.  So far it works perfectly.

Thanks for the suggestion though Robert.

I might also add that the AZSpell ActiveX control from BeCubed Software seems to accomplish what I want, though I am still reviewing it.  As a bonus to auto-hyphenating in a RichTextBox control it also spell checks!  Kinda nifty if you ask me.

Two other hyphenation libraries that I haven't looked into are "Dashes" and "Proximity-Franklin".  Both of which seem to be high quality C libraries.

Dave B.
Monday, October 06, 2003

*  Recent Topics

*  Fog Creek Home