Text boxes are controls containing text. They are often employed to allow the user to enter text but can be set to be read-only with the effect that the text can only be changed under program control.
The following are standard text box controls: TextBox, Text_Box, RichTextBox and RichText_Box. The Int32_Box and Double_Box are specialised text boxes that contain numeric filtering with the result that the user is only allowed to enter valid numbers.
You can establish a connection between the text in a text box and a Fortran character string in one of two ways: a) by using vcLinkText@ (possibly with vcRefreshText@) or b) by using vcGetText@ with vcSetText@. The first of these approaches creates a continuous link between the control and a Fortran variable. In this context linking causes changes in the control to be reflected in the Fortran variable whilst refreshing causes changes in the Fortran variable to be reflected in the control. vcLinkText@ should not be used with multi-line controls because of the associated overhead.
In addition, the following functions are of special interest for text boxes.
vcAppendLine@ |
Appends a line of text with a line feed to the end of a text control. |
vcAppendText@ |
Appends text to the end of a text control. |
vcClear@ |
Clears a control. |
vcFindText@ |
Finds a given string. |
vcGetText@ |
Gets all of the text or used with a line index to get a line of text from a control. |
vcLoadText@ |
Displays text from a file in a control. |
vcPrintText@ |
Prints all the text in a control. |
vcReplaceText@ |
Replaces the current selection with a given string. |
vcSaveText@ |
Save the text in a control to a file. |
vcSetText@ |
Sets all of the text or used with a line index to set a line of text in a control. |
A text box can be filled with text in the design view of the form. Alternatively you can use vcAppendLine@ to add lines dynamically at run time. vcLoadText@ is used to read in a file.
If you use a text box as a text editor then it is important to note the limitations of these controls. A TextBox (Text_Box) uses plain monochrome text and is limited to the number of characters specified in the MaxLength property (set this to zero to remove the limit). A RichTextBox (RichText_Box) uses formatted text and is not limited in size. However, a RichTextBox of modest size will take an excessively long time to load from a file. There are other limitations, details of which will be found in the documentation for each function.
The following standard callbacks are of special interest for text boxes.
Cut |
Cuts the selection to the clipboard. |
Copy |
Copies the selection to the clipboard. |
Paste |
Pastes the clipboard into the text. |
Delete |
Deletes the current selection. |
SelectAll |
Selects all the text. |
Undo |
Undo the last operation. |
Redo |
Redoes the last undo for rich text. |
WordWrap |
Toggles the word wrap property. |
Font |
Opens the common font dialog and sets the global font. |
Bold |
Sets a rich text selection to bold font. |
Italic |
Sets a rich text selection to italic font. |
Underline |
Sets a rich text selection to underline font. |
Strikeout |
Sets a rich text selection to strikeout font. |
Solution10 and Solution11 in the demonstration pack contain text editors.