XEditor Extends RichTextBox

The RichTextBox control is a fine control, but it isn’t an editor. To make it into an editor, you’re going to have to throw away the parts that don’t fit the editor model and add new parts that give the editor enhanced editing features.

There are several ways to extend an editor that is based on a TextBox or RichTextBox control. One is to massage the text; you can search the text, parse it, or whatever. You can tack on features that make it easier to manipulate RichTextBox properties. You can also disable RichTextBox properties that are inappropriate for an editor. And finally, you can use features of the Windows RichEdit control that aren’t supported by the ActiveX RichTextBox control. What’s the ­difference?

The Windows control is the underlying window that handles messages that control the appearance and features of the window. The ActiveX control is the COM wrapper that turns those messages into properties and methods. The RichEdit Windows control is a superset of the Edit Windows control from which the TextBox ActiveX control is created. RichEdit understands the Edit messages and adds its own. You can recognize the Edit and RichEdit message constants in the Win32 help files because they have EM_ as a prefix.

The ActiveX RichTextBox control passes most of these messages on as properties. For example, EM_LIMITTEXT corresponds to the MaxLength property. But you might also notice some interesting messages that don’t correspond to Rich-TextBox properties. Why not?

ActiveX controls provide methods and properties for the most popular features or, to be more specific, for the favorite features of the Visual Basic designers. The designers seem to like a few more features in each new version. For example, the TextBox and RichTextBox controls now have a Locked property. In older versions of Visual Basic you had to fake it with the EM_SETREADONLY message. But there are plenty of other obscure and not so obscure features that haven’t yet made it into the ActiveX control.