MultiText VBX v1.18

MultiText VBX (mtext.vbx) is a text box capable of displaying up to 32K of text using different fonts, font styles, and colors. Hypertext words may be embedded, and will cause an event to occur if clicked upon, as well as altering the cursor to a hand whilst over them. Portions of text may be selected with the cursor and copied to the clipboard, either as straight text or with formatting codes included. Text may be entered either by setting a property, or by directly loading text from within files.

One application for MultiText is to display text of a mathematical or scientific bias. The font can be switched at any point to include Greek characters from the symbol font, and can also include super- and sub-script text, as well as fractions.

Contents

Text formatting

Hypertext

Properties

Methods

Events

Distribution

Registration


Text formatting

All of the features which alter how the text is displayed inside MultiText are set by embedding escape codes. This escape code is by default the open square bracket, but this may be altered by changing the SpecialChar property. After the escape code is a single character which instructs MultiText how to display the text which follows. To actually display the escape character, use one after the other, i.e. [[.

For instance to change the text to bold at a certain position would just require inserting [B . All text that follows will now be bold until [b is next encountered, where the bold text is turned off.

For a list of the escape codes, select on the category list that follows:

Fonts

Font styles

Colors

Special


Text formatting : Fonts

The letters on the left below should be placed after the escape character (default open square bracket) to change the font to that stated to the right.

A	Arial

C	Courier

N	Courier New

F	Fixedsys

M	Modern

E	MS Sans Serif

e	MS Serif

R	Roman

P	Script

L	Small Fonts

Y	Symbol

Z	System

T	Terminal

t	Times New Roman

W	Wingdings


Text formatting : Font styles

The letters on the left below should be placed after the escape character (default open square bracket) to change the font style to that stated to the right.

B	Bold on.

b	Bold off.

I	Italic on.

i	Italic off.

S	Strikethru on.

s	Strikethru off.

U	Underlining on.

u	Underlining off.


Text formatting : Colors

The letters on the left below should be placed after the escape character (default open square bracket) to change the color to that stated to the right. System default colors may be used.

0	ForeColor0 property, default &H000000& (black).

1	ForeColor1 property, default &H0000FF& (red).

2	ForeColor2 property, default &HFF0000& (dark blue).

3	ForeColor3 property, default &H00FF00& (light green).

4	ForeColor4 property, default &HFF00FF& (purple).

5	ForeColor5 property, default &HFFFF00& (light blue).

6.	ForeColor6 property, default &H00FFFF& (yellow).

7	ForeColor7 property, default &H808080& (grey).

8	ForeColor8 property, default &H008000& (dark green).

9	ForeColor9 property, default &HFFFFFF& (white).


Text formatting : Special

Superscript text can be started by following the escape character with a D. To turn this off use the d character.

Subscript text can be started by following the escape character with a G. To turn this off use the d character.

Fractions can be displayed in proper form, by use of the f character after the escape code. For instance to display 1/3 the notation would be

[f1/3

Note: Within the content of the fraction, other escape characters will cause unpredictable results and should not be used.

To turn the font, font style, and font color back to normal, use the q character after the escape code.


Hypertext

Within the text displayed, words may be tagged as hotspots. As the cursor is moved over these, the appearance of the cursor will change to a hand. By clicking with the left mouse button whilst over a hotspot, a hot event will be caused, which passes back the index number of the word and the actual word itself.

To mark a word as a hotspot, insert an escape code (default open square bracket) followed by a g. The word that follows is now a hotspot.

The end of the word is either a space, or another escape character. The hotspot word will look no different from the rest of the text, but by inserting escape codes before and after the word it is possible to change the color, style, or actual font of the hotspot word.

Note: The maximum number of hotspots that can be embedded in the text is 100, and any more that this will be ignored. It is recommended that the HilightEnabled property be set to false when using hotspots, as a faster event will occur when clicked upon.


Properties

Standard properties are BackColor, Borderstyle, DragIcon, DragMode, Enabled, FontName, FontSize, Height, Index, Left, Mousepointer, Name, Scrollbar, TabIndex, Tag, Top, Visible, Width.

Note: FontSize is the height of the character cell in pixels and not point sizes, thus the values will need to be higher than their corresponding point size. If the mousepointer property is set to anything other that 0-Default then the cursor will not change to a hand when over a hotspot.

Custom properties are:

BoxLines

This read-only, run-time property contains the maximum number of lines of text that will be seen in the MultiText window using the current fontsize.

ForeColor0 - ForeColor9

These correspond to the escape codes 0 to 9, as detailed in the text formatting topic.

Highlight

This color property represents the background color of the selected region of text. The default is the system setting.

HilightEnabled

This Boolean flag either enables or disables the selecting of text with the mouse. It is recommended that this is set to false if the feature is not required.

HiTextColor

This color property represents that color of text that is within a selected region. The default is the system setting

Lines

This run-time, read-only property contains the number of lines of text.

LoadLength

This numeric long value contains the number of characters to be read in from file during a LoadFile method. If set to 0 then the file will be read in to the end, up to a maximum of 32760 characters.

LoadStart

This numeric long value contains the start position within a file to be read in using the LoadFile method. If set to 0 then loading will resume from the beginning of the file.

NumHots

This run-time, read-only property contains the number of hotspots in the text.

ScrollMax

This run-time, read-only property contains the maximum value for the scroll position, regardless of whether a scroll bar is actually visible.

ScrollPos

This run-time value contains the current scroll position. Changing it will cause the scrollbar to change to the new position.

SpecialChar

This property contains the ANSI character code for the escape character. By default this is 91 which represents the open square bracket.

Text

This contains the actual text, with embedded format codes, that will be shown in the MultiText window.


Methods

Below are the methods applicable to MultiText at run time.

Copy

By setting to TRUE, the selected region of text will be copied into the clipboard.

CopyFormat

By setting to TRUE, the selected region of text, along with any formatting codes within that region, are copied to the clipboard.

LoadFile

By setting this to the full name of a file, the text property will be replaced by the contents of the file. Characters are read in from position LoadStart, and LoadLength characters are read in. If LoadLength is set to 0 then all characters up the end of the file are loaded, up to a maximum of 32760.

ScrollDown

By setting to TRUE the text will scroll down one line. This will occur even if the scrollbar property is set to false.

ScrollUp

By setting to TRUE the text will scroll up one line. Thus will occur even if the scrollbar property is set to false.


Events

The standard events are Click, DblClick, DragDrop, DragOver, MouseDown, MouseMove, and MouseUp.

One custom event exists :

Hot

This event is fired when the user clicks upon a hotspot. Two parameters are passed back. HotIndex is an integer and contains the hotspot number. The first hotspot word in the text is 0, the next is 1 etc. HotWord contains the actual word pressed (or the first 150 characters of it).


Distribution

If MultiText is to be distributed as part of an application then the file MTEXTRT.VBX must be used, but it must be renamed to MTEXT.VBX on the distribution disk.

Under no circumstances may the design time version be distributed within an application. However, the design time version may be distributed as shareware so long as the accompanying files are distributed with it.

Only registered users of MultiText may distribute the run time version with their applications, or use it commercially. The run time version is only available to registered users.


Registration

To be able to distribute MultiText with your applications, or to use it commercially, you must first register. Once registered you will receive the run time version which may be distributed by you in your applications, with no restrictions on the volume sold.

The cost of registering for MultiText is 15 United Kingdom pounds or 25 United States dollars, made payable to Steve Bannister. Please state if you would prefer to receive your copy on disk or sent by e-mail. If you decide on e-mail, you will get a faster reply and will qualify for free upgrades as they are made.

I can also upload the files using FTP if you have a site running an FTP daemon, although I will not upload to an anonymous FTP site.

Please send your cheques or international money orders, and details on which method you would like to receive the files, to :

Steve Bannister

41 Milton Street

Northampton

NN2 7JG

ENGLAND

If you have any queries/comments/bug-reports you can also e-mail me at

s.bannister@open.ac.uk