TX Text Control ActiveX Programmer's Guide

Welcome to TX Text Control, the text processor in a single ActiveX control. Using TX Text Control, you can create all kinds of text-based applications with the ease of programming that is characteristic of Visual Basic and with highly sophisticated formatting and display capabilities which are normally the exclusive domain of large word processing packages.

As an aid to help you locate the information that interests you most, the following section lists and describes the main areas of the documentation.

Introduction

Provides information about the system reqirements you need, how to distribute your applications and how to obtain technical support.

What's New

The chapter discusses the new features introduced in the last TX Text Control releases.

Visual Basic User's Guide

Describes how to use TX Text Control with Microsoft Visual Basic.

Internet Explorer User's Guide

This chapter describes how to use TX Text Control with the Microsoft Internet Explorer.

ASP User's Guide

Demonstrates the usage of the TX Text Control features in the Microsoft Internet Information Server with ASP.

Delphi User's Guide

Shows you how to install and use TX Text Control with Borland Delphi.

Technical Articles

This chapter contains several technical articles, giving you an overview of TX Text Control's properties, methods and events working together.

Programmming Overview

This part contains an overview of TX Text Control's properties, methods and events sorted by programming categories, lists all used data types and contains a reference of the mouse- and keyboard interface.

Reference

Contains a complete reference of all properties, methods and events provided through the implemented TX Text Control controls and objects. All properties, methods and events are sorted in alphabetical order.


Introduction

Provides information about the system reqirements you need, how to distribute your applications and how to obtain technical support.

System Requirements
Distributing your Applications
Installing TX Text Control on a Server
How to Obtain Support
Legal Notice


System Requirements

The TX Text Control ActiveX requires one of the following Windows versions:

  • Windows 95
  • Windows 98
  • Windows ME
  • Windows NT 4.0
  • Windows 2000
  • Windows XP.

The TX Text Control ActiveX supports the following development enviroments or scripting engines:

  • Microsoft Visual Basic 4.0, 5.0, 6.0
  • Borland Delphi 4.0, 5.0, 6.0, 7.0
  • Microsoft Internet Explorer 5.0 or higher
  • Microsoft Internet Information Server 5.0, 5.1, 6.0

Furthermore, TX Text Control can be used with other development platforms which support ActiveX controls. To learn to which extent TX Text Control is supported by these development platforms, please contact the support department.


Distributing your Applications

If you create a setup program for your VB application with the Package and Deployment Wizard that is part of Visual Basic 6, all redistributable files will be included automatically.

In case you wish to use a different setup toolkit or install TX Text Control on a server, the lists below shows all the files necessary for Text Control to operate properly. You must ensure that the files exist on your client's machine and they are the proper version. If your client's machine has older versions of these files, you should update them.

Group 1: TX Text Control core files:

  • tx4ole12.ocx
  • tx12.dll
  • tx12_tls.dll
  • tx12_wnd.dll
  • tx12_obj.dll
  • tx12_ic.dll
  • tx12_ic.ini

Group 2: TX Text Control text and image filters:

  • tx12_bmp.flt
  • tx12_tif.flt
  • tx12_wmf.flt
  • tx12_jpg.flt
  • tx12_png.flt
  • tx12_gif.flt
  • tx12_rtf.dll
  • tx12_htm.dll
  • tx12_doc.dll
  • tx12_xml.dll
  • tx12_css.dll
  • tx12_pdf.dll

Group 3: Microsoft foundation class library:

  • MFC42.DLL (6.00.8447.0)
  • MSVCRT.DLL (6.00.8397.0)

Group 4: Microsoft XML parser:

  • MSXML3.DLL (8.00.7820.0)
  • MSXML3A.DLL (8.00.7820.0)
  • MSXML3R.DLL (8.00.7820.0)

The files listed in the first and second group are the TX Text Control DLL files. All of these files can be found in the \bin subdirectory of your TX Text Control installation directory. They must all be installed in the same directory and you must always install all of them. The first file is the Text Control ActiveX server containing the ActiveX controls. These controls must be registered in the registration database on your client's machine.

You should also verify that the Microsoft foundation class library files (group 3) are installed on your client's computer. These files must be installed in the Windows system directory. Please refer to Microsoft's redistribution policy if you need to redistribute them.

The files listed in the last group (group 4) contain the Microsoft XML parser and are necessary to use Text Control's XML features. These files must be installed in the Windows system directory. Please refer to Microsoft's redistribution policy if you need to redistribute them.

The following files must be registered in the registration database on your client's machine:

  • tx4ole12.ocx
  • MFC42.DLL
  • MSXML3.DLL

To register the Text Control ActiveX on a server the command line tool txregsvr.exe must be used as described in the next section.


Installing TX Text Control on a Server

Internet Information Server (IIS) needs to be installed in order to run TX Text Control in server mode. It can be run on a dedicated server, or by simply activating IIS on the developer's computer. This way, a server application can be developed and tested on the same computer, without requiring access to a seperate server.

At some point an application most likely is to be transfered to a 'real', dedicated server. The following steps are required to transfer your TX Text Control license to that server.

Note that the license agreement entitles you to have TX Text Control installed on your local computer and a single server at the same time, so that you may continue maintaining your application with a local copy of TX Text Control.

  • Copy the required files as listed in the table in Distributing your Applications from your local computer to a single directory on the server. The files are located in the \bin subdirectory of your Text Control installation.
  • Copy txregsvr.exe from Text Control's \tools subdirectory to the a directory on the server
  • On the server, run txregsvr.exe. Txregsvr is a command line tool which creates the registry keys required for Text Control to run on a server. It accepts two parameters, which are the filename and path of the Text Control ActiveX file, and your serial number. Running txregsvr.exe without a parameter displays usage information.
  • Remove txregsvr.exe from the server. Please note that txregsvr.exe is not a redistributable file, and therefore must not be kept on the server.


How to Obtain Support

Every registered and free trial version user can benefit from our free, technical support.

Our support team provides several information sources for technical details. A good starting point for getting information is the TX Text Control Support Forum. Here you can post your problems and discuss it with our support staff and other experienced TX Text Control users.

If you are searching for further samples, then please have a look at the Source Code Library. This library has additional samples that are not provided in this release and is updated with new samples frequently.

If you would like to contact us via e-mail, we would be very obliged if you would use the Support Form.

We understand that there are some support cases where a one-to-one talk can solve some programming problem much quicker than endless e-mails. Therefore, the support hot line is open from 10am to 1pm EST (16:00 to 19:00 CET).

Our customer services representatives and support agents speak English and German and are available to assist with all your sales and technical queries.

Contact Information

Mail and FAX contact
The Imaging Source Europe GmbH

Sommerstrasse 36

D-28215 Bremen Germany

Fax: +49 421 335 9180

Telephone contact |
Support Germany | +49 421 335 910 (10am to 1pm EST, 16:00 to 19:00 CET)
Sales Germany | +49 421 335 910
Sales USA | +1 704 341 8311

E-Mail contact |
Support | For all support enquires.
Sales | For product or pre- or post sales enquiries.
Press | For journalists/analysts looking for company info.
General information | For all further general information.


Legal Notice

Information in this document is subject to change without notice and does not represent a commitment on the part of The Imaging Source Europe GmbH. The Software described in this document is furnished under a license agreement. The Software may only be used or copied in accordance with the terms of this agreement.

Copyright 1991-2005 The Imaging Source Europe GmbH. All rights reserved.

Microsoft, Windows, ActiveX, Visual Basic, Visual C++, Developer Studio are either registered trademarks or trademarks of Microsoft Corporation in the USA and/or other countries.

Borland, Delphi are Trademarks of Borland Software Corporation.

The names of actual companies and products mentioned herein may be the trademarks of their respective owners.


What's New

The chapter discusses the new features introduced in the last TX Text Control releases.

What's New in Version 12.0 since Version 11.0
What's New in Version 11.0 since Version 10.1


What's New in Version 12.0 since Version 11.0

The following provides a general list of features that have been added since TX Text Control version 11.0.

New Features and Update Notes
New Properties, Methods and Events


New Features and Update Notes
TX Text Control 12.0 provides the several new features all described in the following tables.

New Features
Feature | Description
Anchored Images In prior versions of TX Text Control images and OLE objects can either be inserted like a single character or geometrically positioned relative to the complete document. Now a third method is supported that is called 'anchored to a paragraph'. This means that the text still flows around the image or OLE object but the geometrical position is relative to the paragraph to which it is anchored. If other text is inserted in front of this paragraph the object is moved with the text. The new methods ImageInsert and ObjectInsert have been implemented to insert such an image or OLE object in the text. All properties that deal with images and OLE object have been enhanced so that the programmer can manipulate anchored images and OLE objects.
Text Frames TX Text Control now supports text frames. A text frame is a rectangle that can be filled with text by an end-user and that can be edited like the main text. A text frame can be positioned like an image, either geometrically or as a single character. Geometrically its position can either be relative to a paragraph to which it is anchored or relative to a document's page. Three methods have been implemented to insert text frames: TextFrameInsert inserts a text frame that is anchored to a paragraph and that is moved with the text. TextFrameInsertAsChar inserts a textframe that is handled in the document like a single character and TextFrameInsertFixed inserts a text frame that is aligned at a fixed page position. A text frame is fully programable from program code. Every Text Control property or method can be routed to a text frame. The new method TextFrameSelect determines whether a certain Text Control property manipulates a text frame or the main text. Further properties set text frame attributes like the width of the border line, internal margins and the background color.
Image and Text Frame Attributes A new built-in dialog box has been added to allow attributes of images and text frames to be changed. It can be used to set general attributes like size, text wrapping, scaling and text distances. Furthermore, it has a special tab to set filename, format, resolution and compression for image export, and a special tab to set background color and frame attributes for text frames. The new ObjectAttrDialog method opens this dialog.
Image and Text Frame Mouse Interface A new mouse interface for integrated objects like images and text frames is available. Objects can be moved and sized in every insertion mode. A selection frame with size handles shows the current selection state.
Table Formatting Additional features have been added to give end-users more control of how tables are formatted at page breaks. A forced page break can be inserted in a table at each character position using the CTRL+ENTER key combination. This moves the complete table row to the next page. Additionally, a table row can receive a new formatting attribute determining that the complete row is moved to the next page, if at least one line of text is on the next page. Furthermore, a height can be specified which is the table row's minimum height. If more text is inserted, the height grows as necessary. All of these features can be set with the built-in dialog box for setting table attributes and through code using the TableCellAttribute property.

Update Notes
Property/Method/Event | Update Note
ObjectCurrent Property Has been extended to support text frames, and anchored images and OLE objects.
ObjectNext Property Has been extended to support text frames, and anchored images and OLE objects.


New Properties, Methods and Events
In TX Text Control 12.0 the following new properties, methods and events have been added:

Properties
Property | Description
TXTextControl.HeaderFooterAtInputPos Returns which header or footer owns the current text input position.
TXTextControl.ObjectHeight Returns or sets the natural height, in twips, of an image, text frame or OLE object.
TXTextControl.ObjectWidth Returns or sets the natural width, in twips, of an image, text frame or OLE object.
TXTextControl.TextFrameBackColor Returns or sets the background color of a text frame.
TXTextControl.TextFrameBorderWidth Specifies the width, in twips, of a text frame's border line.
TXTextControl.TextFrameInternalMargin Specifies the distance (in twips) between a text frame's border line and the text.
TXTextControl.TextFrameMarkerLines This property determines whether or not marker lines for text frames are visible.

Methods
Method | Description
TXTextControl.ImageInsert This method inserts a new image anchored to a paragraph.
TXTextControl.ImageInsertAsChar This method inserts a new image which is then handled like a single character in the text.
TXTextControl.ImageInsertFixed This method inserts a new image at a fixed geometrical position.
TXTextControl.ObjectAttrDialog This method invokes the built-in dialog box for setting attributes of images, text frames and OLE objects.
TXTextControl.ObjectGetSelected This method returns the identifier of the currently selected object.
TXTextControl.ObjectInsert This method inserts a new OLE object or other control anchored to a paragraph.
TXTextControl.TextFrameInsert This method inserts a new text frame anchored to a paragraph.
TXTextControl.TextFrameInsertAsChar This method inserts a new text frame, which is then handled as a single character in the text.
TXTextControl.TextFrameInsertFixed This method inserts a new text frame at a fixed geometrical position.
TXTextControl.TextFrameSelect This method determines whether a certain Text Control property or method manipulates a text frame or the main text.

Events
Event | Description
TXTextControl.ObjectRightClicked Occurs when an object has been clicked on with the right mouse button.
TXTextControl.TextFrameActivated Occurs when a text frame has obtained the input focus.
TXTextControl.TextFrameDeactivated Occurs when a text frame has lost the input focus.


What's New in Version 11.0 since Version 10.1

The following provides a general list of features that have been added since TX Text Control version 10.1.

New Features and Update Notes
New Properties, Methods and Events


New Features and Update Notes
TX Text Control 11.0 provides the several new features all described in the following tables.

New Features
Feature | Description
Nested Tables A table can be inserted within another table. Such a table is called a nested table. The level of nesting is not limited. All of Text Control's text filters have been expanded to import and export nested tables. To refer to a nested table, the same properties and methods can be used as for top-level tables. The TXTextControl.TableNext property lists all top-level and all nested tables in the order they appear in the text flow. Other properties and methods have been added to get a table's nesting level or to get its outer or outermost table.
Table Splitting A table can be split below or above the table row containing the current input position with the TXTextControl.TableSplit method. If the original table has an identifier, both parts retain their identifier. A TXTextControl.TableCreated event occurs for the bottom part to enable the application to change the identifier of the bottom part. If a table is split above the first row, a new line is inserted above the table, and if a table is split below the last row, a new line is inserted below the table. This is useful to insert text above or below a nested table that immediately starts and/or ends at the beginning or the end of the cell in which it is nested.
Multiple Undo Text Control has a new undo buffer that supports multiple undo and redo operations. Additionally, the undo buffer now supports many more Text Control features such as images, text fields and all table operations. The new methods TXTextControl.StartUndoAction and TXTextControl.EndUndoAction can bundle more than one property call to a single undo action. The new TXTextControl.AllowUndo property activates or deactivates the undo buffer. Deactivating the undo buffer saves time and memory which can be useful, if a Text Control for example is deployed as a report generator.
Image Resolution and Compression Quality If images are embedded in a document with their complete binary data, it can be useful to alter an image's resolution and the quality of the data compression algorithm to minimize the file size. By default, Text Control uses the image's default resolution and a default value for the data compression. The txImageCompressionQuality and txImageMaxResolution settings of the TXTextControl.LoadSaveAttribute property can be used to alter these values for all images in the complete document. The TXTextControl.ImageExportCompressionQuality and TXTextControl.ImageExportMaxResolution properties can be used to overwrite these values for a single image.
PDF Document Security New parts of the LoadSaveAttribute property allow the setting of the standard PDF security features. Both passwords can be set: a user password to allow document opening and a master password to allow modification of the current access permissions. Furthermore, the txDocAccessPermissions part allows individual access permissions to be set.
Ruler Bar Design The Ruler Bar Control has an additional look with a flat design. This new look is now the default setting, but the previous look can still be set with the new Appearance property.

Update Notes
Property/Method/Event | Update Note
CanRedo Property Has been extended with additional values to indicate the action that can be redone.
CanUndo Property Has been extended with additional values to indicate the action that can be undone.
LoadSaveAttribute Property Has been extended with the following parts: txDocAccessPermissions, txMasterPassword, txUserPassword, txImageCompressionQuality, txImageMaxResolution.


New Properties, Methods and Events
In TX Text Control 11.0 the following new properties, methods and events have been added:

Properties
Property | Description
TXTextControl.AllowUndo Determines whether the undo buffer is active or not.
TXTextControl.ImageExportCompressionQuality Determines a value between 1 and 100, which is the quality of a lossy data compression used, if the image is saved.
TXTextControl.ImageExportMaxResolution Determines the maximum resolution in dots per inch used, if the image is saved.
TXTextControl.TableCanSplit Checks whether a table can be split.
TXTextControl.TableNestedLevel Gets the nested level for the specified table.

Methods
Method | Description
TXTextControl.EndUndoAction Defines the end of an undo action.
TXTextControl.StartUndoAction Defines the beginning of an undo action.
TXTextControl.TableGetOuter This method returns a table's outer table.
TXTextControl.TableGetOuterMost This method returns a table's outermost table.
TXTextControl.TableSplit Splits a table below or above the current input position.


Visual Basic User's Guide

Describes how to use TX Text Control with Microsoft Visual Basic.

Creating a Simple Word Processor
Working with Files
Printing
Using Marked Text Fields
A Word Processor
Connecting to Databases
Using Images
Using Text Frames
Mail Merge
Quote Generator - An Office Application
Headers and Footers
Hypertext Links
Drag and Drop
Report Designer - An Advanced Example
XML Basics
Editing in XML Mode
Quote Generator - XML Version
Using Multiple Controls
A Forms Filler


Creating a Simple Word Processor

This chapter shows you how to create a small word processor from scratch with just a few lines of code. It will be able to load and save files, use the clipboard, and will have dialog boxes for character and paragraph formatting, a ruler bar, a status bar and full keyboard and mouse interface.

The source code for this example is contained in the Samples\vb6\Simple sample source directory.

Creating the Project
Creating the Controls
Connecting the Controls
Running the Program
Setting the Page View
Resizing the Controls
Adding a Menu
What Comes Next


Creating the Project

Assuming that you have already run the Text Control installation program and started Visual Basic, the next step is to create a project for the text processor. To do this begin by selecting the New Project command from the file menu. Then use the Tools / Custom Controls... command to include the file tx4ole11.ocx into the new project. You will see four additional icons appear at the bottom of the toolbox, representing the Text Control and its Status Bar, Button Bar and Ruler Bar:

The Text Control Icon

The Status Bar Icon

The Button Bar Icon

The Ruler Icon


Creating the Controls

The next step is to put these four controls on a form and connect them. Click on the Text Control icon and draw it on the form. In the same way, create a Ruler Bar and a Button Bar on top of the Text Control, and a Status Bar below it. Your form should now look like this:


Connecting the Controls

Add the following code to the form's Load event procedure:

[Visual Basic 6]
Private Sub Form_Load()
   TXTextControl1.ButtonBarHandle = TXButtonBar1.hWnd
   TXTextControl1.RulerHandle     = TXRuler1.hWnd
   TXTextControl1.StatusBarHandle = TXStatusBar1.hWnd
End Sub


Running the Program

The text processor is not yet finished, but we can make a first attempt at running it and seeing what it can do. Click the Start button. You can type in some text, select it with the mouse, copy it to the clipboard (use the <CTRL>+<C> and <CTRL>+<V> keys as long as there is no menu), select a different font, set tabs and do lots of other things. All of these features have been built into the Text Control and can be used with almost no programming effort.

You will have noticed, however, that some features are still missing. For instance, if you resize the main window, the controls keep their old sizes. There is no menu, and there are no scrollbars either. We will fix this in the coming chapters.


Setting the Page View

TX Text Control offers several view modes for its different tasks. To work as a word processor set the ViewMode property to Page View or Centered Page View. This automatically adds the necessary scroll bars, page size and margins.


Resizing the Controls

Two steps are involved in making the controls resize properly when the main window is resized.

Set the Align property to 1 - Align Top for the Button Bar, the Ruler Bar and the Text Control. Set it to 2 - Align Bottom for the Status Bar. This will adjust everything except the height of the Text Control.

Open the code window for the form which contains the Text Control. In the combo boxes on top of the code window, select Form in the Object: box and Resize in the Proc: box. The code window should show an empty procedure for the Resize event:

[Visual Basic 6]
Private Sub Form_Resize ()
End Sub

Extend it as follows:

[Visual Basic 6]
Private Sub Form_Resize ()
   TXTextControl1.Height = _
      ScaleHeight - TXRuler1.Height _
      - TXStatusBar1.Height - TXButtonBar1.Height
End Sub

This line of code will cause the Text Control's height to be adjusted every time the size of the form is altered. (The '_' character is used to extend one logical line of code to two or more physical lines).


Adding a Menu

In this chapter, you will add a menu to the text processor to enable you to call the Text Control's built-in dialog boxes.

Use the Visual Basic Menu Design Window to create a Format menu with the items Character... and Paragraph.... Name the items mnuFomat_Character and mnuFormat_Paragraph. (Please refer to the Visual Basic documentation if you need help with creating menus).

Add the following code to the Click procedures of the menu items:

[Visual Basic 6]
Private Sub mnuFormat_Character_Click()
   TXTextControl1.FontDialog
End Sub
Private Sub mnuFormat_Paragraph_Click()
   TXTextControl1.ParagraphDialog
End Sub

Start the program again. You should be able to use the menu items to call the Font and Paragraph dialog boxes.

Now for the Edit menu. Again use the Menu Design Window and create an Edit menu containing items for Cut, Copy, and Paste. The code for these menu items is:

[Visual Basic 6]
Private Sub mnuEdit_Cut_Click()
   TXTextControl1.Clip 1
End Sub
Private Sub mnuEdit_Copy_Click()
   TXTextControl1.Clip 2
End Sub
Private Sub mnuEdit_Paste_Click()
   TXTextControl1.Clip 3
End Sub

Having added these menu items, you can exchange formatted text with other word processors via the clipboard.

The last menu for now shall be a simple file menu. Create a File menu including the items Load... and Save As.... Place a common dialog box icon on the form and enter the following code, which will call the common dialog box to get a file name from the user, and will then load respectively save the selected file:

[Visual Basic 6]
Private Sub mnuFile_Load_Click()
   On Error Resume Next
   ' Create an "Open File" dialog box
   CommonDialog1.Filter = "TX Demo (*.tx)|*.tx"
   CommonDialog1.DialogTitle = "Open"
   CommonDialog1.Flags = cdlOFNFileMustExist Or _
      cdlOFNHideReadOnly
   CommonDialog1.CancelError = True
   CommonDialog1.ShowOpen
   If Err Then Exit Sub
   ' Pass the filename to the Text Control
   TXTextControl1.Load CommonDialog1.filename, 0
End Sub
Private Sub mnuFile_SaveAs_Click()
   On Error Resume Next
   ' Create a "Save File" dialog box
   CommonDialog1.Filter = "TX Demo (*.tx)|*.tx"
   CommonDialog1.DialogTitle = "Save As"
   CommonDialog1.Flags = cdlOFNOverwritePrompt Or _
      cdlOFNHideReadOnly
   CommonDialog1.CancelError = True
   CommonDialog1.ShowSave
   If Err Then Exit Sub
   ' Open the selected file
   TXTextControl1.Save CommonDialog1.filename, 0
End Sub


What Comes Next

It goes, of course, without saying that Text Control has many more features than those included in our little demo program. It is up to you now to include zoom, images, tables, OLE objects, paragraph frames and whatever else makes up a full-blown word processor. If you need some hints about how to integrate special features, have a look at the source code of the other sample programs or post a message in the Text Control support forum at http://www.textcontrol.com.


Working with Files

Text Control uses 7 different file formats:

  • Its own, native format, which you would normally use to store data in document files.
  • The Rich Text Format (RTF), which can be used to exchange formatted text with other applications.
  • HTML
  • XML
  • Microsoft Word format
  • Unformatted text in ANSI or Unicode format.
  • Adobe PDF. This file format can only be used for exporting your documents.

Using RTF, HTML, Word or unformatted text is very easy: Just specify the format you want to use as a parameter of the Load or Save method.

Using RTF, HTML, Word and unformatted text, you can only read or write the contents of a single Text Control from or to a file. Using the native file format, however, you can write a file header prior to saving the Text Control data, or even write the contents of several Text Controls to one file.

The Mail Merge sample program shows you how to write the contents of Text Control and other data to a single file. The MDIDemo sample shows you how to write a file header prior to the Text Control's data and how to use RTF, HTML, Word and unformatted text.


Printing

Simple Printing
Advanced Printing
Changing Paper Bins
Print Preview


Simple Printing

Sending a file to the printer in most cases only requires a single line of code. Text Control's PrintDoc Method will automatically detect the default printer and its settings, so that you only need to specify the range of pages and number of copies you wish to have printed:

[Visual Basic 6]
TXTextControl1.PrintDoc "My Print Job", 1, _
   TXTextControl1.CurrentPages, 1

The code above will print one copy of the current document. The first parameter, "My Print Job", specifies an arbitrary name under which the print job is displayed in the print manager. The second and 3rd parameters specify the range of pages to be printed, and the last one is number of copies to be printed.

A Common Dialog box can be used to let the user select printer, range of pages, number of copies.

[Visual Basic 6]
' Display a common print dialog
CmDialog1.Copies = 1
CmDialog1.FromPage = 1
CmDialog1.ToPage = TXTextControl1.CurrentPages
CmDialog1.Min = 1
CmDialog1.Max = CmDialog1.ToPage
CmDialog1.Flags = cdlPDHidePrintToFile Or cdlPDNoSelection
CmDialog1.ShowPrinter
' Print selected pages
TXTextControl1.PrintDoc Form.Caption, CmDialog1.From, _
   CmDialog1.ToPage, CmDialog1.Copies

This code is used, for instance, in the MDIDemo sample program.


Advanced Printing

Although the options which the PrintDoc method offers are sufficient for most applications, there are situations where you may need more control over the printing process. You may, for instance, want to select a different paper bin for the first and the following pages. This is where the PrintPage method is used.

In order to give you maximum flexibility, all that PrintPage does is to send a single page to the printer. It does not even eject the printed page, so that it can be used to print the contents of multiple Text Controls on a single sheet of paper.

PrintPage only has a single parameter, which is the page number, and you need to call it for every page to be printed in turn. Some additional methods and properties are required to select a printer and to control the print job, as shown in this code snippet:

[Visual Basic 6]
For CurPage = 1 To TXTextControl1.CurrentPages
   ' Initialize the VB Printer object
   Printer.Print
   ' Select a printer
   TXTextControl1.PrintDevice = Printer.hDC
   ' Print one page
   TXTextControl1.PrintPage CurPage
   ' Eject the page
   If CurPage <> EndPage Then Printer.NewPage
Next CurPage
' Tell Print Manager we are finished
Printer.EndDoc

The following examples will show you how to extend this basic printing routine with additional features.


Changing Paper Bins

A typical requirement for office applications is to print the first page of a document with letterhead paper and the remaining pages on plain paper. This is usually done by using a printer that has two separate trays for the two types of paper. The application simply sends the first page to the first paper bin, and then switches to the second bin for the remaining pages.

The printing code from our previous example can be easily extended to achieve this:

[Visual Basic 6]
Printer.PaperBin = vbPRBNLower ' select first tray
For CurPage = 1 To TXTextControl1.CurrentPages
   Printer.Print
   ' select second tray
   if CurPage = 2 then Printer.PaperBin = vbPRBNUpper
   TXTextControl1.PrintDevice = Printer.hDC
   TXTextControl1.PrintPage CurPage
   If CurPage <> EndPage Then Printer.NewPage
Next CurPage
Printer.EndDoc


Print Preview

Text Control's PrintPage method can not only be used with printers, but also with any control that has a hDC property. For instance. a Picture Box can be used as a print preview window. This is done by simply assigning its hDC property to Text Control's PrintDevice Property. When calling PrintPage, Text Control will print to the Picture Box instead of to the printer.

This code snippet will print page 1 to a picture box named Picture1. You can use the PrintZoom Property to scale down the printout if the Picture Box is smaller than a full printer page:

[Visual Basic 6]
TXTextControl1.PrintDevice = Picture1.hDC
TXTextControl1.PrintZoom = 25 ' scale down to 25%
TXTextControl1.PrintPage 1

The MDIDemo sample program contains a sophisticated print preview form that works like this. Its source code is contained in the Samples\vb6\MDI folder.


Using Marked Text Fields

Marked Text Fields are markers which are inserted in the text. They can be used to implement a wide range of special functions in a text processor. To name just a few:

  • Mail Merge functions
  • Spreadsheet-like calculation fields
  • Bookmarks
  • Automatic table of contents and index generation
  • Hypertext viewers which include any kind of buttons, images, pop-up windows or even OLE objects in the text

Any group of characters within the text can be a marked text field. The maximum number of fields is 65,535. Text Control maintains the positions and numbers of the fields. It also takes care of loading, saving and clipboard operations.

A Simple Example
Bookmarks
Adding Strings to Marked Text Fields


A Simple Example

This first sample program will show you how fields are created and what happens when they are clicked on. The code shown here is contained in the Samples\vb6\Field1 sample source directory.

The program consists of a form with just one menu item, Insert Field!, with an exclamation mark to say that clicking on this item will cause an immediate action instead of dropping a menu. There are two Text Controls on the form, one of which is used as a normal text window (TXTextControl1), the other one as a pop-up window (TXTextControl2).

The following code is executed when the menu item is clicked on:

[Visual Basic 6]
Private Sub mnuInsertField_Click ()
   TXTextControl1.FieldInsert "--------"
End Sub

This inserts a field at the current caret position. If you move the cursor over the field, Text Control changes the mouse pointer to an upward pointing arrow to indicate that there is something to click on.

If you click on the field, the application receives a FieldClicked event, to which it responds by popping up a window which displays the field number.

Only four lines of code are required for this:

[Visual Basic 6]
Private Sub TXTextControl1_FieldClicked(ByVal FieldIndex As Integer)
   TXTextControl1.FieldCurrent = FieldIndex
   TXTextControl2.Text = "This is field no. " & FieldIndex _
      & ". Its text is: " & TXTextControl1.FieldText
   TXTextControl2.Move TXTextControl1.FieldPosX, _
      TXTextControl1.FieldPosY
   TXTextControl2.ZOrder
End Sub

The first line selects the Marked Text Field which has been clicked on. Line 2 builds the string that is to be displayed in the pop-up window. Line 3 moves the pop-up window, which is initially hidden behind the text window, to the position of the marked text field. Line 4 puts the pop-up window in front of the text window to make it visible. When the mouse button is released, the text window is moved to the front again:

[Visual Basic 6]
Private Sub TXTextControl1_MouseUp(Button As Integer, _
      Shift As Integer, X As Single, Y As Single)
   TXTextControl1.ZOrder
End Sub


Bookmarks

This example shows you how to use Text Control's marked text fields to create bookmarks. The first version will reference the bookmarks simply by their field numbers. The source code for this example is contained in the Samples\vb6\Field2 sample source directory.

The sample application has a Bookmark menu with two items which are named Insert and Go to.... Clicking Insert creates a marked text field at the current caret position. If a text selection exists, the selected text is converted into a field. If not, the character next to the caret is selected.

[Visual Basic 6]
Private Sub mnuBookmark_Insert_Click()
   If TXTextControl1.Text = "" Then
   MsgBox "Cannot insert bookmark if control is empty."
   Else
      If TXTextControl1.SelLength = 0 Then _
         TXTextControl1.SelLength = 1
      TXTextControl1.FieldInsert ""
   End If
End Sub

After typing in some text and inserting a few bookmarks, select the Go To... menu item. This will launch a dialog box which allows you to enter the number of the bookmark to jump to. There is no error processing in this example, so if you enter the number of a non-existent field, nothing will happen.

Clicking the OK button executes the following procedure:

[Visual Basic 6]
Private Sub cmdOk_Click()
   Form1.TXTextControl1.FieldCurrent = Text1.Text
   Form1.TXTextControl1.SelStart = _
      Form1.TXTextControl1.FieldStart - 1
   Form1.TXTextControl1.SelLength = _
      Form1.TXTextControl1.FieldEnd - _
      Form1.TXTextControl1.FieldStart + 1
   Unload Me
End Sub

The number which has been entered in the dialog box is taken as a value for the FieldCurrent property.


Adding Strings to Marked Text Fields

The source code for this example is contained in the Samples\vb6\Field3 sample source directory.

In commercial word processors, bookmarks are normally referenced by names, not just by numbers. The names are typed in by the user when he creates a bookmark. The Goto Bookmark dialog box then presents a listbox or combobox in which one of the strings can be selected.

The Insert Bookmark... menu item in this version of the program creates a dialog box where the user can enter a label for the bookmark.

When the OK button is clicked, the following code is executed:

[Visual Basic 6]
Private Sub btnOK_Click()
   Form1.TXTextControl1.FieldInsert ""
   Form1.TXTextControl1.FieldData( _
      Form1.TXTextControl1.FieldCurrent) = Text1
   Form1.TXTextControl1.SelLength = 0
   Unload Me
End Sub

First, a marked text field is created at the current caret position. Second, the name of the bookmark, which is the text that has been typed in by the user, is stored in the FieldData property.

The Goto Bookmark dialog box contains a combo box which lists all of the bookmarks which have been created so far.

The combo box is filled with the bookmark titles when its form is loaded:

[Visual Basic 6]
Private Sub Form_Load()
   Dim nFieldID As Integer
   nFieldID = 0
   ' Fill the combobox with bookmarks
   Do
      nFieldID = Form1.TXTextControl1.FieldNext(nFieldID, 0)
      If nFieldID > 0 Then
         cboBookmark.AddItem _
            Form1.TXTextControl1.FieldData(nFieldID)
      End If
   Loop While nFieldID <> 0
   ' Copy the first item to the edit control part of
   ' the combo box
   cboBookmark.Text = cboBookmark.List(0)
End Sub

When the OK button is clicked, the bookmark list is searched for the string which has been selected in the combo box, and the corresponding marked text field is selected.

[Visual Basic 6]
Private Sub cmdOk_Click()
   Dim nFieldID As Integer
   nFieldID = 0
   ' Search for the requested bookmark
   Do
      nFieldID = Form1.TXTextControl1.FieldNext(nFieldID, 0)
      If nFieldID > 0 Then
         If Form1.TXTextControl1.FieldData(nFieldID) = _
            cboBookmark.Text Then
            Exit Do
         End If
      End If
   Loop While nFieldID <> 0
   ' If the bookmark has been found, select it.
   ' Text Control will then automatically scroll to
   ' make it visible.
   If nFieldID <> 0 Then
      Form1.TXTextControl1.FieldCurrent = nFieldID
      Form1.TXTextControl1.SelStart = _
         Form1.TXTextControl1.FieldStart - 1
      Form1.TXTextControl1.SelLength = _
         Form1.TXTextControl1.FieldEnd - _
         Form1.TXTextControl1.FieldStart + 1
   Else
      MsgBox "Bookmark not found."
   End If
   Unload Me
End Sub

You can also extend the sample program with a dialog box, similar to the Go To Bookmark... dialog, in which a bookmark can be deleted without deleting the text. This would require converting the Marked Text Field to normal text. Use the FieldDelete method to achieve this.

More information about marked text fields and a list of all properties, methods and events that can be used with marked text fields, can be found in the chapter Technical Articles - Marked Text Fields.


A Word Processor

This chapter shows you how to use Text Control to write a standard word processor. The program is based upon the MDI sample from the Visual Basic Programmer's Guide, with the TextBox controls replaced by Text Controls. If you are not familiar with MDI, control arrays or creating a toolbar you may want to read that chapter first.

The source code for this example is contained in the Samples\vb6\MDI sample source directory.

Adding a PageSetup Dialog Box
A Print Dialog Box
Search and Replace
Using Paragraph Frames
Dialog Boxes for Text and Background Color


Adding a PageSetup Dialog Box

The Page Setup dialog box is used to determine the page size and print margins. The maximum page size is restricted by the capabilities of the default printer. For implementation details, look at the source code of the PageDlgform.


A Print Dialog Box

When the Print... menu item is clicked, first a Common Dialog box is shown to let the user enter the range of pages, number of copies and printer specific information. The rest of the procedure, which is part of the MDIChild form, is just a loop which sets the appropriate Text Control properties for every page to be printed.


Search and Replace

Searching and replacing is entirely done in Text Control. You just have to assign a value of 1 for Search or 2 for Search And Replace to the FindReplace method. Text Control then opens the Windows Common Dialog box.


Using Paragraph Frames

With Text Control, you can add lines and frames to a paragraph or a range of paragraphs. For instance, you can put a line on top of a caption like in the property reference of the printed manual.

The dialog box for paragraph frames is not included in the Text Control, but the source code is included in the MDI sample.

The properties which are responsible for paragraph frames are FrameDistance, FrameLineWidth, and FrameStyle.


Dialog Boxes for Text and Background Color

This is also done with Common Dialogs. The color value returned from the dialog box is assigned to the ForeColor or BackColor properties.


Connecting to Databases

TX Text Control can be connected to any type of database, and store formatted text in any of its text formats. You can save a complete document as a record, or load text from a database into table cells and Marked Text Fields. Typical applications which can be created are mail merge, report generators, formatted data entry masks, and all types of business applications where documents are created from information stored in a database.

This chapter shows you how to save the contents of a Text Control to a database. The data is stored as an RTF formatted string in a text field. For an advanced sample program which shows how to use databases with tables and marked text fields, please also refer to the TX Quote Generator sample program.

The source code for this sample program is contained in the Samples\vb6\DataAccess sample source directory.

The Sample Program
Saving a Record
Retrieving a Record


The Sample Program

The sample program consists of a form with 2 Text Controls, both of which display the same record of a database. The upper control displays it as formatted text, whereas, for demonstration purposes, the lower control shows the record's RTF source code.

Clicking the Next button will save any changes you have made in the upper window, and advance to the next record.


Saving a Record

All data access is handled by two Methods, which are SaveToMemory and LoadFromMemory. The SaveToMemory Method stores formatted text to a byte array, which is then passed on to the database engine using Visual Basic's DAO or ADO functions. The following code uses DAO syntax.

[Visual Basic 6]
Private Sub PutRecord()
   Dim ba() As Byte, s As String
   ba = TXTextControl1.SaveToMemory(5, 0)
   ' convert from ANSI to Unicode
   s = StrConv(ba, vbUnicode)
   rs.Edit
   rs("RTF") = s
   rs.Update
End Sub

Other text formats can be used by simply changing the first parameter of the SaveToMemory method.


Retrieving a Record

To retrieve a record from the database and display it, the data is converted from Unicode to ANSI, and then passed on to the LoadFromMemory method of Text Control 1. As Text Control 2 just displays the RTF source code without any formatting, we can simply use the Text property to load it.

[Visual Basic 6]
Private Sub GetRecord()
   Dim ba() As Byte, s As String
   ' Load RTF data and convert it to a byte array
   s = rs("RTF")
   ba = StrConv(s, vbFromUnicode)
   ' Display RTF data in Text Control 1
   TXTextControl1.LoadFromMemory ba, 5, 0
   TXTextControl1.Refresh
   ' Display RTF source code in Text Control 2
   TXTextControl2.Text = s
End Sub

The text format used in this example is RTF, which has the advantage of being accessible by most word processing programs. If this is not an issue, Text Control's binary format may be a better choice, as it is more compact and will take up less space in a database.


Using Images

TX Text Control provides three different methods for inserting images:

  • The ImageInsert method is the default method for inserting images. An image inserted with this method is anchored to a paragraph. Text can flow around the image, and the image moves with the paragraph.
  • Images inserted with the ImageInsertAsChar method are handled like a single character in the text. This method is often used for inserting small images and icons.
  • The ImageInsertFixed method inserts an image at a fixed position on the page. The image will keep its position regardless of the surrounding text.

Images can be inserted from a file or from the clipboard. When saving a document, you can select whether to embed image data in the document file, or save a reference to a seperate image file. Note that not all options are available in all file formats. For instance, while image data can be embedded in RTF and .DOC files, HTML does not provide this option.

Further options are:

  • to convert images to a different file format,
  • to convert embedded images to image files, and
  • to change image resolution and compression rate.

This is especially useful, if you create HTML files, where embedded images and image file formats like WMF or TIFF need to be converted to JPEG or GIF files for display in a browser. Image resolution and compression settings are also required for creating PDF files, for instance to create one version of a PDF with low-resolution images for viewing on screen, and another one with high resolution images for printing.

An overview of all properties, methods and events which can be used in conjunction with images can be found at Images, Text Frames and OLE Objects. Properties which have a name that begins with "Object" can be used with images as well as other kinds of embedded objects, like text frames and OLE objects, whereas those starting with "Image" only apply to images.

Inserting an Image
Setting Image Attributes


Inserting an Image

The source code for this sample program is contained in the Samples\vb6\Images sample source directory.

The mnuImage_Insert_Click function shows you how to open a dialog box for selecting an image file, and then insert the image:

[Visual Basic 6]
Private Sub mnuImage_Insert_Click()
    On Error GoTo err_InsertImage

    CmDialog1.DialogTitle = "Insert Image"
    CmDialog1.Filter = TXTextControl1.ImageFilters
    CmDialog1.FileName = ""
    CmDialog1.Flags = cdlOFNPathMustExist Or cdlOFNOverwritePrompt Or cdlOFNHideReadOnly
    CmDialog1.CancelError = True
    CmDialog1.ShowOpen

    TXTextControl1.ImageInsert CmDialog1.FileName, -1, 1, 0, 0, 100, 100, 3, 100, 100, 100, 100
    Exit Sub

err_InsertImage:
    If Err <> cdlCancel Then MsgBox Err.Description

End Sub

The image is inserted using the ImageInsert method.


Setting Image Attributes

TX Text Control has a built-in dialog box which enables you to change the size of an image, the way images are stored, and various other settings. In the sample program, the Image Attributes dialog box is invoked either with the Image Settings menu item, or by right-clicking on an image. The dialog box is opened using the ObjectAttrDialog method:

[Visual Basic 6]
Private Sub mnuImage_Settings_Click()
    TXTextControl1.ObjectAttrDialog
End Sub

Private Sub TXTextControl1_ObjectRightClicked(ByVal ObjectId As Integer)
    TXTextControl1.ObjectAttrDialog
End Sub


Using Text Frames

This chapter describes how you can control and manipulate text using text frames. The source code for the sample programs shown here can be found in the Samples\vb6\TextFrames folder.

An overview of all properties, methods and events which can be used in conjunction with text frames can be found at Images, Text Frames and OLE Objects. Properties which have a name that begins with "Object" can be used with text frames as well as other kinds of embedded objects, like images and OLE objects, whereas those starting with "TextFrame" only apply to text frames.

Inserting a Text Frame
Drawing Text Frames Using The Mouse
Printing Labels


Inserting a Text Frame

TX Text Control provides three different methods for inserting text frames:

  • The TextFrameInsert method is the default method for inserting text frames. A text frame inserted with this method will be anchored to a paragraph. Text can flow around the frame, and the frame will move with the paragraph.
  • Text frames inserted with the TextFrameInsertAsChar method are handled like a single character in the text. This method is often used to insert small data entry fields.
  • The TextFrameInsertFixed method inserts a text frame at a fixed position on the page. The text frame keeps its position regardless of changes made to the surrounding text.

The first sample program shows how to insert a text frame using TextFrameInsert. The source code for this sample program can be found in the Samples\vb6\TextFrames\Inserting Text Frames folder.

The sample program has two menu items, one of which calls TX Text Control's TextFrameInsert method to create a text frame, and the other one calls ObjectAttrDialog to open a settings dialog box.

[Visual Basic 6]
Private Sub mnuTextFrame_Insert_Click()
    TXTextControl1.TextFrameInsert -1, 0, 0, 0, 1000, 1000, 3, 20, 20, 20, 20
End Sub

Private Sub mnuTextFrame_Settings_Click()
    TXTextControl1.ObjectAttrDialog
End Sub

Text frames can be moved and resized by dragging them with the mouse. Clicking on the border of a text frame selects and activates it. After a text frame has been selected, its Settings dialog box can be opened by clicking the Settings menu item.

TX Text Control's ObjectAttrDialog method can be used on all types of insertable objects, including text frames, images and OLE objects. To prevent the dialog box from being displayed when no text frame has been selected, the corresponding menu item is only enabled after a text frame has been clicked on. This is done in the sample program's mnuTextFrame_Click event handler:

[Visual Basic 6]
Private Sub mnuTextFrame_Click()
    mnuTextFrame_Settings.Enabled = (TXTextControl1.ObjectGetSelected(&H20) <> 0)
End Sub

ObjectGetSelected is another method that can be used with all insertable objects. Its parameter determines which type of object to look for.


Drawing Text Frames Using The Mouse

The source code for this sample program can be found in the Samples\vb6\TextFrames\Drawing Text Frames Using The Mouse directory

TX Text Control does not provide a built-in mouse interface for drawing frames, but it is straightforward to create one using a Visual Basic 6 Shape control. In the sample program, click on the Insert New Frame menu item. This changes the cursor to a cross hair, indicating that you can now start drawing a frame.

When the mouse button is released, the shape control will be replaced by a text frame.


Printing Labels

This sample program shows how to insert multiple text frames simultaneously. The application is a label printing program, used to print, for instance, address labels or badges. The source code for this sample program can be found in the Samples\vb6\TextFrames\Printing Address Labels directory

The sample program contains a dialog box for entering information about the label sheet to be used, e.g. the number of labels and their dimensions.

The program then creates a text frame for each of the labels.

The text frames can them be filled out, either manually by clicking on a field and typing in text, or from a file or database. When you click on the Fill in menu item, the sample program will enter the words "Address no." followed by the field identifier into each of the frames.

To load text from a file instead, simply replace the .Text property with a call to TX Text Control's Load method.

[Visual Basic 6]
Private Sub mnuLabel_FillIn_Click()
    Dim FrameID As Integer

    FrameID = tx.ObjectNext(0, &H20)
    While FrameID
        tx.TextFrameSelect (FrameID)
        tx.Text = tx.Text = "Address no. " & FrameID
        tx.TextFrameSelect 0
        FrameID = tx.ObjectNext(FrameID, &H20)
    Wend
End Sub


Mail Merge

The chapter Connecting to Databases showed you how to store the entire contents of a Text Control in a database field. For implementing mail-merge functionality, however, the requirements are different: the contents of database fields have to be inserted at specified positions in a previously prepared document. The following sample program provides you with the knowledge of how to do this.

Step 1 - Merging Database Data and Text
Step 2 - Printing more than one Record
Step 3 - Dynamic Template Generation


Step 1 - Merging Database Data and Text

The program consists of two forms, Form1, for creating a text template and Form2 for connecting it to the database.

Start the program and use the Template/ Load... command to load the sample template file e.g. template1.tx. The file contains various fields which are to be replaced by database entries. Select Database / Browse Database to access Form2. Now you are able to skip through the database entries connected with the template. When you click the Merge button in Form2, the contents of the three database fields are copied to the text fields in Form1. You can select a different record by clicking one of the data control buttons in Form2, and then clicking Merge again to replace the fields.

This example has a couple of interesting features. We will focus on the features in which Text Control's functionality is primaraily used. You will find a menu item, with which a template file can be loaded. This file already contains several Marked Text Fields. So we can get some data from a database into these fields, each one has a unique name. These unique names are saved in the FieldData property.

Using a second menu item, a further form can be opened - this allows a suitably prepared database to be linked. With a button click, the current data set can be merged into the document.

The most important function of this example is the one that allows a data field from the linked database to be merged into a field from Text Control. To get this to work, we need to get the field number of the Marked Text Field that belongs to the data field. This can be achieved using the following code:

[Visual Basic 6]
Function FindField(name As String) As Integer
   Dim id As Integer
   Dim foundID As Integer
   foundID = 0
   id = Form1.TXTextControl1.FieldNext(0, 0)
   While id <> 0
      If Form1.TXTextControl1.FieldData(id) = name Then
         foundID = id
      End If
      id = Form1.TXTextControl1.FieldNext(id, 0)
   Wend
   If foundID <> 0 Then
      FindField = foundID
   Else
      FindField = 0
   End If
End Function

Using a loop we go through all the fields from the Text Control - and the FieldData property belonging to each field - to check whether it is the same as the name we are searching for. If we get a hit, its' ID is returned. If no field is found, then a zero is returned.

For the merging of the field data with the database we will have to add another function to our application. Let's have a look at the source code:

[Visual Basic 6]
Sub Merge(TXDest As TXTextControl, field As String)
   Dim id As Integer
   Dim i As Integer
   Dim db As Database
   Dim rs As Recordset
   Dim data, SQL As String
   ' Open database
   Set db = Form2.Data1.Database
   Set rs = db.OpenRecordset(db.TableDefs(0).name)
   ' Find record
   SQL = "SELECT * FROM " + db.TableDefs(0).name + _
        " where " + rs.Fields(1).name + " like '" +_
        field + "'"
   Set rs = db.OpenRecordset(SQL)
   rs.MoveFirst
   ' Now fill all fields with data
   For i = 0 To rs.Fields.Count - 1
      ' Get ID of field with the according name
      id = FindField(rs.Fields(i).name)
      ' Get data from database
      data = rs(rs.Fields(i).name)
      If id <> 0 Then
         TXDest.FieldCurrent = id
         TXDest.FieldText = data
      End If
   Next i
End Sub

This function opens the database, and fills up each Marked Text Field of the template with the data from each database field. You will find the whole sample project in the Samples\vb6\Mailmerge\Step1 sample directory.


Step 2 - Printing more than one Record

Now we are going to set up a print queue. The user will have the option to add single records to the print queue and then start printing the queue on command. As shown in step 1, the user can browse through a database and merge single data records into the document.

The queue is a simple list box, in which the company name of the current record is added. This record name will be replaced by the actual data from the current record.

To print a document in the background, we have to use the following code (in the Form2 of the sample project). We use a second, invisible Text Control, which is filled with the data from the template and merge the data into this control.

We do not have to write a second routine for the merging, the old one has been changed a little and defined globally. This globally defined routine now gets the parameters from the Text Control in which the merging is currently taking place. What's more, the actual records from the database are now merged in the marked text fields and no longer in the label captions.

Now we just need to call StartPrinting to start the printing. Let us take a look at the following VB code:

[Visual Basic 6]
Sub StartPrinting()
   Dim data() As Byte
   Dim i As Integer
   ' Copy document to hidden TX
   data = Form1.TXTextControl1.SaveToMemory(3, False)
   Form2.TXHidden.LoadFromMemory data, 3, False
   ' Print queue
   While (doPrint And Form2.List1.ListCount > 0)
      Merge Form2.TXHidden, Form2.List1.List(0) ' Merge data
      For i = 1 To Form2.TXHidden.CurrentPages
         Printer.Print
         Form2.TXHidden.PrintDevice = Printer.hDC
         Form2.TXHidden.PrintPage i
         Printer.NewPage
      Next i
      Printer.EndDoc
      ' First item printed, remove it from queue
      RemoveItem (0)
   Wend
End Sub

The complete content of the visible document is copied into the second, hidden Text Control. We use the LoadFromMemory and SaveToMemory methods to do this. Now we simply have to work off the queue. A simple while loop, which runs until there are no longer entries in the list box, takes care of this.

However first, we have to do the actual merging. The hidden Text Control and the string at position 0 of the list box are passed as parameters. In this case, it is the company name of the record which is to be printed. The document is then printed and finally the record is removed from the list box.

The source code for this sample can be found in the Samples\vb6\MailMerge\Step2 directory.


Step 3 - Dynamic Template Generation

This step will show you how to build a real mail-merge layout editor. In other words, the user should be able to select a database and insert its fields into his active document just by clicking the mouse. Then, when we start the actual mail merging process, these fields will be replaced by the data from the database.

However, the problem is that we do not know how many fields there are in the database. In other words our application must be able to work with databases of varying size.

Secondly, we are going to set up a menu item, which will call a Common Dialog so that the user can select a database. However, the database is not really loaded - just the name of the database is stored in the curDBName variable. Storing an entire database in the memory could be somewhat problematic, should the database be several terabytes in size.

Thirdly, we need to let the user insert fields from the database into this document. However, only fields which are in the database may be inserted into the active document. To do this, we use a combo box. On loading the database we then proceed to fill this combo box with the names of its fields. Using a simple button, we can then insert a field from the database into our active document.

Each piece of static code dealing with database fields has to be replaced with dynamic field names.

Consider the Browse Database form: In the previous example, the labels which display the data from the database were statically linked to the database.

Using a control array, these labels now need to be dynamically created when the form is loaded. Once they have been loaded, they then have to be linked to the corresponding database field.

To do this, we need to use the following Visual Basic code:

[Visual Basic 6]
Private Sub Form_Load()
   Data1.DatabaseName = curDBName
   doPrint = False
   TXHidden.Left = 10000 ' Move TX out of the visible area
   Dim db As Database
   Dim rs As Recordset
   ' Find record
   Set db = OpenDatabase(curDBName)
   Set rs = db.OpenRecordset(db.TableDefs(0).name)
   lblField(0).Caption = rs.Fields(0).name
   lblData(0).DataField = rs.Fields(0).name
   ' Create labels
   For i = 1 To rs.Fields.Count - 1
      Load lblField(i)
      lblField(i).Top = 320 + (i * 300)
      lblField(i).Caption = rs.Fields(i).name
      lblField(i).Visible = True
      Load lblData(i)
      lblData(i).Top = 320 + (i * 300)
      lblData(i).DataField = rs.Fields(i).name
      lblData(i).Visible = True
      ' if i > 6 We need more space
      If i > 6 Then
         Form2.Height = Form2.Height + 300
         Frame1.Height = Frame1.Height + 300
         Data1.Top = Data1.Top + 300
         cmdMerge.Top = cmdMerge.Top + 300
         cmdCancel.Top = cmdCancel.Top + 300
      End If
   Next i
End Sub

On one side, we have the field labels, which will show the name of the currently active database field and on the other we have data labels, which will display content from the database.

As soon as we have more that seven fields in the database, the form will have to be enlarged so that there is enough room to accommodate all the labels.

A very important point here is the saving and loading of the templates: When the fields from a database appear in the active document, the connected database must also be loaded when the document is loaded.

Therefore, we need to save the name of the database in the document. To do this, we have to write a header to the document we are saving. Only then may we save the Text Control data. On loading, the header is read first.

Here is the Visual Basic code to do exactly this:

[Visual Basic 6]
Private Sub mnuSaveTemplate_Click()
   Dim FileID As Long
   Dim lFilePos As Long
   On Error Resume Next
   ' Create a "Save File" dialog box
   CommonDialog1.Filter = "TX Demo (*.ttx)|*.ttx"
   CommonDialog1.DialogTitle = "Save As"
   CommonDialog1.Flags = cdlOFNOverwritePrompt Or cdlOFNHideReadOnly
   CommonDialog1.CancelError = True
   CommonDialog1.ShowSave
   If Err Then Exit Sub
   ' Write Header
   Open CommonDialog1.FileName For Binary As #1
   FileID = FILE_ID
   Put #1, , FileID
   Put #1, , curDBName
   Put #1, , vbCrLf
   lFilePos = loc(1)
   Close #1
   TXTextControl1.Save CommonDialog1.FileName, lFilePos, 3
End Sub

The project files for this sample can be found in the Samples\vb6\MailMerge\Step3 directory.


Quote Generator - An Office Application

This sample program shows how to use Text Control in office applications. The main task of an office application typically is to create documents from information taken from a set of databases. For instance, a quote is generated from a record in an address database and one or more records in an article database.

The source code for the following examples is contained in the sub folders Step1 and Step2 of the Samples\vb6\QuoteGen sample source directory.

The program is built up in two steps, starting very simple with only a single address database, and adding more features later on.

Step 1 - Creating a Quote from a Database
Step 2 - Adding Articles with a Table


Step 1 - Creating a Quote from a Database

When the program is started, it displays an address database in a data bound grid control.

This may not be the most scalable approach, but all we need in this first version is a simple way to select a record from the database, and therefore using a grid and a data control will do for now.

Selecting the File/New Quote menu item takes the current record from the database and creates a document from it. This is done in the following way:

A form containing a Text Control is opened, and a style sheet is loaded. A style sheet is a file that serves as a template for the final document. It contains all text parts which are equal to all documents, for instance a phrase like "In reply to your inquiry and according to our general terms of business we are pleased to..", and placeholders for information that is to be inserted from a database, like 'Address', 'Date', and so forth. It also defines the font, font size, company logo, and layout, so that all files will have the same look.

Once the style sheet has been loaded, the placeholders are updated from the database, so that they now contain the real address, name, customer number, and date.

The style sheet can be edited with the Advanced menu. Later versions of the program will have additional style sheets for other types of documents.

Business applications tend to become very large over time, and often, as the company grows and changes, need to be extended in unexpected ways. Often early versions of the program use a simple desktop database, and later need to be adapted to a more powerful client/server model. Or the company suddenly has a dependency in another country, and the software has to deal with different languages and currencies. For this reason, a modular, component based design is vital, and we will already follow this approach in the first step.

The application can be divided into several logical units:

  • The Database module provides an interface to the physical database, and allows for later changing the database without rewriting the complete program.
  • The DataEntry module provides the user interface to the databases, i.e. enables the user to add and edit records.
  • The Search unit allows for searching the databases, for instance for a company name or invoice number.
  • The Editor unit assembles and displays a document, and lets you save and print it.
  • Visual Basic makes it straightforward to put these units into ActiveX components, providing good encapsulation and re usability.

Note that Step 1 only contains the database and the editor module. The remaining ones, together with an additional article database, will follow in Step 2.


Step 2 - Adding Articles with a Table

Before you read everything about how it is programmed, you may want to run it and see what it does, so here is a short user's guide first.

  • Start the program. You will see the main form, displaying some customer address records. Select one by clicking on it.
  • Select the File / New Quote menu item. A quote will be generated using the selected customer's name, address and customer number.
  • Click on the Insert / Article menu item. Select one of the articles displayed in the dialog box that pops up, and click OK. The product data will automatically be entered into the quote.
  • Enter the desired quantity. The total will be recalculated accordingly.
  • Repeat step 3 to enter more articles (clicking into an empty table row first). Delete the remaining empty lines by selecting them with the mouse and clicking Edit / Delete table rows.
  • Finished. Click File / Print to make a printout of the quote.

The first thing we need to do in order to add article descriptions and pricing to our quotes from Step 1 is to add another database. We call it the article database, and display it on the main form beside the address database.

That's it for the main form. In the Editor module, we now add a menu item which lets us insert items from the article data into a quote.

A list of articles is best displayed in a table, and Text Control offers all required table functions to let us insert product IDs, descriptions, and prices into the respective cells, as well as to perform calculations. We therefore add a table to the style sheet and adjust its column widths, text distances, and caption text so that later only the plain text needs to be filled in.

This is what the style sheet now looks like:

A new menu item has been added to the Advanced menu, which allows to insert a table. Also, a Format/Table menu item has been created which calls Text Control's Table Attribute dialog box, so that we can adjust the table grid lines and background shading. The table's column widths and tabs are adjusted in the ruler bar. Note that the 2 rightmost columns have decimal tabs, so that the currency values they will contain will be properly aligned at the decimal sign.

We are now ready to fill in text from the article database into the table. The properties we need at this point are:

  • TableAtInputPos to check whether the input position is within a table
  • TableRowAtInputPos to get the current table row
  • TableColAtInputPos to get the current tablecolumn
  • TableCellText to access the text in a given table cell

After the user has selected a product in the article database, the program performs these steps:

  • It checks if the current input position is in an empty field in the first column of a table, where a product code can be inserted. If not, then it moves the input position to the first free cell.
  • It inserts the selected product code, product description, and price.
  • Whenever Text Control sends a Change event, it checks if it was an entry in the Quantity column that has changed, and recalculates the total accordingly.


Headers and Footers

This example shows how to use headers and footers. The source code is contained in the Samples\vb6\Headers sample source directory.

TX supports headers as well as footers. You also have the ability to create a different header or footer for the first page.

The Sample Program

To insert a header or footer in the example, click on Insert and choose one of the four possible options. The code that is executed when clicking on one of the menu items is almost the same. For the Header menu item it looks as shown below. The line

[Visual Basic 6]
TXTextControl1.HeaderFooter = TXTextControl1.HeaderFooter + txHeader

informs Text Control that a header should be added to the current settings.

Setting the HeaderFooterStyle property to txMouseClick enables the user to activate the header with a single click rather than a double-click. Activating a header or footer with a double-click is Text Control's default setting. More information about how to use headers and footers and a list of all properties, methods and events that can be used with headers and footers, can be found in the in the chapter Technical Articles - Headers and Footers.

When using properties, Text Control distinguishes between the main text and headers or footers. To switch between these different independent text parts, Text Control provides the HeaderFooterSelect method:

[Visual Basic 6]
TXTextControl1.HeaderFooterSelect txHeader
TXTextControl1.SelText = "Header"
TXTextControl1.HeaderFooterSelect 0

This code selects the header, so that the following code affects the header and then sets the headers text. Finally the mode is reset to zero using the HeaderFooterSelect method. More information about programming with headers and footers see the chapter Technical Articles - Headers and Footers - Programming Headers and Footers.

A header or footer is activated from programming code using the HeaderFooterActivate method. To delete a header or footer, simply subtract the txHeader constant from the current HeaderFooter settings.The following is the complete code of the menu item:

[Visual Basic 6]
Private Sub mnuHeader_Click()
   If mnuHeader.Checked = False Then
      TXTextControl1.HeaderFooter = _
         TXTextControl1.HeaderFooter + txHeader
      TXTextControl1.HeaderFooterSelect txHeader
      TXTextControl1.SelText = "Header"
      TXTextControl1.HeaderFooterSelect 0
      TXTextControl1.HeaderFooterActivate txHeader
      mnuHeader.Checked = True
   Else
      TXTextControl1.HeaderFooter = _
         TXTextControl1.HeaderFooter - txHeader
      mnuHeader.Checked = False
   End If
End Sub


Hypertext Links

This chapter shows how to use Text Control's marked text fields to insert hypertext links and targets into text documents and how to respond to events which Text Control fires when the user clicks on a hypertext link.

The source code for the following examples is contained in the sub folders Step1 to Step4 of the Samples\vb6\Hyperlnk sample source directory.

Step 1 - Inserting a Hypertext Link
Step 2 - Adding a Dialog Box for Inserting Hypertext Links
Step 3 - Adding Targets
Step 4 - Adding Jumps to External Targets


Step 1 - Inserting a Hypertext Link

In this first sample program a hypertext link will be inserted in a text document. The document is saved then as a HTML file so that it can be viewed in a browser.

Hypertext links are handled as a special type of a marked text field. A hypertext link therefore is inserted by calling the FieldInsert method, and then specifying the type of the field with the FieldType property:

[Visual Basic 6]
TXTextControl1.FieldInsert "Text Control Web Site"
TXTextControl1.FieldType(TXTextControl1.FieldCurrent) = _
         txFieldExternalLink

To store the target to where the link points, the FieldTypeData property is used:

[Visual Basic 6]
TXTextControl1.FieldTypeData(TXTextControl1.FieldCurrent)=_
         "http://www.textcontrol.com"

The following line of code saves the document, containing the hypertext link, which has just been inserted as a HTML file in the sample folder:

[Visual Basic 6]
TXTextControl1.Save App.Path & "\step1.html", ,4 , 0

When this file is loaded with a web browser, the hypertext link will be displayed as specified in your browser's settings. Clicking on the link, will take you to the Text Control web site.

Note that there is no code for the Click events yet, so clicking on the hypertext link in the Text Control will have no effect. Also, the link is neither underlined nor colored.


Step 2 - Adding a Dialog Box for Inserting Hypertext Links

In this second sample program a dialog box is created which enables the user to insert hypertext links in a more convenient way. Additionally, hypertext links which have previously been inserted or loaded from a file, can be edited and modified. Note that, while hypertext links are usually associated with HTML files, they can as well be stored in RTF or Microsoft Word files, or in Text Control's proprietary format.

The dialog box has two text boxes. The first is for the text that represents the hypertext link in the document and the second is for the address, to where the link points. In the step 1 example, the representing text was "Text Control Web Site", and the address, to where the link points, was "http://www.textcontrol.com".

The same dialog box is used for both, inserting a new and editing an existing hypertext link. Depending on whether the current input position is inside of an existing link, this link is modified. Otherwise a new one is inserted.

The dialog form's properties, i tx and bShowHyperlinks, are used to pass a Text Control's reference and some information about how to display the hypertext links to the form.

[Visual Basic 6]
Public Sub do_mnuInsert_Hyperlink_Click(tx As _
            TXTextControl, bShowHyperlinks As Boolean)
   Set frmHyperlink.tx = tx
   frmHyperlink.bShowHyperlinks = _
      (mnuView_Hyperlinks.Checked = True)
   frmHyperlink.Show 1
End Sub

When the form is loaded, the text boxes are filled with the text and link information when the current input position is inside of an existing link:

[Visual Basic 6]
Private Sub Form_Load()
   If CaretInsideHyperlink(tx) <> 0 Then
      txtLinkedText = tx.FieldText
      txtLinkTarget = tx.FieldTypeData(tx.FieldCurrent)
   Else
      txtLinkedText = tx.SelText
   End If
End Sub

The user then can change the displayed information. The information is then transfered to the document by either inserting a link or modifying the existing one when the OK button is pressed:

[Visual Basic 6]
If tx.FieldAtInputPos <> 0 Then
   ' editing an existing hypertext link
   tx.FieldText = txtLinkedText
   tx.FieldType(tx.FieldCurrent) = txFieldExternalLink
   tx.FieldTypeData(tx.FieldCurrent) = txtLinkTarget
Else
   ' insert new hypertext link
   tx.FieldInsert txtLinkedText
   tx.FieldType(tx.FieldCurrent) = txFieldExternalLink
   tx.FieldTypeData(tx.FieldCurrent) = txtLinkTarget
   HighlightHyperlinks tx, bShowHyperlinks
End If

Finally, there is a menu item to switch the character format of the hyperlink's text to blue colored and underlined style. The menu item calls the function HighlightHyperlinks, which is defined in the file HyperlinkFunctions.bas.


Step 3 - Adding Targets

Step 1 and 2 only handle references to external resources, i.e. addresses of web pages or files. In this step, links to positions in the same document will be handled. These links are called internal links and the positions, to where they point, are called targets. Targets are also referred to as anchors (in the context of HTML editors) or bookmarks (in word processors). When using this example, first add some text and then some targets with the Insert / Target... menu item. Finally use the Insert / Hypertext Link... menu item to add links to these targets.

1. Inserting a Target:

Targets are realized again as a special type of a marked text field. The type and the target's name must be set with the FieldType and the FieldTypeData properties.

Unlike links, targets have no visible text, therefore an empty field must be inserted with the FieldInsert method to insert a target:

[Visual Basic 6]
Dim TargetName As String
TargetName = InputBox("Target name:", "Insert target")
If TargetName <> "" Then
   TXTextControl1.FieldInsert ""
   TXTextControl1.FieldType(TXTextControl1.FieldCurrent) = _
      txFieldLinkTarget
   TXTextControl1.FieldTypeData( _
      TXTextControl1.FieldCurrent) = TargetName
End If

Only one text box is required to display the name of a target, so a simple InputBox statement can be used.

Inserting Links to Targets

To insert links to the just inserted targets, the Hypertext Link dialog box is extended with a list box showing the names of all targets the document contains. The FieldNext method is used to fill this list box:

[Visual Basic 6]
Dim FieldID As Integer
List1.Clear
FieldID = tx.FieldNext(0, &H100&)
While FieldID <> 0
   List1.AddItem tx.FieldTypeData(FieldID)
   FieldID = tx.FieldNext(FieldID, &H100&)
Wend

When the user selects a target, the Link To field is filled with the target's name.

After typing the link's text and pressing the OK button, the link is inserted. An internal link is inserted in the same way as the external links from step 1, but the FieldType property now is set to txInternalLink and the FieldTypeData property is set to the target's name.

2. Jumping to a Target:

After inserting internal links and targets, a jump must be realized. When the user clicks on a marked text field that represents a hypertext link, Text Control fires a FieldLinkClicked event. The information provided through this event can be used with the FieldGoto method to jump to the target:

[Visual Basic 6]
Private Sub TXTextControl1_FieldLinkClicked( _
      ByVal FieldIdAs Integer, _
      ByVal FieldType As Integer, _
      TypeData As String)
   TXTextControl1.FieldGoto txFieldLinkTarget, TypeData
End Sub

While the FieldGoto method is used for targets within the same file, links to external targets must be treated differently. When the Jumping to an External Target event occurs, and the FieldType parameter indicates that the link is external, then it depends on the type of the application, what to do. External links can point to, for instance, files on the local harddisk, or addresses in the internet.

Note that responding to the events is only required for making the hypertext links work while the text is edited in Text Control. If the text is saved to a file and displayed with a browser, then the hypertext links will work depending on the used browser.


Step 4 - Adding Jumps to External Targets

Finally, in this step, jumps to other documents and jumps to targets in these documents are added.

1. An Enhanced Dialog Box for Displaying and Selecting Targets:

Again the Hypertext Link dialog box is extended to choose an external file. A Choose File... button is placed on the form that triggers a common dialog.

After the user has chosen a file, its name is displayed in the text box and the file is searched for internal targets:

[Visual Basic 6]
Private Sub CheckFileForTargets(file As String)
   tx(1).LoadSaveAttribute(txEnableLinks) = True
   tx(1).Load file, 0, 4
   FillListboxWithTargets (1)
   optSelFile.Value = True
   loadedFile = file
End Sub

For this purpose the file is loaded in a second, invisible Text Control. Then the FieldNext method is used as in step 3 to list all targets.

2. Jumping to an External Target:

To implement the jump to an external link, the code added to the FieldLinkClicked event in step 3 must be extended. The following code does not handle jumps to internet addresses, it only implements jumps to targets in other files. To separate a file from a name of a target, Text Control uses the '#' character. The following code separates the file name and the target's name, loads the file with the Load method and jumps to the target with the FieldGoto method:

[Visual Basic 6]
ElseIf FieldType = txFieldExternalLink Then
   'This sample does not feature links to www sites,
   'so exit sub
   If Left(TypeData, 7) = "http://" Then
      Exit Sub
   End If
   TXTextControl1.LoadSaveAttribute(txEnableLinks) = True
   pos = InStr(TypeData, "#")
   'File name includes an internal link
   If pos >= 0 Then
      'Ask the user to save changes, if any
      If bDocDirty Then
      ret = MsgBox("Save changes?", vbYesNoCancel, _
               "Question")
         If ret = vbYes Then
            mnuFile_SaveAs_Click
         ElseIf ret = vbCancel Then
            Exit Sub
         End If
   End If
      'Extract file name & path from full path
   str = Left(TypeData, pos - 1)
      TXTextControl1.Load str, 0, 4
      'Extract file position from full path
      str = Mid(TypeData, pos + 1)
      TXTextControl1.FieldGoto txFieldLinkTarget, str
   Else
      'File name doesn't include an internal link
      TXTextControl1.Load TypeData, 0, 4
   End If
End If

3. Loading and Saving Files containing Hypertext Links:

When an HTML, RTF or Microsoft Word document is loaded, Text Control must convert containing hypertext links to appropriate marked text fields as described above. To perform this, a programmer must set the LoadSaveAttribute (txEnableLinks) before using the Load method. Otherwise hypertext links and target fields are not converted. When a document is saved, marked text fields that represent hypertext links, are always converted to the appropriate format.

If Text Control's proprietary format is used, setting LoadSaveAttribute is not necessary.

More information about hypertext links and a list of all properties, methods and events that can be used with marked text fields, can be found in the chapter Technical Articles - Marked Text Fields - Special Types of Marked Text Fields.


Drag and Drop

This example shows how to use the InputPosFromPoint method to realise a simple Drag&Drop in a Text Control application.

Drag&Drop in a text editor enables the user to drag a piece of text and drop it in a new location of the document. So, the incoming mouse events have to be analyzed and handled.

The code shown here is contained in the Samples\vb6\DragDrop sample source directory.

The Sample Program

In the MouseDown event, the InputPosFromPoint method is used to get the character position the user has clicked on. The current input position and the length of the selection are stored in global variables, because they are needed in the MouseUp event. If the input position the user has clicked on, is inside of the current selection, dragging can be started. First a global variable named dragging is set to true and the MousePointer property is changed to indicate that dragging is in process. The text and format information of the current selection is copied to a memory buffer using the SaveToMemory method. Finally, the Text Control's EditMode property is set to 2 - read only.

[Visual Basic 6]
'Get current input position and the current selection
pos = TXTextControl1.InputPosFromPoint(X, Y)
gblStart = TXTextControl1.SelStart
gblLength = TXTextControl1.SelLength
'Check if the click occured in the current selection
If gblStart <= pos And gblStart + gblLength > pos Then
'Start dragging
   data = TXTextControl1.SaveToMemory(3, True)
   dragging = True
   MousePointer = 2
   TXTextControl1.EditMode = 2
End If

In the MouseUp event procedure the InputPosFromPoint method is used again to get the character position where the user has left the mouse button. When dragging is in process and the input position is not inside the current selection, the drop operation can be performed. The previously saved text now is inserted with the LoadFromMemory method after setting the new input position with the SelStart property.

[Visual Basic 6]
pos = TXTextControl1.InputPosFromPoint(X, Y)
If dragging Then
   'Check if the new input position is outside of
   'the current selection. If it's not, do not
   'copy the text
   If Not (gblStart<=pos And gblStart + gblLength>pos) Then
      TXTextControl1.SelText = ""
      If pos < gblStart Then
         TXTextControl1.SelStart = pos
      Else
         TXTextControl1.SelStart = pos - gblLength
      End If
      TXTextControl1.LoadFromMemory data, 3, True
   End If
   'End dragging
   dragging = False
   MousePointer = vbNormal
   TXTextControl1.EditMode = 0
End if


Report Designer - An Advanced Example

This sample program shows you how to build a report designer with TX Text Control. It has separate windows for header, footer and report data. Variables can be entered in any of the 3 windows which are later filled in from a database. Besides displaying data, fields can also be used to perform simple calculations. All of Text Control's formatting options are available to make the report visually appealing.

The Northwind database which is included with Visual Studio 6 is used as a sample database.

The source code for this example is contained in the Samples\vb6\Report sample source directory.

Quick Users Guide
Programming Details
How it Works


Quick Users Guide

After starting the Report application, select File/Open... and load the sample report designer template nwindarticle.txr.

Click on the

button to generate a report from the template and the attached Northwind sample database. The report will be displayed in a seperate child window:

The report can be saved as an Adobe PDF file by selecting the File / Export to PDF menu item, or can be printed. Although not shown in this sample program, it would be as easy to save a report in Microsoft Word, HTML or RTF format. The following screen shot shows the sample report saved as a PDF file and displayed in Adobe Reader:

If you wish to design your own reports, select File/New from the menu. Use the Report/Open Database menu item to select the desired table or query from the nwind.mdb database.

Add some database fields by selecting their field name in the toolbar and pressing the Add button.

To add a sum field you have to select a database field in the template and press the Sum button in the toolbar. The field's name will change to sum(<field name>).

You can also add a page counter anywhere in the report. Set the caret to the desired text position and press the double cross button in the toolbar. A field named page$ will be inserted

For additional formatting there is a context menu. Press the right mouse button in the designer to activate it.


Programming Details

The program is an MDI application which has two different types of child forms. The first one, frmEditLayout, is a simple report designer in which you can add database fields, tables and static text to the three areas of a report. The second form named frmPreview will display the generated document.

When opening the sample document via the File Open... menu item the program opens the designer form and the corresponding database, the nwind.mdb located in your Visual Basic 6 bin directory. If the database could not be found, it opens a file open dialog where you can specify the location of the database.


How it Works

A report is created in 3 steps:

  • Fields contained in the header are replaced by data from the respective database fields. The header is then copied to the preview control.
  • The template from the middle part of the designer form is used to create an entry for each record in the database.
  • The footer is added to the document.

A function similar to the one used in the MailMerge sample program replaces the field contents with data from the database:

[Visual Basic 6]
Sub Merge(rs As Recordset, TXDest As TXTextControl, _
            Sums As Collection, orgdata As Variant)
   Dim id As Integer
   Dim i As Integer
   Dim data As String
   Dim TypeID As DAO.DataTypeEnum
   Dim FieldName As String
   Dim sumField As SumaryField
   ' reload original content
   TXDest.ResetContents
   TXDest.LoadFromMemory orgdata, 3, False
   id = TXDest.FieldNext(0, 0)
   ' Now fill all fields with data
   While id <> 0
      FieldName = TXDest.FieldData(id)
      If FieldName = "page$" Then
         data = CStr(frmEditLayOut.numPages)
      ElseIf Left$(FieldName, 4) = "sum(" Then
         ' summary field found
         Set sumField = Sums(Mid(FieldName, 5,_
                         Len(FieldName) - 5))
         data = FormatData(sumField.value,_
                sumField.DataType)
      Else
         data = FormatData(rs(FieldName),_
                         rs(FieldName).Type)
      End If
      TXDest.FieldCurrent = id
      TXDest.FieldText = data
      TXDest.FieldDelete False
      ' remove the fields to increase insertion speed
      id = TXDest.FieldNext(0, 0)
   Wend
   ' Next i
End Sub

The function handles three types of fields, which are page number, sum and database field.

Sum fields are updated for each database record in turn, so the value of these fields is always the sum of all records up to the current row of the recordset. Database fields are simply replaced by the contents of the current record. To increase the performance of the report engine, all fields are converted to plain text before they are appended to the report. This is done by calling the FieldDelete method with False as a parameter. The original contents are saved and loaded back in for each database record. This is done in the DoReport function:

[Visual Basic 6]
Public Sub DoReport()
   On Error GoTo err_Report
   Dim headerheight, footerheidth, dataheight As Long
   Dim docheight As Long
   Dim ext() As Long
   Dim Sums As New Collection
   numPages = 1
   bCancel = False
   ...
   ' save the original content of the report
   BackupTXFields orgHeaderContent, orgDataContent, _
                   orgFooterContent
   ' summary field found
   CheckForSumFields Sums
   frmPreview.TXTextControl1.ResetContents
   frmPreview.TXTextControl1.Visible = False
   Merge rs, TXHeader, Sums, orgHeaderContent
   ext = TXHeader.GetTextExtent()
   headerheight = GetTextHeight(TXHeader)
   InsertHeader
   footerheight = GetTextHeight(TXFooter)
   ' calculate the remaining document height
   docheight = frmPreview.TXTextControl1.PageHeight _
                  - frmPreview.TXTextControl1.PageMarginT _
                  - frmPreview.TXTextControl1.PageMarginB _
                  - headerheight
   While (rs.EOF = False And bCancel = False)
      UpdateSums Sums, rs
      Merge rs, TXData, Sums, orgDataContent
      data = TXData.SaveToMemory(3, False)
      ext = TXData.GetTextExtent()
      dataheight = GetTextHeight(TXData)
      ' does the footer fit on the page ?
      docheight = docheight - dataheight
      ' does the footer fit on the page ?
      If (docheight) <= footerheight Then
         Merge rs, TXFooter, Sums, orgFooterContent
         Merge rs, TXHeader, Sums, orgHeaderContent
         DoNextPage
         ' reset the remaining document height
         docheight = frmPreview.TXTextControl1.PageHeight _
                        - frmPreview.TXTextControl1.PageMarginT _
                        - frmPreview.TXTextControl1.PageMarginB _
                        - headerheight - dataheight
      End If
      b = frmPreview.TXTextControl1.LoadFromMemory(data, _
                  3, True)
      rs.MoveNext
      ...
   Wend
   ...
   RestoreTXFields orgHeaderContent, orgDataContent, _
                     orgFooterContent
   Exit Sub
err_Report:
   MsgBox Err.Description
End Sub

The lines of code which handle the display of a progress dialog, but have no effect on the functionality of the report generation, have been omitted for clarity.

The LoadFromMemory method is used to insert document parts into the generated report. By calling the GetTextExtent method, we can determine the height of the inserted part. This is required to calculate the number of database records fitting on one page. If the page end is reached, the DoNextPage function is called which appends the footer to the current page, inserts a page break and adds a new header on the following page.


XML Basics

The purpose of this chapter is to help you get started with Text Control Enterprise and its XML features. It will show you how to open an XML file, and how to use it in conjunction with a CSS style sheet and a DTD.

There is a more detailed description of Text Control's XML related properties and methods in the Technical Articles section, see Working with XML Files.

The source code for this example is contained in the Samples\vb6\XMLBasics sample source directory.

The Sample Program
The XML File
The CSS File
The DTD File


The Sample Program

The sample program has only one menu item, which is Open File. Looking at the source code reveals nothing unusual: The main difference to the Open File routine in other Text Control sample programs is the Load method's Format parameter. It has a value of 10 to indicate that we want to laod an XML file:

[Visual Basic 6]
With CommonDialog1
   .Filter = "*.xml"
   .Flags = cdlOFNFileMustExist Or cdlOFNHideReadOnly
   .CancelError = True
   .ShowOpen
   If .FileName <> "" Then
      TXTextControl1.Load .FileName, , 10
   End If
End With

There is quite a bit happeing behind the scenes, however. If you load the TestFile.xml sample file, Text Control will not only load the xml file, but will

  • automatically validate it using the enclosed DTD, and
  • format it according to the CSS stylesheet provided.

Let us take a closer look at the 3 files involved.


The XML File

The XML file contains a simple list of addresses:

<?xml version="1.0"?>
<? XML:stylesheet type="text/css" href="address.css"?>
<!DOCTYPE address SYSTEM "address.dtd">
<address>
   <address_record>
      <name>Paul</name>
      <street>Baker Street</street>
      <city>London</city>
      <email>paul@hotmail.com</email>
   </address_record>
   <address_record>
      <name>George</name>
      <email>george@hotmail.com</email>
   </address_record>
</address>

Note that, unlike an HTML or RTF file, an XML file does not contain any information about how the text is to be displayed or formatted.


The CSS File

In line 2 of the XML file (above), you can see a reference to a stylesheet file called address.css. This CSS file tells Text Control that an address entry should be displayed as a table, and that the individual elements are table cells, having a 1 pixel wide border and a font size of 1 point:

address { display: table }
address_record { display: table-row}
name, street, city, email {	display: table-cell; border: 1px; font-size: 11pt }

When you load address.xml with the sample program, Text Control will display it according to this stylesheet.

Changing the CSS file can make the text appear in a completely different way. For instance, a list can be used instead of a table, as in this example:

name {	display: block; font-size: 14pt; color: blue }
street, city, email { display: list-item; font-size: 11pt}

This is how Text Control will display the XML data using the new sylesheet:


The DTD File

The DTD specifies which elements may occur in an XML file, and in which way the elements should be ordered or nested. The sample DTD specifies that an address contains one or more address_record elements, which in turn can contain a name, street, city, and email. street and city are defined as optional elements.

<!ELEMENT address ( address_record+ )>
<!ELEMENT address_record ( name, street?, city?, email )>
<!ELEMENT name (#PCDATA )>
<!ELEMENT street (#PCDATA )>
<!ELEMENT city (#PCDATA )>
<!ELEMENT email (#PCDATA )>

When loading an XML file, Text Control checks whether the XML code is valid, i.e. adheres to the rules specifed in the DTD. An error will occur if it does not, like in this example, where the required <name> has been removed:

<?xml version="1.0"?>
<? XML:stylesheet type="text/css" href="address.css"?>
<!DOCTYPE address SYSTEM "address.dtd">
<address>
   <address_record>
      <street>Baker Street</street>
      <city>London</city>
      <email>paul@hotmail.com</email>
   </address_record>
</address>

Loading the above XML code will raise an error:

This strict error checking is considered one of the major strengths of XML, as it ensures that a document will always have a certain structure, and thus can be processed by other applications.


Editing in XML Mode

This chapter looks at some of the differences between normal text editing and editing an XML file.

The source code for this example is contained in the Samples\vb6\XMLEditing sample source directory.

The Sample Program

Run the sample program and load the demo file address_list.xml. You will notice that there is now a button bar with 3 combo boxes:

You don't need to create the combo boxes yourself, they are built into Text Control's Button Bar.

The first combo box displays the style of current XML field. If you move down the caret by pressing the down arrow key, the display will change from name to street, city and email, depending on what type of field you are in.

With the second combo box, additional XML fields can be inserted.

You can select to either insert a complete address record, or one of the optional elements, which are street and city. Depending on the DTD, not all elements can be inserted at all positions. For instance, if you click on the name Paul in the first line of the document, and try to insert a street, an error will occur, because this record already contains a street. Try again with Ringo, and it will work.

The third combo box is for deleting XML fields. Again, every action is checked with the DTD, so that you can be sure not to invalidate your document by, for instance, deleting a required field.


Quote Generator - XML Version

This chapter is about an XML version of the Quote Generator sample program. The main task of a Quote Generator is to automatically create documents from database records. A record from an address database and one or more records from an article database are combined with a template file to form a quote.

Program wise, Marked Text Fields are used to insert address, date and various other bits of information. Tables are used to list the quoted articles with their prices and descriptions, and to do calculations like adding VAT and computing a total. A custom file format capable of handling all this is required for the template files.

While this works fairly well, it would be much easier to create this type of application if there were a single technology that would combine all the features of Marked Text Fields, tables and a custom file format. And that's where XML comes in.

The source code for this example is contained in the Samples\vb6\XMLQuote sample source directory.

Creating a Quote from a Database

When the program is started, it displays an address database in a data bound grid control.

Selecting the File/New Quote menu item takes the current record from the database and creates a document from it. This is done in the following way:

A form containing a Text Control is opened, and a template is loaded. A template is an XML file that contains all text parts that are equal to all documents, for instance a phrase like "In reply to your inquiry and according to our general terms of business we are pleased to..". It has a corresponding DTD file, which defines what elements can be inserted by the user and a CSS file that defines fonts, font sizes, and layout, so that all files will have the same look.

Once the template has been loaded, additional information is filled in from the, so that the quote now contains the real address, name, customer number, and date. This is done by directly accessing XML elements.

Filling in the data is done by directly accessing the respective XML fields. In this code snippet, the customer number and current date are being entered:

[Visual Basic 6]
.tx.XMLElements("customer_no_value").Item(1).Text = sCustomerID
.tx.XMLElements("date_value").Item(1).Text = sDate

All that is left to do for the user is to select the articles to be quoted.

Note that the article table actually is a set of XML elements. The table structure that you see is only defined by the style sheet. If you save the quote as an XML file and load it with a text editor, this is what a row of the article table looks like:


Using Multiple Controls

Running the Sample Program
How it Works
Saving the Controls
Printing Multiple Controls
Setting Scrollbars and Text Area


Running the Sample Program

This chapter shows how to use Text Control in programs which have several text fields placed on a single page. Think of a program to print labels, to fill out forms, or to mask data entry. The Forms1 sample program, which can be found in the Samples\vb6\Forms1 subdirectory provides the basic functionality for applications of this kind.

Initially, when the program is started, the main window contains one framed Text Control where text can be entered. The rest of the window is empty.

What you can do with the program is:

  • Move the Text Control and dragging the window with the mouse.
  • Resize the Text Control by pressing the ALT key and dragging the window borders with the mouse.
  • Create additional controls by clicking on an empty part of the main window.
  • Save, load or print.

To keep things simple, there are no scrollbars in the main window and no menu items except the ones listed above. Scrollbars, zoom and a few other features will however be added in the next chapter.


How it Works

The Forms1 sample uses a control array for the text fields. The first Text Control, the one which you see when you start the program, is placed on the form at design time. More controls are created when you click on an empty area of the form. These controls are created dynamically with the Visual Basic Load function when a MouseDown event occurs on the form:

[Visual Basic 6]
Private Sub Form_MouseDown(Button As Integer, _
      Shift As Integer, X As Single, Y As Single)
   MaxID = MaxID + 1
   Load TXTextControl1(MaxID)
   TXTextControl1(MaxID).Move X, Y
   TXTextControl1(MaxID).Visible = True
   TXTextControl1(MaxID).ZOrder
End Sub

Clicking on an existing text field brings it to the front. This is done by changing the Z order when a Click event has occurred:

[Visual Basic 6]
Private Sub TXTextControl1_Click(Index As Integer)
   TXTextControl1(Index).ZOrder
End Sub

The global variable MaxID counts the total number of controls; It is initialized to a value of 1 when the form is loaded.

Moving and resizing the controls is done by Text Control itself. To enable these functions, the SizeMode property must be set to 3 - Move and Sizeable.


Saving the Controls

Saving a document which has been created with this program necessitates storing not only the data contained in the Text Controls, but also the number and the positions of the controls. In addition, a format identifier should be stored to enable the load routine of the program to determine if it can process a file which it is about to load. The code on the following page shows you how to save the document.

[Visual Basic 6]
Private Sub mnuFile_SaveAs_Click()
   On Error Resume Next
   Dim i As Integer, FileID As Long
   Dim xPos As Single, yPos As Single
   Dim xSize As Single, ySize As Single
   ' Create a "Save File" dialog box
   CommonDialog1.Filter = "TX Form Demo (*.txf)|*.txf"
   CommonDialog1.DialogTitle = "Save As"
   CommonDialog1.Flags = cdlOFNOverwritePrompt Or _
      OFNHideReadOnly
   CommonDialog1.CancelError = True
   CommonDialog1.ShowSave
   If Err Then Exit Sub
   ' Open the file
   Open CommonDialog1.filename For Binary As #1
   If Err Then
      MsgBox "Can't open file: " + CommonDialog1.filename
      Exit Sub
   End If
   ' Write file header consisting of file format ID
   ' and number of controls
   FileID = FILE_ID
   Put #1, , FileID
   Put #1, , MaxID
   ' Save the position of all Text Controls
   For i = 1 To MaxID
      xPos = TXTextControl1(i).Left
      yPos = TXTextControl1(i).Top
      xSize = TXTextControl1(i).Width
      ySize = TXTextControl1(i).Height
      Put #1, , xPos
      Put #1, , yPos
      Put #1, , xSize
      Put #1, , ySize
   Next i
   Close #1
   ' Save the contents of all Text Controls
   For i = 1 To MaxID
      TXTextControl1(i).Save CommonDialog1.filename
   Next i
End Sub

The Load routine first reads the format ID and the number of controls. Then it creates the required number of controls, loads their contents and finally moves them to their correct position:

[Visual Basic 6]
Private Sub mnuFile_Load_Click()
   On Error Resume Next
   Dim i As Integer, lFilePos As Long
   Dim FileID As Long, xPos As Single, yPos As Single
   Dim xSize As Single, ySize As Single
   ' Create an Open File dialog box
   CommonDialog1.Filter = "TX Form Demo (*.txf)|*.txf"
   CommonDialog1.DialogTitle = "Open"
   CommonDialog1.Flags = cdlOFNFileMustExist Or _
      cdlOFNHideReadOnly
   CommonDialog1.CancelError = True
   CommonDialog1.ShowOpen
   If Err Then Exit Sub
   ' Open the selected file
   Open CMDialog1.filename For Binary As #1
   If Err Then
      MsgBox "Can't open file: " + CommonDialog1.filename
      Exit Sub
   End If
   ' Read file header
   Get #1, , FileID
   If FileID <> FILE_ID Then
      MsgBox "Wrong file type: " + CommonDialog1.filename
      Close #1
      Exit Sub
   End If
   ' Destroy existing controls
   For i = 2 To MaxID
      Unload TXTextControl1(i)
   Next i
   ' Create text controls and load their contents
   Get #1, , MaxID
   For i = 1 To MaxID
      Get #1, , xPos
      Get #1, , yPos
      Get #1, , xSize
      Get #1, , ySize
      If i <> 1 Then Load TXTextControl1(i)
      TXTextControl1(i).Move xPos, yPos, xSize, ySize
      TXTextControl1(i).Text = ""
   Next i
   lFilePos = Loc(1)
   Close #1
   For i = 1 To MaxID
      lFilePos = TXTextControl1(i).Load _
         CommonDialog1.filename, lFilePos)
   Next i
End Sub


Printing Multiple Controls

Printing a document is quite straightforward. The PageWidth and PageHeight properties are set to a value of 0 at design time, so the controls are printed like they are formatted on the screen. The PageMargin properties are used to specify the positions of the controls on the page.

[Visual Basic 6]
Private Sub mnuFile_Print_Click()
   Dim i As Integer
   Printer.Print
   For i = 1 To MaxID
      TXTextControl1(i).PrintDevice = Printer.hDC
      TXTextControl1(i).PageMarginL = TXTextControl1(i).Left
      TXTextControl1(i).PageMarginT = TXTextControl1(i).Top
      TXTextControl1(i).PrintPage 1
   Next i
   Printer.NewPage
   Printer.EndDoc
End Sub


Setting Scrollbars and Text Area

By default, a newly created Text Control will have a vertical scrollbar, and will scroll down if you enter more text than fits into the window. If an applications requires text input to be restricted to the visible area of the text window, this can be changed by setting the ViewMode Property to "4 - Simple Control".

The complete source code of the Forms1 sample program is contained in the Samples\vb6\Forms1 sample source directory.


A Forms Filler

The Sample Program
Adding ButtonBar, Ruler and StatusBar
Displaying the Background Image
Working with Transparent Text Controls
Zooming


The Sample Program

With the Forms1 sample program, you can place text fields at arbitrary positions on a page. When you print the page, the text fields appear on the paper at exactly the same positions where they were previously placed on the screen. These features will be used in the following sample to create a program for filling out pre-printed forms.

The scanned image of the form is shown in the background of the screen, enabling the user to easily determine the positions of the filled-out fields. He has only to click (with the CTRL key pressed) on the area of the form where he wants to put text and then start typing. The fields can be moved and resized afterwards by holding down the ALT key and dragging them with the mouse.

The source code for this example is contained in the Samples\vb6\Forms2 sample source directory.


Adding ButtonBar, Ruler and StatusBar

The Button Bar, Ruler and Status Bar are used in a special way in this sample program. If you run the program and click on various fields you will notice that the tools automatically switch to the text field which has been clicked on. This switching is done internally by Text Control, so no programming is required for it. The tools are simply connected to the first member of the Text Control array at design time.


Displaying the Background Image

The background image is displayed by an Image Control. You could also use the Visual Basic PictureBox for this, but the PictureBox can not handle the large image files which result from scanning a full document page, and it does not support the TIFF file format, which is used by most scan programs.

The Image Control is not a separate custom control, but a child window of the Text Control. To display the background image, create a Text Control which has the size of the whole page, and then load an image using Text Control's ObjectInsertAsChar method.

The Text Control which displays the background image has an additional function, which again saves a lot of programming work. It acts as a container for the Text Controls which are used as fill-out fields. (A container control enables you to draw other controls within it at design time. Examples of container controls are frames and picture boxes). The big advantage of a container is that it handles all of the clipping for the controls which have been created on top of it. Otherwise, scrolling the background image would cause the text fields to overwrite anything that lies within the form's boundaries, like Button Bar, Ruler Bar, and even the scrollbars. It would require many calculations of field positions and sizes and some direct calls to the Windows DLLs on every scroll and resize event to do the clipping without a container control. Using the background Text Control as a container, you need only create the first text field inside of it, and everything else is done automatically.


Working with Transparent Text Controls

Run the program, load a background image and create a few text fields by clicking on this background image. You will notice that the text fields are transparent, so you can see the background image below. Using this feature in a program requires some fine-tuning of the clipping areas with the ClipChildren and ClipSiblings properties.

These two properties determine which areas of an image are repainted when a new part of a control becomes visible or when its contents have been changed. For example, if one control is covered by another, it only has to be repainted if the one which lies on top of it is transparent. You will always want to repaint as little as possible to make the application run fast and to avoid unnecessary flickering on the screen. Furthermore you will not want your computer to spend time drawing things which are not visible.

For maximum flexibility in setting the clipping areas and mixing transparent and opaque controls, two properties have been implemented which share this task:

The ClipChildren property is used only for Text Controls which act as a container for other Text Controls. When ClipChildren is set to True, the areas occupied by the child controls are excluded from the update area. So, if as in the forms filler program, transparent controls are used as children of the container control, this property must be set to False.

The ClipSiblings property determines the behaviour between each of the child controls. It must be set to False if the program allows transparent Text Controls to overlap others.


Zooming

Zooming is simply done by setting the ZoomFactor property of each of the Text Controls:

[Visual Basic 6]
Private Sub mnuView_ZoomItem_Click(Index As Integer)
   Dim nZoom As Integer, i As Integer
   nZoom = Val(Mid$(mnuView_ZoomItem(Index).Caption, 2))
   TXTextControl2.ZoomFactor = nZoom
   For i = 1 To MaxID
      TXTextControl1(i).ZoomFactor = nZoom
   Next i
   For i = 1 To 5
      mnuView_ZoomItem(i).Checked = (i = Index)
   Next i
End Sub


Internet Explorer User's Guide

This chapter describes how to use TX Text Control with the Microsoft Internet Explorer.

Browser Based vs. Traditional Applications
Creating ActiveX Documents in Visual Basic
Using Text Control with HTML and VBScript
How to obtain a code signed CAB File


Browser Based vs. Traditional Applications

Traditional applications need to be installed on every single computer on a network. Each time a new computer is added, or a hard disk has crashed, the system administrator has to walk to that machine, insert all the CDs, and re-install all the programs. This makes up a major part of what IT managers call "total cost of ownership" - the manpower required to keep a network of computers up and running.

One of the most promising ways to solve this problem is to let all software run in a browser. The process works pretty much like with the browser plugins for audio files or PDF documents: When you click one of these files for the first time, the appropriate plugin is downloaded and installed, and the file can be processed instantly.

Of the various ways to create browser based applications, two are especially well suited for working with ActiveX controls, like Text Control:

If you are a Visual Basic programmer, you will find it straightforward to use ActiveX documents. ActiveX documents are created with Visual Basic 6, just like normal .exe programs. This is shown in Creating ActiveX Documents in Visual Basic.

If you feel more comfortable writing HTML code, then you will prefer to insert Text Control as an ActiveX object into your HTML page, and do the programming with a script language. You don't need any special tools for this, just a simple text editor. Using Text Control with HTML and VBScript shows you how to do it.


Creating ActiveX Documents in Visual Basic

Creating a new Project
How it Works
Creating a CAB File
Editing the HTML File
Running the Program


Creating a new Project

To create an ActiveX Document, start Visual Basic and select ActiveX Document Exe in the New Project dialog box.

Then continue adding a Text Control to your project and writing code, just as if you were to create a Standard EXE application.


How it Works

The code (below) is the complete source code for our first sample program. If you compare it to a similar VB sample program which runs as an .exe, you will notice 2 differences:

  • The toolbars are connected in the UserDocument_Initialize Event, instead of the Form_Load event.
  • Loading and saving files is done through the Property Bag. For detailed information about Property Bags and ActiveX document programming in general, refer to the VB documentation, and search http://www.msdn.microsoft.com/ for ActiveX Document.
[Visual Basic 6]
Private Sub mnuAbout_Click()
   frmAbout.Show vbModal
End Sub
Private Sub TXTextControl1_Change()
   PropertyChanged "TextData"
End Sub
Private Sub UserDocument_Initialize()
   TXTextControl1.ButtonBarHandle = TXButtonBar1.hWnd
   TXTextControl1.StatusBarHandle = TXStatusBar1.hWnd
   TXTextControl1.RulerHandle = TXRuler1.hWnd
End Sub
Private Sub UserDocument_Resize()
   TXTextControl1.Height = ScaleHeight _
      - TXButtonBar1.Height - TXStatusBar1.Height _
      - TXRuler1.Height
End Sub
Private Sub UserDocument_ReadProperties(PropBag As PropertyBag)
   Dim TextData() As Byte
   TextData = PropBag.ReadProperty("TextData", "")
   TXTextControl1.LoadFromMemory TextData, 9
   UserDocument_Resize
End Sub
Private Sub UserDocument_WriteProperties(PropBag As PropertyBag)
   Dim TextData() As Byte
   TextData = TXTextControl1.SaveToMemory(9)
   PropBag.WriteProperty "TextData", TextData
End Sub


Creating a CAB File

Text Control comes with a pre-built CAB file, but, as we need to create a CAB file for the ActiveX document anyway, we simply include the Text Control files there, and do not use the pre-built CAB.

The CAB file is created with Visual Basic's Package and Deployment Wizard. Having started it, follow these steps:

  • Select the project file, which is ..\Ie\ActiveX Document\Project1.vbp for the sample program.
  • Click on Package, and then select Internet Package.

The Wizard will create a CAB file, a document file, and a HTML file. All required Text Control files will be included automatically.


Editing the HTML File

The HTML file which has been generated by the Package and Deployment Wizard needs to be edited, so that it will properly register the Text Control ActiveX. The VB documentation states that the HTML file is only required if you use Internet Explorer 3, and that you can use the .vbd file instead if you have IE 4 or later. However, this is not true if the document contains ActiveX controls. ActiveX controls need to be included by their class ID in an Object tag. This is the modified HTML code:

<HTML>
<HEAD>
   <TITLE>Project1.CAB</TITLE>
</HEAD>
<BODY>
Loading ...
<OBJECT ID="UserDocument1"
   CLASSID="CLSID:ab949ac0-ec97-11d9-9e2b-004005a9abd2"
   CODEBASE="Project1.CAB#version=9,9,9,9">
</OBJECT>
<SCRIPT LANGUAGE="VBScript">
Sub Window_OnLoad
   Document.Open
   Document.Write "<FRAMESET>"
   Document.Write "<FRAME SRC=""UserDocument1.VBD"">"
   Document.Write "</FRAMESET>"
   Document.Close
End Sub
</SCRIPT>
</BODY>
</HTML>


Running the Program

Having modified the HTML code, the 3 files can be put anywhere on your local hard disk, on a file server, or on a HTTP server. All that a user has to do in order to start the program is to point his browser to the HTML file. Internet Explorer will automatically download and install the CAB file, and start the program.


Using Text Control with HTML and VBScript

The Object Tag
Step 1 - Displaying a Text Control on a HTML Page
Step 2 - Programming with VBScript
Step 3 - Handling Events
Step 4 - Loading a File
Step 5 - Printing
Step 6 - Working with CAB Files


The Object Tag

As an alternative to creating ActiveX Documents with Visual Basic, Text Control can also be used directly as an ActiveX object in HTML code. To include a Text Control in HTML code, it is declared as an object:

<OBJECT
  classid="clsid:ab949ac1-ec97-11d9-9e2b-004005a9abd2"
  id=objTX
  width=600
  height=400
  >
  <PARAM NAME="ViewMode" VALUE="2">
  <PARAM NAME="ScrollBars" VALUE="3">
  <PARAM NAME="PageWidth" VALUE="12240">
  <PARAM NAME="PageHeight" VALUE="15840">
</OBJECT>

The "classid=" statement specifies Text Control's class ID, which Internet Explorer can use to locate it. (Note that this declaration requires that a Text Control has already been installed on your computer. We will later add a CAB file reference so that it can automatically be loaded and installed from a file server or the Internet.) The "id=objTX" statement assigns a name to the object which is used to access it from program code. The remaining lines set the width and height, and assign some initial values to some of Text Control's properties.


Step 1 - Displaying a Text Control on a HTML Page

Little more than the <OBJECT> tag is required in order to display a Text Control on a HTML page. Only the minimum HTML declarations need to be added:

<HTML>
<HEAD>
  <TITLE>A Simple First Page</TITLE>
</HEAD>
<BODY>
<OBJECT
  classid="clsid:ab949ac1-ec97-11d9-9e2b-004005a9abd2"
  id=objTX
  width=600
  height=400
  >
  <PARAM NAME="ViewMode" VALUE="2">
  <PARAM NAME="ScrollBars" VALUE="3">
  <PARAM NAME="PageWidth" VALUE="12240">
  <PARAM NAME="PageHeight" VALUE="15840">
  <PARAM NAME="Text" VALUE="Text Control running in Internet Explorer">
</OBJECT>
</BODY>
</HTML>

The code shown here is contained in Step1.htm in the \IE\HTML sample source directory. Open the file in Internet Explorer to run the sample program.


Step 2 - Programming with VBScript

Having created a Text Control object on our HTML page, we now need a way to access its methods and properties. Internet Explorer supports VBScript, which is a subset of the Visual Basic programming language. All you need to create a VBScript program is a text editor, and the VBScript Language Reference which is available for download on Microsoft's web site.

As a simple example on how VBScript works, we add a button to our sample program from Step 1, and let it write some text in the Text Control window when you click on it.

A button is created in the BODY section of our HTML page like this:

<FORM>
  <INPUT NAME="Button1" TYPE="BUTTON" VALUE="Click me!">
</FORM>

In the HEADER part, we add some VBScript code to process the button's OnClick event:

<SCRIPT LANGUAGE="VBScript">
<!--
Sub Button1_OnClick
  objTX.Text = "Thanks for clicking me!"
End Sub
-->
</SCRIPT>

When the button is clicked on, the script code is executed and assigns some text to Text Control's Text property. All of Text Control's properties and methods can be used like this.

The code shown here is contained in Step2.htm in the \IE\HTML sample source directory.

Now you probably want to add a ButtonBar or a StatusBar. This is a little tricky in IE. There is no event like the Form_Load event in VB. You can't use the <BODY onLoad="..."> event, this is called before the two objects have been created.

But Text Control offers a solution. You can use the BODY onLoad event to set the ButtonBarHandle to 1. This tells TX that you want to set these handle when all controls have been created. So, Text Control fires an event called ConnectTools, when it's ready to receive the handles. The code to do that looks like the following:

<HTML>
   <HEAD>
      <TITLE>A Simple First Page</TITLE>
      <SCRIPT LANGUAGE="VBScript">
      <!--
      Sub Load()
         objTX.ButtonBarHandle = 1
      End Sub
      Sub objTX_ConnectTools()
         objTX.ButtonBarHandle = objBB.hWnd
      End Sub
      -->
   </SCRIPT>
</HEAD>
<BODY onLoad="Load()">

Where objBB is the ButtonBar object. The class ids for the additional ActiveX controls are:

Button Bar: clsid:ab949ac9-ec97-11d9-9e2b-004005a9abd2
Status Bar: clsid:ab949ad1-ec97-11d9-9e2b-004005a9abd2
Ruler Bar:  clsid:ab949acd-ec97-11d9-9e2b-004005a9abd2

Another way to solve this special problem is to build a custom ActiveX control that wraps the TextControl and/or a Button Bar/Status Bar/Ruler Bar.

The code shown here is contained in Step2.htm in the IE\HTML sample source directory.


Step 3 - Handling Events

If you are familiar with Visual Basic, then you should have no problem setting up event handlers in a web page. Event handlers are code that is called when a particular action is performed on or performed by a component. For example, let's say that you wish to perform an action whenever the user clicks on a field in the TX Text Control. You would setup an event handler for the FieldClicked event as follows:

<SCRIPT ID="EventHandlers" LANGUAGE="vbscript">
<!--
   Sub objTX_FieldClicked(ByVal FieldId)
      msgbox "A field has been clicked. Field identifier: " & FieldId
   End Sub
-->
</SCRIPT>

We recommend that script code that accesses components always be placed after the object tags of OCX components. But this is not necessary with event handler code as this code will not be called until a component is initialized.

Since Internet Explorer's VBScript does not support variable types, you cannot use variables such as Long, Boolean, Double, Integer, etc in your code. All variables in VBScript are Variants. Therefore, the following code would be incorrect and would generate a script error.

Sub objTX_FieldClicked(ByVal FieldId as Integer)

Use the following code instead, omitting any "as Integer" or other variable types...

Sub objTX_FieldClicked(ByVal FieldId)

Anyway, the parameter of the FieldClicked event can be easily accessed by VBScript, because it casts automatically the variable into the correct variable type.

The code shown here is contained in Step3.htm in the IE\HTML sample source directory.


Step 4 - Loading a File

Now that we know how to display a Text Control and access its properties, we can take care of some of the functions required in most word processing applications, which are file handling and printing.

To load a file, we first need to display a Common Dialog box which lets the user select the file to be opened. The common dialog box is added to the HTML page as an ActiveX object, just like the Text Control in Step 1:

<OBJECT
  classid="clsid:F9043C85-F6F2-101A-A3C9-08002B2F49FB"
  id=objComDlg
  >
</OBJECT>

In our button's OnClick event, we call objComDlg.ShowOpen to show the dialog box, and then, after the user has selected a filename, open the file in Text Control.

Sub Button1_OnClick
   on error resume next
   objComDlg.Filename = ""
   objComDlg.Filter = "Microsoft Word Format " & _
         "(*.doc)|*.doc|" & _
         "Rich Text Format (*.rtf)|*.rtf|" & _
         "Hypertext Markup Language " & _
         "(*.htm, *.html)|*.htm;*html|" & _
         "Text Documents (*.txt)|*.txt"
   objComDlg.ShowOpen
   if err.number = 0 then
      If UCase(Right(objComDlg.FileName, 3)) = "DOC" Then
         objTX.Load objComDlg.Filename,0,9,0
      elseIf UCase(Right(objComDlg.FileName, 3)) = "RTF" _
      Then
         objTX.Load objComDlg.Filename,0,5,0
      elseIf UCase(Right(objComDlg.FileName, 3)) = "HTM" _
      or UCase(Right(objComDlg.FileName, 4)) = "HTML" Then
         objTX.Load objComDlg.Filename,0,4,0
      else
         objTX.Load objComDlg.Filename,0,1,0
      end if
   end if
End Sub

The code shown here is contained in Step4.htm in the IE\HTML sample source directory.


Step 5 - Printing

Printing works pretty much like loading a file: We first open a Common Dialog box (this time with objComDlg.ShowPrint instead of objComDlg.ShowOpen), and then pass the selected settings on to Text Control's PrintDoc method.

The code shown here is contained in Step5.htm in the IE\HTML sample source directory.


Step 6 - Working with CAB Files

One of the advantages of letting your application run in a web browser (instead of as a stand-alone .exe) is that there is no need to install it on each of the client's computers. This would be, of course, of little use if you still need to install Text Control. For this reason, Text Control is also available as a CAB file, which is automatically downloaded and installed when needed. Two changes are required to our sample program of Step 4 in order to make use of the CAB file

1. An additional OBJECT tag is inserted for a .lpk file. This file is not Text Control specific, but includes license information for all ActiveX controls you use on a HTML page in encrypted form. It must be in the same directory as the .html file.

<OBJECT CLASSID="clsid:5220cb21-c88d-11cf-b347-00aa00a28331" VIEWASTEXT>
  <PARAM NAME="LPKPath" VALUE="tx.lpk">
</OBJECT>

The .lpk file can be created by using a program called Lpk_tool.exe, which is included in the Microsoft ActiveX SDK that is available for download from www.microsoft.com.

2. TX Text Control's OBJECT tag is extended by a reference to the CAB file. You can put the CAB file anywhere on a file server or on a web server. The codebase = statement (below) needs to be updated with the respective path to the CAB file on your server.

<OBJECT
  classid="clsid:ab949ac1-ec97-11d9-9e2b-004005a9abd2"
  codebase="http://myserver.com/.../tx.cab"
  id=objTX
  width=600
  height=400
  >
  <PARAM NAME="ViewMode" VALUE="2">
  <PARAM NAME="ScrollBars" VALUE="3">
  <PARAM NAME="PageWidth" VALUE="12240">
  <PARAM NAME="PageHeight" VALUE="15840">
  <PARAM NAME="Text" VALUE="TX Text Control ActiveX in Internet Explorer">
</OBJECT>

You may like to test this sample application, running from your own hard disk. Depending upon where you have installed TX Text Control, the path to the CAB file in the object tag should look something like this:

codebase="file:///C:/Program Files/The Imaging Source Europe GmbH/TX Text Control 12.0/Cab/TX.CAB"

The code shown here is contained in Step6.htm in the IE\HTML sample source directory.


How to obtain a code signed CAB File

Text Control's setup program has copied a CAB file to your Program Files\...\TX Text Control\Cab folder. This CAB file includes all required Text Control files, and is suited for most applications, including a distribution in an intranet or from a file server.

However, it has not been code signed, and therefore Internet Explorer will issue a security warning when you install it from the Internet.

A code-signed CAB file which can be installed without generating such warnings is available free of charge at http://www.textcontrol.com/in/CabFileRequest.htm.


ASP User's Guide

Demonstrates the usage of the TX Text Control features in the Microsoft Internet Information Server with ASP.

Using Text Control with ASP and VBScript
Prerequisites
Simple Sample Programs
Online Store - An Advanced ASP Example


Using Text Control with ASP and VBScript

This chapter shows you how to use Text Control on a server.

When running on a server, Text Control is switched to a special mode so that it does not have a user interface. There is no editing window, no toolbars and no ruler. No dialog boxes nor error messages will be displayed. It is completely invisible to the user, and all editing and processing is done from code.

At first glance it may seem strange to have an editor running where it is hidden from the user, but there are many applications where documents need to be processed from code rather than interactively:

  • Documents can be assembled from various sources, like text files (ASCII, RTF, HTML, DOC, XML) and image files (BMP, TIFF, WMF, JPEG, PNG, GIF).
  • Information can be filled in from a database. An example for this is the automatic generation of nvoices and order confirmations, as shown in the Online Store sample program.
  • Documents can be converted to RTF, HTML, DOC or PDF, and then either saved to a file or database, or sent via email or HTTP.
  • XML data can be converted to HTML and other formats on-the-fly. Documents can be stored in a single format, and converted as requested by users.
  • Batch processing and batch printing of large volumes of documents is supported.
  • All word processing functions normally available from menu items and dialog boxes can be applied from code. Options include find&replace, fonts, paragraph indents and alignment, inserting tables and images, and many more. Just like a piece of text is selected with the mouse, it can be selected from code, for instance to underline it or change its text color.

Instead of the word processor interface common to client applications, server based programs often communicate with the user via HTTP. The user enters some information on a web page, which is sent to the server, processed on the server, and then sent back as, say, a PDF file containing an invoice. Some applications may not have a user interface at all, for instance when used for batch processing of large amounts of files, or batch print jobs.


Prerequisites

Internet Information Server (IIS) needs to be installed in order to run Text Control in server mode. It can be run on a dedicated server, or by simply activating IIS on the developer's computer. An application can be developed and tested on a single computer, and later moved to a dedicated server. Text Control supports IIS, version 5 or higher, running on Windows 2000, Windows XP or Windows Server 2003.


Simple Sample Programs

Installing the Samples
Creating a Text Control in a Server Side Script
Generating Dynamic Content
Step 1 - Generate a PDF File
Step 2 - Insert a Table
Step 3 - Format Text
Step 4 - Format Tables
Step 5 - Merge multiple Documents
Step 6 - Print a Document
Performance Considerations
What Comes Next


Installing the Samples

To run the installed sample code, you have to set up a virtual directory in your Internet Information Server. To do so, perform the following steps:

  • Start the Internet Information Server Administration Tool. The location of this tool depends on the operating system.
  • Select Default Web Site in the left tree view and then the Action/New/ Virtual Directory... menu item. This will start a wizard.
  • On the first page, Virtual Directory Alias, specify tx as an alias name and press the Next button.
  • On the second page, Web Site Content Directory, select the Samples\Asp subdirectory found in your TX Text Control installation path. Press the Next button.
  • On the third page, Virtual Directory Access Permissions, enable Write permission for the virtual directory and press Finish.

Now you can test the installation by opening your browser and browsing to http://<your_machine_ip>/tx, where <your_machine_ip> is the IP address or host name of your server. The index page index.htm located in the Samples\Asp subdirectory is shown.


Creating a Text Control in a Server Side Script

An instance of a Text Control is created by calling the Server.CreateObject function:

Dim lc, tx
set lc = Server.CreateObject("TIS.TX.LicManager.12")
set tx = Server.CreateObject("TIS.TX.TextControl.12")
tx.EnableAutomationServer

Before creating the Text Control object, a license manager object must be created that reads Text Control's license information from the registration data base. This information is necessary to create a Text Control object.

The EnableAutomationServer method initializes the Text Control object as an automation server. The remaining lines set the width, height and page margins of a Text Control document.


Generating Dynamic Content

One of the most common tasks for a web developer, is to write dynamic document content. In some cases, it is necessary to generate print-ready documents, for example invoices or quotes. The following steps 1 to 6 illustrate some of these tasks with short example scripts. The scripts can all be found in the Samples\Asp\Simple subdirectory, named step1.asp to step6.asp.


Step 1 - Generate a PDF File

The first sample script, step1.asp, begins with a few lines of code which show how to generate PDF documents on-the-fly.

Dim lc, tx
set lc = Server.CreateObject("TIS.TX.LicManager.12")
set tx = Server.CreateObject("TIS.TX.TextControl.12")
tx.EnableAutomationServer
...
tx.Text = "The quick brown fox jumps over the lazy dog."
' Save in Adobe pdf format (format identifier 12)
tx.Save Server.MapPath("demo.pdf"), 0, 12

The sample code above creates a document with the given text and writes it to the server as a PDF file. The output of the script provides a link to the generated document. You need Adobe Reader to view this file in your browser.

Please note the call to the MapPath method of the Server object. This method converts a virtual file name to the fully qualified path of the file system. Without the MapPath call TX Text Control would try to write he file to the current directory, because it cannot handle virtual file names. Due to the access restrictions of the anonymous internet user, calling the Save method would fail, as this user does not have permission to write to the current directory.

The format identifiers used with the Save method are listed in the reference description for this method.


Step 2 - Insert a Table

In the second step, step2.asp, a more advanced document is generated. A table is inserted and its cells are filled with text.

tx.TableInsert 2, 2, -1, 11	' inserts a 2x2 table
tx.TableCellText(11, 1,1) = "Cell 0,0"
tx.TableCellText(11, 1,2) = "Cell 0,1"
tx.TableCellText(11, 2,1) = "Cell 1,0"
tx.TableCellText(11, 2,2) = "Cell 1,1"

The TableInsert method is used to add a table to the generated document. The last parameter of this method is a unique identifier for the table. This identifier can be used to alter the table or its cells dynamically. The example uses this identifier as a parameter to TableCellText to address the previously inserted table.

Furthermore there is also another interesting code fragment that deals with PDF output. As you can see, the generated document is not saved in a file. The sample script sends the PDF output directly to the client's browser:

binPDF = tx.SaveToMemoryBuffer (binPDF, 12, 0)
Response.Clear
Response.ContentType = "application/pdf"
Response.BinaryWrite(binPDF)

With the SaveToMemoryBuffer method the document is stored in a memory buffer identified through the binPDF variable. Using this it is possible to send the whole document to the client's browser. It also could be encoded and sent as attachment via e-mail.


Step 3 - Format Text

This third step shows how text can be formatted. With Text Control's text formatting properties, the complete layout of a document can be controlled.

tx.FormatSelection = true
tx.FontSize = 17
tx.FontName = "Times New Roman"
tx.SelText = "TX Text Control Step 3" & vbCrLf

This example alters the font name and size at the current input position and inserts a line of text. The new line is formatted with the previously specified attributes. You can also select a text fragment with the SelStart and SelLength properties and alter any attribute of a character or paragraph after inserting text. For a detailed overview of all properties that handle formatting attributes see Programming Categories - Character Formatting and Programming Categories - Paragraph Formatting.


Step 4 - Format Tables

TX Text Control offers full control of table layout, like border width, background color, and distances between a cell's text and its border. The code in the fourth example formats each cell of the table added in step 3, using the TableCellAttribute property.

tx.ObjectInsertAsChar 0, Server.MapPath("x.jpg"), _
            tx.TableCellStart(11, 1 ,1)-1, 100,100, 0, 1
tx.TableCellAttribute(11, _
            1, 1, txTableCellHorizontalExt) = 1500
tx.TableCellAttribute(11, _
            1, 1, txTableCellRightBorderWidth) = 20
tx.TableCellAttribute(11, _
            1, 1, txTableCellBottomBorderWidth ) = 20
tx.TableCellAttribute(11, _
            1, 1, txTableCellTextGap) = 50

This code first inserts an image at the first position of the first cell. The ObjectInsertAsChar method inserts an image that acts like a character.

ObjectInsertAsChar expects the text position at which the image is to be inserted as its third parameter. The table's first cell is modified with the TableCellAttribute property. The width of the cell is set to 1500 twips, a border is set for the right and the bottom of the cell, and cell padding of 50 twips is set. There are many more possibilities to manipulate a table's layout. See Programming Categories - Tables for more information.


Step 5 - Merge multiple Documents

A very useful feature of TX Text Control is the capability to merge documents with different text formats into one document. For instance, you can generate a new document from code and add a Microsoft Word document or a document formatted with another supported format to this document. There are several cases when such a feature is useful, e.g. generating an invoice and adding legal information to it.

The following code fragment sets the current input position to the end of the current document and appends the demo document installed with the TX Text Control installation program:

tx.SelStart = Len(tx.Text)
tx.SelLength = 0
' add a page break
tx.SelText = Chr(12)
' insert the demo document
tx.Load Server.MapPath("demo.rtf"), 0, 5, true

As you can see, the Load method has three additional parameters, besides the file name of the document. The first specifies the zero-based file position from where the data is to be read (in this case 0, because the complete demo document is added). The second specifies the format identifier and the last parameter is a boolean value, which must be set to True if a document is to be inserted. Otherwise, if set to False the merged document would replace the current document.


Step 6 - Print a Document

Sometimes you need to print a generated document on the server, e.g. to generate an invoice. VBScript does not support the Visual Basic printer object or any similiar functionality to select printers, paper bins etc. It is possible, however, to send your document to the default printer. This can be achieved with the following single line of code:

...
tx.PrintDoc "ASP Document Title", 1, tx.CurrentPages(), 1
...

The PrintDoc method prints the contents of the Text Control to the system's default printer. The first parameter specifies the document's title in the printer's queue, the following are the first and the last page to print. The last parameter specifies the number of copies. This sample code can be found in the 'step6.asp' sample script.

If you want to print to a file, add a printer driver to your system, which supports the desired output format, e.g. a Postscript driver. Add a new Local Port to your printer configuration and specify a file name for the port, e.g. c:\out.ps. The output of this printer driver is redirected to the specified file. The file will be overwritten each time you print to this printer driver.


Performance Considerations

A Text Control should be used in page scope to achieve the maximum performance. Page scope means, that a Text Control is created for a single Active Server Page and will be alive until this page is processed.

It is not recommended to use a Text Control in session or application scope, because this can decrease the performance of Internet Information Server. The Session or Application object will be locked down to a single thread.


What Comes Next

The next sample, Online Store, will demonstrate the functionality of TX Text Control in a real world application.

For additional information on how to integrate special features, have a look at the source code of the Visual Basic sample programs. Almost all Text Control properties and methods can be used with the exception of those needing a visible surface like dialog boxes, toolbars and all features manipulating the display of a document. For a list of properties and methods that cannot be used, see Technical Articles - Server Programming.


Online Store - An Advanced ASP Example

This example shows how to use TX Text Control to create documents on-the-fly without any server-side user interaction. It uses input information from a web site, creates a document and returns a print-ready PDF document. You will find this sample in the Samples\Asp\OnlineStore directory.

The Sample Program

The example environment is an online store shopping cart where the user can specify the quantity of articles in the cart. After specifying the postal address and pressing the Order button, the data is used to create an order confref_descirmation on the server. The data is sent to the server using the HTTP POST variables where the ASP script creates a Text Control object.

<form action="create_confirmation.asp" method="post" ID="Form1">

First of all, a template document is loaded that already contains the design of the invoice. The template generation is omitted for clarity in this sample. If you want to know more about template generation, please have a look at the Mail Merge sample in the Visual Basic User's Guide.

' Load a template file
tx.Load Server.MapPath("template.tx")
' Merge the marked text fields with the posted data
tx.FieldCurrent = 1
tx.FieldText = request.form("company")
tx.FieldCurrent = 2
tx.FieldText = request.form("street")

Mail merge is then performed on the fields already present in the template, filling them with values like name or address. The fields were inserted with the template generator and they are used as placeholders for the form's data. For a detailed ref_descoverview of all text field capabilities see Technical Articles - Marked Text Fields.

Now it is time to put the ordered items into a table. The table is also an element of the template document. For each item whose quantity is greater than zero, a new line is inserted into the table and the item's product description is copied to ref_descthe new row.

For i = 1 To request.form("article_amount")
   If(request.form("article" + CStr(i) + "_qty") <> 0) Then
      tx.SelStart = tx.TableCellStart(TableID, _
               tx.TableRows(TableID), 1)
      tx.TableInsertLines 2, 1
      tx.TableCellText(TableID, CurrentRow, 1) = _
               request.form("article" + CStr(i) + "_qty")
      tx.TableCellText(TableID, CurrentRow, 2) = _
         request.form("article" + CStr(i) + "_ordernumber")
      tx.TableCellText(TableID, CurrentRow, 3) = _
         request.form("article" + CStr(i) + "_description")
      article_sum = request.form("article" _
                     + CStr(i)+"_qty") _
               * request.form("article" + CStr(i) + "_price")
      TotalSum = TotalSum + article_sum
      tx.TableCellText(TableID, CurrentRow, 4) = _
                  FormatNumber (article_sum, 2) & " US $"
      CurrentRow = CurrentRow + 1
   End If
Next

Finally, the grand total is calculated and copied to the last row in the table. The final step is to use the SaveToMemoryBuffer method to save the document in the desired format to a local buffer which isref_desc sent to the user via Response.BinaryWrite. In this case we are going to save in PDF.

' Write the contents as a PDF document to a variable and
' return it to the client
OutputBuffer = tx.SaveToMemoryBuffer(OutputBuffer, 12, 0)
Response.Clear
Response.ContentType = "application/pdf"
Response.AddHeader "Content-Disposition", "attachment; filename=order.pdf"
Response.BinaryWrite(OutputBuffer)


Delphi User's Guide

Shows you how to install and use TX Text Control with Borland Delphi.

Installing TX Text Control with Delphi
Upgrading from a Previous Version of TX Text Control
Creating a Simple Word Processor
Working with Files
Printing
Using Marked Text Fields
A Word Processor
Using Text Control with a Database
Using Images
Mail Merge
Headers and Footers
Hypertext Links
Drag and Drop
Using Multiple Controls
A Forms Filler


Installing TX Text Control with Delphi

TX Text Control must be re-imported in the Delphi development environment if

  • A prior TX Text Control has been updated.
  • The TX Text Control trial version has been replaced by the full version.

In one of these cases perform all steps described in the next section Upgrading from a Previous Version of TX Text Control.

If you import TX Text Control in Delphi for the first time, see the chapter Creating a Simple Word Processor and the next chapter New Installation with Delphi 6 and 7.

New Installation with Delphi 6 and 7

To import TX Text Control in Delphi 6 or 7, a Delphi unit is contained in the TX Text Control installation.

In the Delphi development enviroment choose Install Component from the Component menu entry. On the first tab of the opened dialog, click the first Browse... button to insert the TX Text Control unit.

Navigate to the Delphi 6-7 subfolder contained in your TX Text Control installation directory, choose the Tx4oleLib_TLB.pas file and click on Open. Confirm the settings with OK.

The dclusr.dpk package has been opened. Click on Compile to build the package. After that, close the package.

A new tab "TX Text Control" has been created in the Component Palettes containing all 4 controls of TX Text Control.


Upgrading from a Previous Version of TX Text Control

When upgrading from a previous version or from a trial version of TX Text Control, please perform the following steps to ensure a proper installation.

  • Start Delphi.
  • From the File menu, choose Open.... The Open... dialog box appears.
  • Load the package file containing the TX Text Control ActiveX component. The package files are:
  • Delphi 7: ..\Borland\Delphi7\Lib\dclusr.dpk
  • Delphi 6: ..\Borland\Delphi6\Lib\dclusr.dpk
  • Delphi 5: ..\Borland\Delphi5\Lib\dclusr50.dpk
  • Delphi 4: ..\Borland\Delphi4\Lib\dclusr40.dpk
  • Delphi 3: ..\Borland\Delphi3\Lib\dclusr30.dpk
  • After choosing one of these files, click Open.
  • The Package workspace appears.

for Delphi 4, 5, 6, 7:

  • Click the Remove button.
  • The Remove From Project dialog appears. Choose the files Tx4OleLib_TLB.dcr and Tx4OLELib_TLB.
  • Click OK to remove these files from the package.
  • Click the Compile button.
  • Click Yes to confirm that the package will be re-compiled. A message informs that the TX Text Control components are no longer registered. Confirm this with OK.
  • Delphi 4 and 5: Import the new TX Text Control version with the menu item Component - Import ActiveX Control....
  • Delphi 6 and 7: Import the new TX Text Control version as described in the chapter New Installation with Delphi 6 and 7.

for Delphi 3:

  • Choose the files Tx4OleLib_TLB.dcr and Tx4OLELib_TLB.
  • Click Remove. The files will be removed from the package. Click Compile.
  • A message informs that the TX Text Control components are no longer registered. Confirm this with OK.
  • From the File menu, choose Save.
  • Import the new TX Text Control version with the menu item Component - Import ActiveX Control....


Creating a Simple Word Processor

This chapter shows you how to create a small word processor from scratch with just a few lines of code. It will be able to load and save files, use the clipboard, and will have dialog boxes for character and paragraph formatting, a ruler, a status bar and full keyboard and mouse interface.

The source code for this example is contained in the Samples\Delphi\Simple sample source directory.

Creating the Project
Creating the Controls
Connecting the Controls
Running the Program
Setting the Page View
Resizing the Controls
Adding a Menu
What Comes Next


Creating the Project

Assuming that you have already run the Text Control installation program and started Delphi, the next step is to create a project for the text processor.To do this begin by selecting the New Application command from the file menu. If you have already imported TX into Delphi, its icons are shown when the ActiveX tab is selected. Otherwise, click on Controls / Import ActiveX... and choose the TX Text Control from the given list. Click Install and then OK until all dialogs have been closed. Now you will see the following four additional icons when the ActiveX tab is selected:

The Text Control Icon

The Status Bar Icon

The Button Bar Icon

The Ruler Icon


Creating the Controls

The next step is to put these four controls on a form and connect them. Click on the Text Control icon and draw it on the form. In the same way, create a Ruler and a Button Bar on top of the Text Control, and a Status Bar below it. Your form should now look like this:


Connecting the Controls

Add the following code to the form's FormShow event procedure:

procedure TForm1.FormShow(Sender : TObject);
begin
   TXTextControl1.ButtonBarHandle := TXButtonBar1.hWnd;
   TXTextControl1.RulerHandle := TXRuler1.hWnd;
   TXTextControl1.StatusBarHandle := TXStatusBar1.hWnd;
end;


Resizing the Controls

Two steps are involved in making the controls resize properly when the main window is resized.

Set the Align property to alTop for the Button Bar, the Ruler and the Text Control. Set it to alBottom for the Status Bar. This will adjust everything except the height of the Text Control.

Change to the events listing in the property window and double-click the OnResize event. The code window should show an empty procedure for the Resize event:

procedure TForm1.FormResize(Sender: TObject);
begin

end;

Extend it as follows:

procedure TForm1.FormResize(Sender: TObject);
begin
   TXTextControl1.Height := ClientHeight
      - TXRuler1.Height - TXStatusBar1.Height
      - TXButtonBar1.Height;
   TXTextControl1.Width := ClientWidth;
   TXRuler1.Width := ClientWidth;
end;

This line of code will cause the Text Control's height and width to be adjusted every time the size of the form is altered.


Adding a Menu

In this chapter, you will add a menu to the text processor to enable you to call the Text Control's built-in dialog boxes.

Use the Delphi Menu Component to create a Format menu with the items Character... and Paragraph.... (Please refer to the Delphi documentation if you need help with creating menus).

Add the following code to the Click procedures of the menu items:

procedure TForm1.Character1Click(Sender: TObject);
begin
   TXTextControl1.FontDialog
end;
procedure TForm1.Paragraph1Click(Sender: TObject);
begin
   TXTextControl1.ParagraphDialog;
end;

Start the program again. You should be able to use the menu items to call the Font and Paragraph dialog boxes.

Now for the Edit menu. Again use the Menu Design Window and create an 'Edit' menu containing items for Cut, Copy and Paste. The code for these menu items is:

procedure TForm1.Cut1Click(Sender: TObject);
begin
   TXTextControl1.Clip (1);
end;
procedure TForm1.Copy1Click(Sender: TObject);
begin
   TXTextControl1.Clip (2);
end;
procedure TForm1.Paste1Click(Sender: TObject);
begin
   TXTextControl1.Clip (3);
end;

Having added these menu items, you can exchange formatted text with other word processors via the clipboard.

The last menu for now shall be a simple file menu. Create a File menu including the items Load... and Save As.... Place a common dialog box icon on the form and enter the following code, which will call the common dialog box to get a file name from the user, and will then load respectively save the selected file:

procedure TForm1.Load1Click(Sender: TObject);
const
   TXT_FIlE = 1;
   TXM_FILE = 3;
begin
   OpenDialog1.Title := 'Open file';
   OpenDialog1.Filename := '';
   OpenDialog1.Filter :=
      'Text Control Demo (*.txm)|*.txm
         |Plain text(*.txt)|*.txt';
   OpenDialog1.FilterIndex := 1;
   If OpenDialog1.Execute then begin;
   // Pass the filename to the text control
   If UpperCase(copy(OpenDialog1.Filename,
      length(OpenDialog1.filename)-2, 3)) = 'TXM' then begin
      TXTextControl1.Load(OpenDialog1.Filename, 0,
         TXM_FILE, 0);
   end
   else
      TXTextControl1.Load(OpenDialog1.Filename, 0,
         TXT_FILE, 0);
   end;
end;
procedure TForm1.Saveas1Click(Sender: TObject);
const
   TXM_FILE = 3;
begin
   SaveDialog1.Title := 'Save as ...';
   SaveDialog1.Filename := '';
   SaveDialog1.Filter := 'Text Control Demo (*.txm)|*.txm';
   SaveDialog1.FilterIndex := 1;
   SaveDialog1.DefaultExt := 'txm';
   if SaveDialog1.Execute then begin;
      // Pass the filename to the text control
      TXTextControl1.Save(SaveDialog1.Filename, 0,
         TXM_FILE, 0);
   end;
end;


What Comes Next

It goes, of course, without saying that Text Control has many more features than those included in our little demo program. It is up to you now to include zoom, images, tables, OLE objects, paragraph frames and whatever else makes up a full-blown word processor. If you need some hints about how to integrate special features, have a look at the source code of the other sample programs or post a message in the TX Text Control support forum at http://www.textcontrol.com.


Working with Files

Text Control uses 7 different file formats:

  • Its own, native format, which you would normally use to store data in document files.
  • The Rich Text Format (RTF), which can be used to exchange formatted text with other applications.
  • HTML
  • XML
  • Microsoft Word format
  • Unformatted text in ANSI or Unicode format.
  • Adobe PDF. This file format can only be used for exporting your documents.

An example of how to use the native file format has already been presented in the previous chapter. Using RTF, HTML, Word or unformatted text is just as simple: Just specify the format you want to use as a parameter of the Load or Save method.

Using RTF, HTML, Word and unformatted text, you can only read or write the contents of a single Text Control from or to a file. Using the native file format, however, you can write a file header prior to saving the Text Control data, or even write the contents of several Text Controls to one file.

The Forms1 sample program, which is described in the section Using Multiple Controls, shows you how to write the contents of multiple Text Controls to a single file. The MDIDemo sample shows you how to write a file header prior to the Text Control's data and how to use RTF, HTML, Word and unformatted text.


Printing

Delphi provides a printer object that can be used to print the contents of a Text Control.

The following example sends the contents of a Text Control, which can be several pages long, to the default printer:

Example Code

procedure TForm1.Print1Click(Sender: TObject);
var wPages, No : Integer;
begin
   wPages := TXTextControl1.CurrentPages;
   Printer.BeginDoc;
   for No := 1 To wPages do begin
      TXTextControl1.PrintDevice := Printer.Canvas.Handle;
      TXTextControl1.PrintPage(No);
      if No <> wPages then
         Printer.NewPage;
   end;
   Printer.EndDoc;
end;

After storing the number of pages in a local variable called wPages, the printer object is initialized with the Printer.BeginDoc statement. The For .. do loop runs from 1 to wPages to print all of the pages. Inside the loop there are three lines of code which print a single page:

  • The device context handle of the printer object is assigned to Text Control's PrintDevice property. Without this step, a device context which is compatible to the screen device would be used, resulting in poor print quality.
  • The number of the page to be printed is passed as a parameter to the PrintPage method. This will also start the printing process.
  • The printer object's NewPage method is invoked to advance to the next page if there is one left.

Everything else, like calculating the line and page breaks, is done internally by Text Control. The formatting is based on the values of two groups of properties:

  • PageHeight and PageWidth determine the dimensions of the printed page.
  • PageMarginB, PageMarginL, PageMarginR and PageMarginT determine the print margins.

These properties are normally set in a page setup dialog box.


A Simple Example

This first sample program will show you how fields are created and what happens when they are clicked on. The code shown here is contained in the Samples\Delphi\Field1 sample source directory.

The program consists of a form with just one menu item, Insert Field!, with an exclamation mark to say that clicking on this item will cause an immediate action instead of dropping a menu. There are two Text Controls on the form, one of which is used as a normal text window (TXTextControl1), the other one as a pop-up window (TXTextControl2).

The following code is executed when the menu item is clicked on:

procedure TForm1.Insertfield1Click(Sender: TObject);
begin
   TXTextControl1.FieldInsert ('-------');
   TXTextControl1.FieldEditAttr[
      TXTextControl1.FieldCurrent] := $10 + $2 + $1;
end;

This inserts a field at the current caret position and sets its attributes, so it is displayed with a gray background and a second input position in front of and right behind a field.If you move the cursor over the field, Text Control changes the mouse pointer to an upward pointing arrow to indicate that there is something to click on.

If you click on the field, the application receives a FieldClicked event, to which it responds by popping up a window which displays the field number.

Only five lines of code are required for this:

procedure TForm1.TXTextControl1FieldClicked(Sender: TObject;
   FieldIndex: Smallint);
begin
   TXTextControl1.FieldCurrent := FieldIndex;
   TXTextControl2.Text := 'This is field no. '
      + InttoStr(FieldIndex) + '. Its text is: '
      + TXTextControl1.FieldText;
   TXTextControl2.Left :=
      toPixels(TXTextControl1.FieldPosX);
   TXTextControl2.Top :=
      toPixels(TXTextControl1.FieldPosY);
   TXTextControl2.BringtoFront;
end;

The first line selects the marked text field which has been clicked on. Line 2 builds the string that is to be displayed in the pop-up window. Line 3 and 4 moves the pop-up window, which is initially hidden behind the text window, to the position of the marked text field. Line 5 puts the pop-up window in front of the text window to make it visible. When the mouse button is released, the text window is moved to the front again:

procedure TForm1.TXTextControl1MouseUp(Sender: TObject;
   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
   TXTextControl1.BringtoFront;
end;


Bookmarks

This example shows you how to use Text Control's marked text fields to create bookmarks. The first version will reference the bookmarks simply by their field numbers. The source code for this example is contained in the Samples\Delphi\Field2 sample source directory.

The sample application has a Bookmark menu with two items which are named Insert and Go to.... Clicking Insert creates a marked text field at the current caret position. If a text selection exists, the selected text is converted into a field. If not, the character next to the caret is selected.

procedure TForm1.Insert1Click(Sender: TObject);
var
   fieldID : Integer;
begin
   If TXTextControl1.Text = '' Then
      Application.MessageBox ('Cannot insert a bookmark
         if the Text Control is empty.','ERROR',MB_OK)
   Else begin
      If TXTextControl1.SelLength = 0 Then
         TXTextControl1.SelLength := 1;
      TXTextControl1.FieldInsert ('');
      fieldID := TXTextControl1.FieldCurrent;
      TXTextControl1.FieldEditAttr[fieldID] :=
            $10 + $2 + $1;
   end;
end;

After typing in some text and inserting a few bookmarks, select the Go To... menu item. This will launch a dialog box which allows you to enter the number of the bookmark to jump to. There is no error processing in this example, so if you enter the number of a non-existent field, nothing will happen.

Clicking the OK button executes the following procedure:

procedure TfrmGoto.Button1Click(Sender: TObject);
begin
   Form1.TXTextControl1.FieldCurrent :=
      StrtoInt(Edit1.Text);
   Form1.TXTextControl1.SelStart :=
      Form1.TXTextControl1.FieldStart - 1;
   Form1.TXTextControl1.SelLength :=
      Form1.TXTextControl1.FieldEnd
         - Form1.TXTextControl1.FieldStart + 1;
   Close;
end;

The number which has been entered in the dialog box is taken as a value for the FieldCurrent property.


Adding Strings to Marked Text Fields

The source code for this example is contained in the Samples\Delphi\Field3 sample source directory.

In commercial word processors, bookmarks are normally referenced by names, not just by numbers. The names are typed in by the user when he creates a bookmark. The Goto Bookmark dialog box then presents a listbox or combobox in which one of the strings can be selected.

The Insert Bookmark... menu item in this version of the program creates a dialog box where the user can enter a label for the bookmark.

When the OK button is clicked, the following code is executed:

procedure TfrmInsert.btnOKClick(Sender: TObject);var fieldID : Integer;
begin
   If Form1.TXTextControl1.SelLength = 0 Then begin
      If Form1.TXTextControl1.SelStart
         = Length(Form1.TXTextControl1.Text) Then
      begin
         Form1.TXTextControl1.SelText := ' ';
         Form1.TXTextControl1.SelStart :=
            Form1.TXTextControl1.SelStart - 1;
      end;
      Form1.TXTextControl1.SelLength := 1;
   end;
   // Insert a field and store the bookmark name in its
   // FieldData property
   Form1.TXTextControl1.FieldInsert ('');
   fieldID := Form1.TXTextControl1.FieldCurrent;
   Form1.TXTextControl1.FieldEditAttr [fieldID] :=
         $10 + $2 + $1;
   Form1.TXTextControl1.FieldData
      [Form1.TXTextControl1.FieldCurrent] := Edit1.Text;
   Form1.TXTextControl1.SelLength := 0;
   Close;
end;

First, a marked text field is created at the current caret position. Second, the name of the bookmark, which is the text that has been typed in by the user, is stored in the FieldData property.

The Goto Bookmark dialog box contains a combo box which lists all of the bookmarks which have been created so far.

The combo box is filled with the bookmark titles when its form is loaded:

procedure TfrmGoto.FormShow(Sender: TObject);
var
   nfieldID : Integer;
begin
   nFieldID := 0;
   cboBookmark.Clear;
   // Fill the combobox with bookmarks
   Repeat
      nFieldID := Form1.TXTextControl1.FieldNext(
            nfieldID, 0);
      If nFieldID > 0 Then
         cboBookmark.Items.Add(
            Form1.TXTextControl1.FieldData[nFieldID])
   Until nFieldID = 0;
   // Copy first item to the edit control part of the
   // combo box
   cboBookmark.Text := cboBookmark.Items.Strings[0];
end;

When the OK button is clicked, the bookmark list is searched for the string which has been selected in the combo box, and the corresponding marked text field is selected.

procedure TfrmGoto.Button1Click(Sender: TObject);
var
   nFieldID : Integer;
label
   Exit;
begin
   nFieldID := 0;
   // Search for the requested bookmark
   Repeat
      nFieldID := Form1.TXTextControl1.FieldNext(
            nFieldID, 0);
      If nFieldID > 0 Then begin
         If Form1.TXTextControl1.FieldData[nFieldID] =
            (cboBookmark.Text) Then
         begin
            Goto Exit;
         end;
      end;
   until nFieldID = 0;
   Exit:
   // If the bookmark has been found, select it.
   // Text Control will then automatically scroll
   // to make it visible
   If nFieldID <> 0 Then begin
      Form1.TXTextControl1.FieldCurrent := nFieldID;
      Form1.TXTextControl1.SelStart :=
         Form1.TXTextControl1.FieldStart - 1;
      Form1.TXTextControl1.SelLength :=
         Form1.TXTextControl1.FieldEnd
         - Form1.TXTextControl1.FieldStart + 1;
      end
   Else
      Application.MessageBox(
         'Bookmark not found.','ERROR',MB_OK);
   Close;
end;

You can also extend the sample program with a dialog box, similar to the Go To Bookmark... dialog, in which a bookmark can be deleted without deleting the text. This would require converting the Marked Text Field to normal text. Use the FieldDelete method to achieve this.

More information about marked text fields and a list of all properties, methods and events that can be used with marked text fields, can be found in the chapter Technical Articles - Marked Text Fields.


A Word Processor

This chapter shows you how to use Text Control to write a standard word processor.

The source code for this example is contained in the Samples\Delphi\MDIDemo sample source directory.

Adding a PageSetup Dialog Box
A Print Dialog Box
Search and Replace
Using Paragraph Frames
Dialog Boxes for Text and Background Color


Adding a PageSetup Dialog Box

The Page Setup dialog box is used to determine the page size and print margins. The maximum page size is restricted by the capabilities of the default printer. For implementation details, look at the source code of the frmPageDlg form.


Dialog Boxes for Text and Background Color

This is also done with Common Dialogs. The color value returned from the dialog box is assigned to the BackColor property.


Using Text Control with a Database

This chapter describes how to use Text Control to access databases with the Delphi TDBNavigator control. If you are not familiar with the TDBNavigator control please refer to the Delphi documentation.

The source code for this example is contained in the Samples\Delphi\Database sample source directory.

The Sample Program

The sample uses the LoadFromMemory and SaveToMemory methods to store data to the database and vice versa. Not only is the plain text stored, but also all formatting information, e.g. font and paragraph attributes, colors and image file names. The data is stored in RTF format, which is easiest to handle.

The Database sample program is connected to a small data base which contains descriptions of some of Text Control's properties. You can browse through the records of the data base by clicking the TDBNavigator control buttons on the lower left side of the window. If you want to change something in the current record, press the button with the triangle.


Using Images

TX Text Control provides three different methods for inserting images:

  • The ImageInsert method is the default method for inserting images. An image inserted with this method will be anchored to a paragraph. Text can flow around the image, and the image will move with the paragraph.
  • Images inserted with the ImageInsertAsChar method are handled like a single character in the text. This method is often used for inserting small images and icons.
  • The ImageInsertFixed method inserts an image at a fixed position on the page. The image will keep its position regardless of the surrounding text.

Images can be inserted from a file or from the clipboard. When saving a document, you can select whether to embed image data in the document file, or save a reference to a seperate image file. Note that not all options are available in all file formats. For instance, while image data can be embedded in RTF and .DOC files, HTML does not provide this option.

Further options are:

  • to convert images to a different file format,
  • to convert embedded images to image files, and
  • to change image resolution and compression rate.

This is especially useful, if you create HTML files, where embedded images and image file formats like WMF or TIFF need to be converted to JPEG or GIF files for display in a browser. Image resolution and compression settings are also required for creating PDF files, for instance to create one version of a PDF with low-resolution images for viewing on screen, and another one with high resolution images for printing.

An overview of all properties, methods and events which can be used in conjunction with images can be found at Images, Text Frames and OLE Objects. Properties which have a name that begins with "Object" can be used with images as well as other kinds of embedded objects, like text frames and OLE objects, whereas those starting with "Image" only apply to images.

Inserting an Image
Setting Image Attributes


Inserting an Image

The source code for this sample program is contained in the Samples\delphi\Images sample source directory.

The TForm1.Insert1Click function shows you how to open a dialog box for selecting an image file, and then insert the image:

[Delphi]
procedure TForm1.Insert1Click(Sender: TObject);
begin
    OpenDialog1.Title := 'Insert Image';
    OpenDialog1.Filename := '';
    OpenDialog1.Filter := TXTextControl1.ImageFilters;
    OpenDialog1.FilterIndex := 1;
    OpenDialog1.Options := [ofPathMustExist, ofFileMustExist, ofHideReadOnly];

    if OpenDialog1.Execute then begin
        try
            TXTextControl1.ImageInsert(OpenDialog1.Filename,-1, 1, 0, 0, 100, 100, 3, 0, 0, 0, 0);
        except
            MessageDlg('Cannot insert image: ' + OpenDialog1.filename + '.', mtError, [mbOK], 0);
        end;
    end;
end;

The image is inserted using the ImageInsert method.


Setting Image Attributes

TX Text Control has a built-in dialog box which enables you to change the size of an image, the way images are stored, and various other settings. In the sample program, the Image Attributes dialog box is invoked either with the Image Settings menu item, or by right-clicking on an image. The dialog box is opened using the ObjectAttrDialog method:

[Delphi]
procedure TForm1.Settings1Click(Sender: TObject);
begin
    TXTextControl1.ObjectAttrDialog;
end;

procedure TForm1.TXTextControl1ObjectRightClicked(Sender: TObject;
    ObjectId: Smallint);
begin
    TXTextControl1.ObjectAttrDialog;
end;


Mail Merge

The chapter Using Text Control with a Database showed you how to store a Text Control's entire contents in a database field. For implementing functions like mail merge, however, the requirements are different: the contents of database fields have to be inserted at specified positions in a previously prepared document. The following sample program provides you with the basis of how to this.

The code shown here is contained in the Samples\Delphi\StdLet sample source directory.

The Sample Program
How it Works


The Sample Program

The program consists of two forms, Form1 for creating a text and Form2 for connecting it to the database.

Start the program and use the File / Open... command to load the sample file account.tx. The file contains three fields which are to be replaced by database entries. Select Insert / Data to access Form2. When you click the Insert button in Form2, the contents of the three database fields are copied to the text fields in Form1. You can select a different record by clicking one of the data control buttons in Form2, and then clicking Insert again to replace the fields.


How it Works

Each of the 3 edit controls on the second form is connected to a field in the database. The data is read from the database in the same way as in the Database sample.The only new thing is copying the data from the edit controls to the text fields in the document. This is done when you click on the Insert button:

procedure TForm2.Button1Click(Sender: TObject);
begin
   Form1.TXTextControl1.FieldCurrent := 1;
   Form1.TXTextControl1.FieldText := Form2.Edit1.Text;
   Form1.TXTextControl1.FieldCurrent := 2;
   Form1.TXTextControl1.FieldText := Form2.Edit2.Text;
   Form1.TXTextControl1.FieldCurrent := 3;
   Form1.TXTextControl1.FieldText := Form2.Edit3.Text;
end;

To implement a real mail merge function you will have to add a dialog box in which the user can select the database to be used. You may also want to provide a variable number of database fields which are dependent on the contents of the selected database.


Headers and Footers

This example shows how to use headers and footers. The source code is contained in the Samples\Delphi\Headers sample source directory.

TX supports headers as well as footers. You also have the ability to create a different header or footer for the first page.

The Sample Program

To insert a header or footer in the example, click on Insert and choose one of the four possible options. The code that is executed when clicking on one of the menu items is almost the same. For the Header menu item it looks as shown below. The line

TXTextControl1.HeaderFooter := TXTextControl1.HeaderFooter + txHeader;

informs Text Control that a header should be added to the current settings.

Setting the HeaderFooterStyle property to txMouseClick enables the user to activate the header with a single click rather than a double-click. Activating a header or footer with a double-click is Text Control's default setting. More information about how to use headers and footers and a list of all properties, methods and events that can be used with headers and footers, can be found in the chapter Technical Articles - Headers and Footers.

When using properties, Text Control distinguishes between the main text and headers or footers. To switch between these different independent text parts, Text Control provides the HeaderFooterSelect method:

TXTextControl1.HeaderFooterSelect (txHeader);
TXTextControl1.SelText := 'Header';
TXTextControl1.HeaderFooterSelect (0);

This code selects the header, so that the following code affects the header and then sets the headers text. Finally the mode is reset to zero using the HeaderFooterSelect method. More information about programming with headers and footers see the chapter Technical Articles - Headers and Footers - Programming Headers and Footers.

A header or footer is activated from programming code using the HeaderFooterActivate method. To delete a header or footer, simply substract the txHeader constant from the current HeaderFooter settings. The following is the complete code of the menu item:

procedure TForm1.Header1Click(Sender: TObject);
begin
   If Header1.Checked = False Then begin
      TXTextControl1.HeaderFooter
         := TXTextControl1.HeaderFooter + txHeader;
      TXTextControl1.HeaderFooterSelect (txHeader);
      TXTextControl1.SelText := 'Header';
      TXTextControl1.HeaderFooterSelect(0);
      TXTextControl1.HeaderFooterActivate (txHeader);
      Header1.Checked := True;
   end Else begin
      TXTextControl1.HeaderFooter
         := TXTextControl1.HeaderFooter - txHeader;
      Header1.Checked := False;
   End;
end;


Hypertext Links

This chapter shows how to use Text Control's marked text fields to insert hypertext links and targets into text documents and how to respond to events which Text Control fires when the user clicks on a hypertext link.

The source code for the following examples is contained in the sub folders Step1 to Step4 of the Samples\Delphi\HyperLnk sample source directory.

Step 1 - Inserting a Hypertext Link
Step 2 - Adding a Dialog Box for Inserting Hypertext Links
Step 3 - Adding Targets
Step 4 - Adding Jumps to External Targets


Step 1 - Inserting a Hypertext Link

In this first sample program a hypertext link will be inserted in a text document. The document is saved then as a HTML file so that it can be viewed in a browser.

Hypertext links are handled as a special type of a marked text field. A hypertext link therefore is inserted by calling the FieldInsert method, and then specifying the type of the field with the FieldType property:

TXTextControl1.FieldInsert ('Text Control Web Site');
TXTextControl1.FieldType[TXTextControl1.FieldCurrent]
   := txFieldExternalLink;

To store the target to where the link points, the FieldTypeData property is used:

TXTextControl1.FieldTypeData[TXTextControl1.FieldCurrent] :=
   'http://www.textcontrol.com';

The following line of code saves the document, containing the hypertext link, which has just been inserted as a HTML file in the sample folder:

TXTextControl1.Save (Application.GetNamePath + '.html',
   0, 4, False);

When this file is loaded with a web browser, the hypertext link will be displayed as specified in your browser's settings. Clicking on the link, will take you to the Text Control web site.

Note that there is no code for the Click events yet, so clicking on the hypertext link in the Text Control will have no effect. Also, the link is neither underlined nor colored.


Step 2 - Adding a Dialog Box for Inserting Hypertext Links

In this second sample program a dialog box is created which enables the user to insert hypertext links in a more convenient way. Additionally, hypertext links which have previously been inserted or loaded from a file, can be edited and modified. Note that, while hypertext links are usually associated with HTML files, they can as well be stored in RTF or Microsoft Word files, or in Text Control's proprietary format.

The dialog box has two text boxes. The first is for the text that represents the hypertext link in the document and the second is for the address, to where the link points. In the step 1 example, the representing text was "Text Control Web Site", and the address, to where the link points, was "http://www.textcontrol.com".

The same dialog box is used for both, inserting a new and editing an existing hypertext link. Depending on whether the current input position is inside of an existing link, this link is modified. Otherwise a new one is inserted.

The dialog form's property, tx is used to pass a Text Control's reference to the form.

procedure TForm1.HypertextLink2Click(Sender: TObject);
begin
   Form2.tx := TXTextControl1;
   Form2.ShowModal;
end;

When the form is loaded, the text boxes are filled with the text and link information when the current input position is inside of an existing link:

procedure TForm2.FormShow(Sender: TObject);
begin
   // If the caret is inside an existing hyperlink,
   // copy the hyperlink's text and link information
   // to the text boxes on the form.
   If (Form1.TXTextControl1.FieldAtInputPos <> 0) Then  begin
      txtLinkedText.Text := Form1.TXTextControl1.FieldText;
      txtLinkTarget.Text :=
         Form1.TXTextControl1.FieldTypeData[
            Form1.TXTextControl1.FieldCurrent];
   end Else begin
      txtLinkedText.Text := Form1.TXTextControl1.SelText;
      txtLinkTarget.Text := '';
   end;
end;

The user then can change the displayed information. The information is then transfered to the document by either inserting a link or modifying the existing one when the OK button is pressed:

If tx.FieldAtInputPos <> 0 Then begin
   // editing an existing hyperlink
   tx.FieldText := txtLinkedText.Text;
   tx.FieldType[tx.FieldCurrent] := txFieldExternalLink;
   tx.FieldTypeData[tx.FieldCurrent] := txtLinkTarget.Text;
end Else begin
   // insert new hyperlink
   tx.FieldInsert (txtLinkedText.Text);
   tx.FieldType[tx.FieldCurrent] := txFieldExternalLink;
   tx.FieldTypeData[tx.FieldCurrent] := txtLinkTarget.Text;
   HighlightHyperlinks (tx, Form1.HypertextLinks1.Checked);
End;

Finally, there is a menu item to switch the character format of the hyperlink's text to blue colored and underlined style. The menu item calls the function HighlightHyperlinks, which is defined in the file Unit3.pas.


Step 3 - Adding Targets

Step 1 and 2 only handle references to external resources, i.e. addresses of web pages or files. In this step, links to positions in the same document will be handled. These links are called internal links and the positions, to where they point, are called targets. Targets are also referred to as anchors (in the context of HTML editors) or bookmarks (in word processors). When using this example, first add some text and then some targets with the Insert / Target... menu item. Finally use the Insert / Hypertext Link... menu item to add links to these targets.

1. Inserting a Target:

Targets are realized again as a special type of a marked text field. The type and the target's name must be set with the FieldType and the FieldTypeData properties.

Unlike links, targets have no visible text, therefore an empty field must be inserted with the FieldInsert method to insert a target:

procedure TForm1.Target1Click(Sender: TObject);
var
   TargetName : String;
begin
   TargetName := InputBox('Target name:',
         'Insert target', '');
   If TargetName <> '' Then begin
      TXTextControl1.FieldInsert ('');
      TXTextControl1.FieldType[TXTextControl1.FieldCurrent]
            := txFieldLinkTarget;
      TXTextControl1.FieldTypeData[
            TXTextControl1.FieldCurrent]
               := TargetName;
   End;
end;

Only one text box is required to display the name of a target, so a simple InputBox statement can be used.

2. Inserting Links to Targets:

To insert links to the just inserted targets, the Hypertext Link dialog box is extended with a list box showing the names of all targets the document contains. The FieldNext method is used to fill this list box:

Procedure TForm2.FillListboxWithTargets(Sender : TObject);
var
   FieldID : Integer;
begin
   ListBox1.clear;
   FieldID := tx.FieldNext(0, $100);
   While FieldID <> 0 do begin
      ListBox1.Items.Add(tx.FieldTypeData[FieldID]);
      FieldID := tx.FieldNext(FieldID, $100);
   end;
end;

When the user selects a target, the Link To field is filled with the target's name.

After typing the link's text and pressing the OK button, the link is inserted. An internal link is inserted in the same way as the external links from step 1, but the FieldType property now is set to txInternalLink and the FieldTypeData property is set to the target's name.

3. Jumping to a Target:

After inserting internal links and targets, a jump must be realized. When the user clicks on a marked text field that represents a hypertext link, Text Control fires a FieldLinkClicked event. The information provided through this event can be used with the FieldGoto method to jump to the target:

procedure TForm1.TXTextControl1FieldLinkClicked(Sender: TObject; FieldId,
   FieldType: Smallint; var TypeData: WideString);
begin
   If FieldType = txFieldInternalLink Then
      TXTextControl1.FieldGoto(txFieldLinkTarget, TypeData);
end;

While the FieldGoto method is used for targets within the same file, links to external targets must be treated differently. When the Jumping to an External Target event occurs, and the FieldType parameter indicates that the link is external, then it depends on the type of the application, what to do. External links can point to, for instance, files on the local harddisk, or addresses in the internet.

Note that responding to the events is only required for making the hypertext links work while the text is edited in Text Control. If the text is saved to a file and displayed with a browser, then the hypertext links will work depending on the used browser.


Step 4 - Adding Jumps to External Targets

Finally, in this step, jumps to other documents and jumps to targets in these documents are added.

1. An Enhanced Dialog Box for Displaying and Selecting Targets:

Again the Hypertext Link dialog box is extended to choose an external file. A Choose File... button is placed on the form that triggers a common dialog.

After the user has chosen a file, its name is displayed in the text box and the file is searched for internal targets:

procedure TForm2.CheckFileForTargets(tfile : String);
begin
   txhidden.LoadSaveAttribute[txEnableLinks] := True;
   txhidden.Load (tfile, 0, 4, false);
   FillListboxWithTargets (1);
   RadioButton2.Checked := True;
   loadedFile := tfile;
End;

For this purpose the file is loaded in a second, invisible Text Control. Then the FieldNext method is used as in step 3 to list all targets.

2. Jumping to an External Target:

To implement the jump to an external link, the code added to the FieldLinkClicked event in step 3 must be extended. The following code does not handle jumps to internet addresses, it only implements jumps to targets in other files. To separate a file from a name of a target, Text Control uses the '#' character. The following code separates the file name and the target's name, loads the file with the Load method and jumps to the target with the FieldGoto method:

Else begin
   // determine which type of link we have
   // (see List1_Click()) and remove
   // the '#' character.
   If (copy(txtLinkTarget.Text, 0, 1) = '#') Then begin
      LinkType := txFieldInternalLink;
      txtLinkTarget.Text := copy(txtLinkTarget.Text, 1,
         Length(txtLinkTarget.Text) - 1);
   end Else
      LinkType := txFieldExternalLink;
   If tx.FieldAtInputPos <> 0 Then begin
      // editing an existing hyperlink
      tx.FieldText := txtLinkedText.Text;
      tx.FieldType[tx.FieldCurrent] := LinkType;
      tx.FieldTypeData[tx.FieldCurrent] :=
            txtLinkTarget.Text;
   end Else begin
      // insert new hyperlink
      tx.FieldInsert (txtLinkedText.Text);
      tx.FieldType[tx.FieldCurrent] := LinkType;
      tx.FieldTypeData[tx.FieldCurrent] :=
            txtLinkTarget.Text;
   End;
   HighlightHyperlinks (tx, Form1.HypertextLinks1.Checked);
   close;
End;

3. Loading and Saving Files containing Hypertext Links:

When an HTML, RTF or Microsoft Word document is loaded, Text Control must convert containing hypertext links to appropriate marked text fields as described above. To perform this, a programmer must set the LoadSaveAttribute (txEnableLinks) before using the Load method. Otherwise hypertext links and target fields are not converted. When a document is saved, marked text fields that represent hypertext links, are always converted to the appropriate format.

If Text Control's proprietary format is used, setting LoadSaveAttribute is not necessary.

More information about hypertext links and a list of all properties, methods and events that can be used with marked text fields, can be found in the chapter Technical Articles - Marked Text Fields - Special Types of Marked Text Fields.


Drag and Drop

This example shows how to use the InputPosFromPoint method to realise a simple Drag&Drop in a Text Control application.

Drag&Drop in a text editor enables the user to drag a piece of text and drop it in a new location of the document. So, the incoming mouse events have to be analyzed and handled.

The Sample Program

In the InputPosFromPoint method is used to get the character position the user has clicked on. The current input position and the length of the selection are stored in global variables, because they are needed in the MouseUp event. If the input position the user has clicked on, is inside of the current selection, dragging can be started. First a global variable named dragging is set to true and the MousePointer property is changed to indicate that dragging is in process. The text and format information of the current selection is copied to a memory buffer using the SaveToMemory method. Finally, the Text Control's EditMode property is set to 2 - read only.

procedure TForm1.TXTextControl1MouseDown(Sender: TObject;
   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
   pos : LongInt;
begin
   //Get current input position and the current selection
   pos := TXTextControl1.InputPosFromPoint(toTwips(X),
            toTwips(Y));
   gblStart := TXTextControl1.SelStart;
   gblLength := TXTextControl1.SelLength;
   //Check if the click occured in the current selection
   If (gblStart <= pos) And (gblStart + gblLength > pos)
         Then begin
      //Start dragging
      data := TXTextControl1.SaveToMemory(3, True);
      dragging := true;
      Cursor := 2;
      TXTextControl1.EditMode := 2;
   End;
end;

In the MouseUp event procedure the InputPosFromPoint method is used again to get the character position where the user has left the mouse button. When dragging is in process and the input position is not inside the current selection, the drop operation can be performed. The previously saved text now is inserted with the LoadFromMemory method after setting the new input position with the SelStart property.

procedure TForm1.TXTextControl1MouseUp(Sender: TObject;
   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
   pos : LongInt;
begin
   pos := TXTextControl1.InputPosFromPoint(toTwips(X),
            toTwips(Y));
   If dragging Then begin
      //Check if the new input position is outside of
      //the current selection. If it's not, do not
      //copy the text
      If Not ((gblStart <= pos)
            And (gblStart + gblLength > pos)) Then begin
         TXTextControl1.SelText := '';
         If pos < gblStart Then
            TXTextControl1.SelStart := pos
         Else
            TXTextControl1.SelStart := pos - gblLength;
         TXTextControl1.LoadFromMemory(data, 3, True);
      End;
      //End dragging
      dragging := False;
      Cursor := 0;
      TXTextControl1.EditMode := 0;
   End;
end;


Using Multiple Controls

This chapter shows how to use Text Control in programs which have several text fields placed on a single page. Think of a program to print labels, to fill out forms, or to mask data entry. The Forms1 sample program, which can be found in the Samples\Delphi\Forms1 subdirectory provides the basic functionality for applications of this kind.

Running the Sample Program
How it Works
Saving the Controls
Printing Multiple Controls


Running the Sample Program

Initially, when the program is started, the main window contains one framed Text Control where text can be entered. The rest of the window is empty.

What you can do with the program is:

  • Move the Text Control by pressing the ALT key and dragging the window with the mouse.
  • Resize the Text Control by pressing the ALT key and dragging the window borders with the mouse.
  • Create additional controls by clicking on an empty part of the main window.
  • Save, load or print.

To keep things simple, there are no scrollbars in the main window and no menu items except the ones listed above. Scrollbars, zoom and a few other features will however be added in the next section.


How it Works

The Forms1 sample uses a control array for the text fields. The first Text Control, the one which you see when you start the program, is placed on the form at design time. More controls are created when you click on an empty area of the form. These controls are created dynamically with the Delphi Create method. Then they are assigned initial values.

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
   Shift: TShiftState; X, Y: Integer);
begin
   MaxID := MaxID + 1;
   TX := TTXTextControl.Create(Form1);
   TX.Parent := Form1;
   TX.Top := Y;
   TX.Left := X;
   TX.Width := TXTextControl1.Width;
   TX.Height := TXTextControl1.Height;
   TX.Name := 'TXTextControl' + InttoStr(MaxID);
   TX.SizeMode := 3; // Move- and sizeable
   TX.BringtoFront;
   TX.OnMouseDown := TXTextControl1MouseDown;
end;

Clicking on an existing text field brings it to the front. This is done by changing the Z order when a Click event has occurred:

procedure TForm1.TXTextControl1MouseDown(Sender: TObject;
   Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
   TTXTextControl(Sender).BringtoFront;
end;

The global variable MaxID counts the total number of controls; It is initialized to a value of 1 when the form is loaded.

Moving and resizing the controls is done by Text Control itself. To enable these functions, the SizeMode property must be set to 3 - Move and Sizeable.


Saving the Controls

Saving a document which has been created with this program necessitates storing not only the data contained in the Text Controls, but also the number and the positions of the controls. In addition, a format identifier should be stored to enable the load routine of the program to determine if it can process a file which it is about to load. The code on the following page shows you how to save the document.

procedure TForm1.Save1Click(Sender: TObject);
var
   outFile : file of byte;
begin
   // Create an "Open File" dialog box
   SaveDialog1.Title := 'Save as';
   SaveDialog1.Filename := '';
   SaveDialog1.DefaultExt := 'txm';
   SaveDialog1.Filter := 'TX Form Demo (*.txf)|*.txf';
   SaveDialog1.FilterIndex := 1;
   if SaveDialog1.Execute then
      Filename := SaveDialog1.Filename
   else
      Exit;
   try
      begin
      // Open the selected file
      AssignFile(outFile, filename);
      rewrite(outFile);
      // Write file header
      FileID.lVersion := File_ID;
      BlockWrite(outFile, FileID, sizeOf(FileID));
      //Save properties of all text controls
      BlockWrite(outFile, MaxID, sizeof(MaxID));
      For i := 1 To MaxID do begin
         TXhWnd := FindComponent('TXTextControl'
               + Inttostr(i));
         with TXProp do begin
            xPos := TTXTextControl(TXhWnd).Left;
            yPos := TTXTextControl(TXhWnd).Top;
            xSize := TTXTextControl(TXhWnd).Width;
            ySize := TTXTextControl(TXhWnd).Height;
         end;
         BlockWrite(outFile, TXProp, sizeof(TXProp));
      end;
      closeFile(outFile);
      //Save contents of all text controls
      For i := 1 to MaxID do begin
         TXhWnd := FindComponent('TXTextControl'
               + InttoStr(i));
         TTXTextControl(TXhWnd).Save(FileName, -1,
               3, False);
      end;
   end;
   Except
      MessageDlg('Error saving ' + filename, mtError,
            [mbOK], 0);
   end;
end;

The Load routine first reads the format ID and the number of controls. Then it creates the required number of controls, loads their contents and finally moves them to their correct position:

procedure TForm1.Load1Click(Sender: TObject);
var
   lFilePos : LongInt;
   InpFile  : file of byte;
   bOpen : Boolean;
begin
   // Create an "Open File" dialog box
   OpenFileDialog.Title := 'Open file';
   OpenFileDialog.Filename := '';
   OpenFileDialog.Filter := 'TX Form Demo (*.txf)|*.txf';
   OpenFileDialog.FilterIndex := 1;
   if OpenFileDialog.Execute then
      Filename := OpenFileDialog.Filename
   else Exit;
   try
      begin
         // Open the selected file
         bOpen := False;
         AssignFile(inpFile, filename);
         reset(inpFile);
         bOpen := True;
         // Read file header
         BlockRead(inpFile, FileID, sizeOf(FileID));
         If FileID.lVersion <> FILE_ID Then begin
            MessageDlg('Wrong filetype: ' + filename,
               mtError,[mbOK],0);
            Exit;
         End;
         // Destroy existing controls
         If MaxID > 1 then begin
            For i := 2 To MaxID do begin
               TXhWnd := FindComponent('TXTextControl'
                  + Inttostr(i));
               TTXTextControl(TXhWnd).Free;
            end;
         end;
         //Create text controls and load their contents
         BlockRead(InpFile, MaxID, sizeof(MaxID));
         For i := 1 To MaxID do begin
            BlockRead(InpFile, TXProp, sizeof(TXProp));
            If i <> 1 Then begin
               TX := TTXTextControl.Create(Form1);
               TX.Parent := Form1;
               TX.Width := TXTextControl1.Width;
               TX.Height := TXTextControl1.Height;
               TX.Name := 'TXTextControl'
                  + InttoStr(i);
               TX.SizeMode := 3;
               TX.BringtoFront;
               TX.OnMouseDown := TXTextControl1MouseDown;
            end;
            TXhWnd := FindComponent('TXTextControl'
               + Inttostr(i));
            TTXTextControl(TXhWnd).Left := TXProp.xPos;
            TTXTextControl(TXhWnd).Top := TXProp.yPos;
            TTXTextControl(TXhWnd).Width := TXProp.xSize;
            TTXTextControl(TXhWnd).Height := TXProp.ySize;
            TTXTextControl(TXhWnd).Text := '';
         end;
         lFilePos := FilePos(InpFile);
         closeFile(InpFile);
         bOpen := False;
         For i := 1 To MaxID do begin
            TXhWnd := FindComponent('TXTextControl'
               + Inttostr(i));
            lFilePos := TTXTextControl(TXhWnd).Load(
               FileName, lFilePos, 3, False);
            TTXTextControl(TXhWnd).Visible := True;
         end;
      end;
   Except
      MessageDlg('Error opening ' + filename, mtError,
            [mbOK], 0);
      if bOpen then begin
         closeFile(inpFile);
      end;
   end;
end;


Printing Multiple Controls

Printing a document is quite straightforward. The ViewMode property is set to 4 - Simple Control, so the controls are printed like they are formatted on the screen. The PageMargin properties are used to specify the positions of the controls on the page.

procedure TForm1.Print1Click(Sender: TObject);
begin
   Printer.BeginDoc;
   For i := 1 To MaxID do begin
      TXhWnd := FindComponent('TXTextControl' +
            InttoStr(i));
      TTXTextControl(TXhWnd).PrintDevice := Printer.Handle;
      TTXTextControl(TXhWnd).PageMarginL :=
            toTwip(TTXTextControl(TXhWnd).Left);
      TTXTextControl(TXhWnd).PageMarginT :=
            toTwip(TTXTextControl(TXhWnd).Top);
      TTXTextControl(TXhWnd).PrintPage (1);
   end;
   Printer.NewPage;
   Printer.EndDoc;
end;

The complete source code of the Forms1 sample program is contained in the Samples\Delphi\Forms1 sample source directory.


A Forms Filler

The Sample Program
Adding a Button Bar, a Ruler Bar and a Status Bar
Displaying the Background Image
Working with Transparent Text Controls
Zooming


The Sample Program

With the Forms1 sample program, you can place text fields at arbitrary positions on a page. When you print the page, the text fields appear on the paper at exactly the same positions where they were previously placed on the screen. These features will be used in the following sample to create a program for filling out pre-printed forms.

The scanned image of the form is shown in the background of the screen, enabling the user to easily determine the positions of the filled-out fields. He has only to click (with the CTRL key pressed) on the area of the form where he wants to put text and then start typing. The fields can be moved and resized afterwards by holding down the ALT key and dragging them with the mouse.

The source code for this example is contained in the Samples\Delphi\Forms2 sample source directory.


Adding a Button Bar, a Ruler Bar and a Status Bar

The Button Bar, Ruler and Status Bar are used in a special way in this sample program. If you run the program and click on various fields you will notice that the tools automatically switch to the text field which has been clicked on. This switching is done internally by Text Control, so no programming is required for it. Each control is simply connected to the status bar, etc. when it's created.


Displaying the Background Image

The background image is displayed by an Image Control. This is not a separate custom control, but a child window of the Text Control. To display the background image, create a Text Control which has the size of the whole page, and then load an image using Text Control's ObjectInsertAsChar method.

The Text Control which displays the background image has an additional function, which again saves a lot of programming work. It acts as a container for the Text Controls which are used as fill-out fields. (A container control enables you to draw other controls within it at design time). The big advantage of a container is that it handles all of the clipping for the controls which have been created on top of it. Otherwise, scrolling the background image would cause the text fields to overwrite anything that lies within the form's boundaries, like ButtonBar, Ruler, and even the scrollbars. It would require many calculations of field positions and sizes and some direct calls to the Windows DLLs on every scroll and resize event to do the clipping without a container control. Using the background Text Control as a container, you need only create the first text field inside of it, and everything else is done automatically.


Zooming

Zooming is simply done by setting the ZoomFactor property of each of the Text Controls:

procedure TForm1.N751Click(Sender: TObject);
begin
   Zoom := TXParent.ZoomFactor;
   TXParent.ZoomFactor := 75;
   For i := 1 to MaxID do begin
      TXhWnd := FindComponent('TXChild' + InttoStr(i));
      TTXTextControl(TXhWnd).ZoomFactor := 75;
   end;
   TXhWnd := FindComponent('N' + InttoStr(Zoom) + '1');
   TMenuItem(TXhWnd).Checked := False;
   N751.Checked := True;
end;


Technical Articles

This chapter contains several technical articles, giving you an overview of TX Text Control's properties, methods and events working together.

Text Formatting and Views
Headers and Footers
Tables
Marked Text Fields
Resources
Working with XML Files
Server Programming
Specifying a Serial Number in C++


Text Formatting and Views

Coordinate System
Simple Control View
Normal View
Page View
Centered Page View
Floating Text
Properties, Methods and Events


Coordinate System

For almost all units of measurement Text Control uses twips. Twip is a fabricated word meaning twentieth of a point. A point which is a unit of measurement for type, is approximately 1/72 inch but often assumed in graphics systems sach as Windows GDI to be exactly 1/72 inch. A twip is 1/20 point and hence 1/1440 inch.

Type size is expressed in units called points. A point is very close to 1/72 inch, so close that it is often defined as exactly 1/72 inch. The point size indicates the height of the characters. For instance, when we speak of 12-point type, we are referring to characters that are 12/72 inch high from the top of the ascenders to the bottom of the descenders.


Simple Control View

The formatting area, which is the area Text Control uses to perform line breaks, is Text Control's control size. This means that every time the control is sized, the text is newly formatted. For this view set the ViewMode property to 4 - Simple Control.

A line break is automatically performed when the current input position reaches the control's right border. When the control's right border is reached without having a break character in a line, no line break is performed and Text Control indicates overflowing text with a vertical mark. This mark is displayed at the control's left or right border, depending on the paragraph alignment setting. When the number of lines exceed the control's height, overflowing text is indicated with a plus mark at the bottom of the control. The current input position, indicated by the caret, can never leave the control. If the user tries to move the caret to overflowing text, the Text Control beeps.

When the Text Control is zoomed, the current control size is also zoomed to adapt the formatting area to the new zooming factor. Its position in relation to its container control or form is also zoomed.

Autoexpanding is only possible in this view. In autoexpanding mode the control's size is automatically expanded to the current text amount. This mode can be set with the AutoExpand property. After Text Control has expanded its control size it sends HExpand and/or VExpand events.

Because the control view has no built-in scroll interface, Text Control has several events to enable a programmer to implement an external scroll interface. The CaretOutBottom, CaretOutLeft, CaretOutRight and CaretOutTop events are sent, when the current input position has been moved outside of the control's visible part. The CaretOut event is sent, when the current input position has been moved to a completely invisible control and the AutoScroll event is sent during extension of a text selection with the mouse. All of these events are only possible in the simple control view.


Normal View

With the PageWidth and PageHeight properties the formatting area can be changed by the programmer. This is necessary to realize a text editor that formats the text accordingly to a certain page width. The ViewMode property must be set to 0 - Normal for this view. In normal view the formatting height - the amount the user can scroll - depends on the current amount of text.

When the formatting width and/or height is greater than the current control size and the caret reaches the control's borders, scrolling is performed automatically to make the new input position visible. In addition, a horizontal and/or a vertical scroll-bar can be used to scroll to text parts outside of the client area without changing the current input position. Scrollbars can be set through the ScrollBars property.

If the Text Control is sized the text is not newly formatted and if the Text Control is zoomed the control's size and position are not changed. If the control is sized, visible scrollbars are automatically hidden when they are no longer needed. Conversely, previously hidden scrollbars are automatically shown when the control's size becomes smaller.


Page View

When the ViewMode property is set to 1 - Page View, Text Control shows pages with margins and borders. The number of pages depends on the amount of text.

The PageWidth and PageHeight properties define the extension of the page including its margins. Page margins have a default value of one inch and can be changed through the PageMarginB, PageMarginL, PageMarginR and PageMarginT properties.


Centered Page View

When the ViewMode property is set to 2 - Centered Page View, pages are displayed in three dimensions with borders and shadows and they are centered in the control's window.

Like for many other extension settings, Text Control uses twentieths of a point to define the formatting area. This unit is often used in combination with text processing applications or fonts and is called TWIP. One TWIP is a 1/1440th of an inch.

In the normal view and in both page views Text Control has a built-in scroll interface. Text Control sends HScroll and VScroll events when it scrolls automatically. The current scroll positions can be obtained or set with the ScrollPosX and ScrollPosY properties.

Only with the Page View and the Centered Page View headers and footers can be used. For more information how to handle headers and footers see Technical Articles - Headers and Footers.


Floating Text

The default setting of the ViewMode property is 3 - Floating Text. In this setting the text is formatted depending on the control's width but it is not limited to the control's height.


Properties, Methods and Events

For a list of all properties, methods and events that can be used to program with text formatting, text view and scrolling see the chapters Programming Categories - Page and Document Settings and Programming Categories - Scrolling.


Headers and Footers

Using Headers and Footers
Programming Headers and Footers
Properties, Methods and Events


Using Headers and Footers

Headers and footers can only be used when the ViewMode property has been set to Page View or Centered Page View.

Headers and footers are parts of a document. The HeaderFooter property determines whether headers and footers, only headers or only footers are contained. Additionally special headers and/or footers for the first page can be specified with this property. To edit a header or footer, it must be activated either with the HeaderFooterActivate method or with a mouse double-click in a header's or footer's area. An activated header or footer gets the input focus and its border is shown with a dotted frame. When a header or footer is activated, the main text is displayed in gray, otherwise a header's or footer's text is displayed in gray. Text Control fires HeaderFooterActivated and HeaderFooterDeactivated events to inform the application about activation or deactivation of headers or footers.

The HeaderFooterStyle property allows the following style settings:

  • Activation can be performed with mouse double-clicks and/or single mouse clicks.
  • The border of an activated header or footer can be solid, dotted or unframed.

The default style setting is a dotted frame and a mouse interface that activates a header or footer with double-clicks.

By default the top of a header has a distance of one centimeter from the top of the page and the bottom of a footer has a distance of one centimeter from the bottom of the page. With the HeaderFooterPosition property these values can be changed. The height of a header or footer depends on the header's or footer's current text.

When a document is loaded or converted from another format, contained headers and footers are automatically displayed. The HeaderFooter property returns the information which headers and/or footers the current document contains.


Programming Headers and Footers

Headers and footers are separate text parts which are independent of the main text. When the user alters the text or the text format, for example with a connected button bar, Text Control uses the current input focus, to determine whether the text format of a header, a footer or the main text is changed. The same occurs when the text is manipulated from programming code. For example when a table is inserted from a menu with the TableInsert method, the current input focus determines whether the table is inserted in a header's or footer's text or in the main text.

In addition to this default text part selection, a programmer can use the HeaderFooterSelect method to use a certain property with a certain text part. For example the following code alters the text of a header:

TXTextControl1.HeaderFooterSelect txHeader
TXTextControl1.Text = "This is the header's text"
TXTextControl1.HeaderFooterSelect 0

The first line selects the header, independent of the current input focus, the second line alters the text of the header and the third line returns to the default selection mode. There can be more than one property or method call between the two HeaderFooterSelect calls.

Almost all properties and methods can be used in this way with some exceptions. The following is a complete list of properties and methods which can be used with headers and footers:

  • all properties and methods to handle character formatting
  • all properties and methods to handle paragraph formatting
  • all properties and methods to handle marked text fields
  • all properties and methods to handle hypertext links
  • all properties and methods to handle tables
  • all properties and methods to handle images, text frames and objects
  • CurrentInputPosition Property
  • Find Method
  • FindReplace Method
  • FormatSelection Property
  • RTFSelText Property
  • SelLength Property
  • SelStart Property
  • SelText Property
  • TabKey Property
  • Text Property

The following methods can only be used in conjunction with the HeaderFooterSelect method:

  • Load Method
  • LoadFromMemory Method
  • LoadSaveAttribute Method
  • Save Method
  • SaveToMemory Method
  • SaveToMemoryBuffer Method


Properties, Methods and Events

For a list of all properties, methods and events that can be used to program with tables see the chapter Programming Categories - Headers and Footers.


Tables

Using Tables
Programming with Table Identifiers
Properties, Methods and Events


Using Tables

Tables can be inserted into a Text Control either with the TableInsert method or via the Load method as part of a document formatted with the RTF or HTML formats. Text Control treats a table as a number of cells organized in rows and columns. Each cell can have as many lines and paragraphs as required. Paragraph formatting is performed in relation to a cell's borders. Each cell has a position and an extension in the document, within this area a cell's frames and text are drawn along with its paragraph and character formatting attributes. There can be a distance between the frame and the text.

Text can be selected either within a single cell or in steps of complete cells or rows. When a selection is deleted inside a table only the text is deleted. To delete one or more complete rows use the TableDeleteLines method. Tables can be copied to the clipboard and pasted from the clipboard. When a table is inserted at the first position of another table or immediately behind another table and both tables have the same number of columns they are combined into a single table. The insertion of one table inside another table is not possible.

A table's attributes are its frame width, distance between frame and formatted text, and background color. To alter the attributes of a table or part of a table, cells must be selected. Then a built-in dialog box can be opened with the TableAttrDialog method. When the selection extends over several tables or tables mixed with text, attributes cannot be changed. To get information about whether attributes can be changed or tables can be inserted or deleted, for example to implement a menu, the TableCanChangeAttr, TableCanDeleteLines and TableCanInsert properties can be used.

When the current input position is inside a table, the ruler shows the positions of all the cells in a table's row and the formatting attributes of the cell the input position belongs to. Then the cells' positions and extensions can be changed with a built-in mouse interface.


Programming with Table Identifiers

Each table can have an user-defined identifier which a programmer can set with the TableInsert method. Setting the identifier is not necessary but recommended when a table's text or attributes are to be changed from the program instead from an end-user. The user-defined identifier need not to be unique and remains valid if a table is saved and reloaded. When no identifier is set Text Control returns an own-selected one, which is unique and does not remain valid if a table is saved and reloaded.

When a table or a part of a table is inserted inside another table the inserted table becomes a part of the existing table and the inserted table's identifier is lost.

When a table with a user-defined identifier is inserted outside of all existing tables a new table is created and the table's identifier remains valid. Text Control informs the program with a TableCreated event that a new table has been created. The programmer can change the table identifier sent with the event by setting the NewTableId parameter of the event.

When a table is inserted from another application, which means it cannot have a user-defined identifier, Text Control sends an own-selected identifier with the TableCreated event and the program can change it.

When tables are imported with the Load method, TableCreated events occur only when text is inserted into an existing document or when an imported table has no user-defined identifier. Otherwise when a table with a user-defined identifier is saved and reloaded no event occurs.

When a table is completely deleted Text Control informs the program with a TableDeleted event.

The following properties and methods can be used with table identifiers to get information or to set table attributes regardless whether the current input position is or is not inside this table:

Property/Method | Description
TableCellText Property | Gets or sets the text contents of a certain table cell.
TableColumns Property | Gets a table's number of columns.
TableRows Property | Gets a table's number of rows.

When more than one table with a certain identifier exists, these properties and methods perform the operation with the original inserted table. In chains of linked windows these properties and methods can be used with any Text Control in the chain regardless of which control contains the table.


Properties, Methods and Events

For a list of all properties, methods and events that can be used to program with tables see the chapter Programming Categories - Tables.


Marked Text Fields

Using Marked Text Fields
Editing Marked Text Fields
Relating data to a Marked Text Field
Special Types of Marked Text Fields
Properties, Methods and Events


Using Marked Text Fields

Fields can be inserted into a Text Control either with the FieldInsert method or via the Load method as a part of a document. The whole communication works with unique numbers returned by this method or defined by the user. To communicate with a field, the field must be previously set as the current field with the FieldCurrent property.

The current text can then be changed or retrieved with the FieldText property and a field can be deleted with the FieldDelete method. To get a field's position, either geometrically or as character position, the properties FieldPosX, FieldPosY, FieldStart and FieldEnd can be used. To get the number of the next field in the text or to enumerate all fields, the FieldNext method can be used.

Special attributes can be set with the FieldChangeable and FieldDeleteable properties. These attributes can prevent a field from beeing deleted or the text of a field from being changed. Further attributes which can help the end-user to edit the field's contents are described in the next chapter.

With different events Text Control informs the application about special conditions. The FieldClicked and FieldDblClicked event inform the application about mouse clicks, FieldEntered and FieldLeft indicate whether the current input position has been moved into or from a field. The FieldSetCursor event can be used to define the cursor when it is moved over a field. The default cursor is the up-arrow cursor. The FieldChanged event occurs when the text of a field has been altered, and the FieldDeleted and FieldCreated event occur when fields have been deleted or created while inserting or deleting text with the keyboard or the clipboard.


Editing Marked Text Fields

When marked text fields are used in an editable Text Control and these fields are editable, the end-user can alter the contents of the field like any other text. Because it is not always unique whether the current input position is or is not inside a field some field attributes have been implemented to help the end-user to edit fields. These attributes can be used in any combination and must be set with the FieldEditAttr property.

When the current input position is in front or behind a field the next inserted character can either belong to the field or to the text outside the field. In normal editing mode an inserted character has the attributes of its preceding character which means that inserted text just behind a field belongs to the field and inserted text in front of a field does belong to the text in front of the field. To solve these problems extended editing features can be defined for every field with the FieldEditAttr property. It implements a second input position at the beginning and the end of the field. The end-user can switch between the two positions with the left and right arrow keys. This is especially important when a marked text field is at the beginning or the end of the complete text. For example when a field is at the end of the text the end-user can press CTRL+END to reach the text end. When this position is also the end of a marked text field the right arrow key can be pressed when the next inserted character should not belong to the field.

To help the end-user to find the correct position, additional settings can be performed which change the caret's width when it is inside a marked text field or display the complete text of a field with a gray background when the current input position is inside this field.

Each of the described attributes can be defined for a single field in any combination which means that different kinds of marked text fields can be implemented in a single Text Control.


Relating data to a Marked Text Field

For each marked text field Text Control can store any data that can be set with the FieldData property. For example when a Text Control is used to show the contents of a database a marked text field can be created for each database field. The database's field names can then be related to the Text Control's marked text fields using the FieldData property.

Other parts of the program can use the FieldData property to retrieve the name of the database field to which a marked text field is linked. For example when the user has clicked on a marked text field, the FieldData property can be used with the field identifier, which has been specified through the FieldClicked event. The property then retrieves the name of the database field the user has clicked on.

The FieldData property accepts strings and numbers. When a marked text field is copied via the clipboard or saved to a file the data belonging to the field is also copied or saved. The usage of the FieldData property does not change the current text contents of a marked text field. When new data is set, all previously set data is overwritten independently of the kind of data involved.


Special Types of Marked Text Fields

Text Control supports special types of marked text fields that can be defined with the FieldType property. The following types are possible:

Type | Description
txFieldExternalLink | This field defines the source of a hypertext link to a location outside of the document.
txFieldInternalLink | This field defines the source of a hypertext link to a location in the same document.
txFieldLinkTarget | This field defines the target of a hypertext link.
txFieldPageNumber | This field displays the current page number. It can only be used in headers or footers.
txFieldHighlight | This field defines a piece of text that can be highlighted.
txFieldTopic | This field defines a position in a document that is the beginning of a topic.

All of these fields have the same general properties as standard marked text fields with the following exceptions: Fields of the type txFieldLinkTarget or txFieldTopic define text positions in a document. Therefore as they have no visible text, they cannot be edited and have no extended edit mode. Fields of the type txFieldPageNumber can only be used in headers or footers.

For each of the special field types Text Control handles some additional data, called type-related data. These data can be set or returned with the FieldTypeData property. For the types txFieldExternalLink and txFieldInternalLink these data are the information to where the link points. This can be an address or a file name and/or the name of a target in a document. Targets in documents can be realized with marked text fields, which have the type txFieldLinkTarget. These fields can have a name that is saved as type-related data. When the user clicks on a field of the type txFieldExternalLink or txFieldInternalLink a FieldLinkClicked event is fired including the information to where the link points. The FieldGoto method can be used to scroll to a target position and the FieldNext method can be used to enumerate all fields of a certain type.

To insert a field of a special type from programming code, use the FieldInsert method first and then set the type and its data. The following Basic example inserts a field that represents a link to the Text Control homepage:

Dim Field As Integer
TXTextControl1.FieldInsert "visit the Text Control homepage"
Field = TXTextControl1.FieldCurrent
TXTextControl1.FieldType(Field) = txFieldExternalLink
TXTextControl1.FieldTypeData(Field)  = _
      "http://www.textcontrol.com"

When a user clicks on this marked text field, a FieldLinkClicked event is fired, containing the address of the homepage. To insert a field of the type txFieldLinkTarget, the created field must not have text. The following Basic example creates a field that represents such a target:

Dim Field As Integer
TXTextControl1.FieldInsert ""
Field = TXTextControl1.FieldCurrent
TXTextControl1.FieldType(Field) = txFieldLinkTarget
TXTextControl1.FieldTypeData(Field) = "first target"

This creates a field with the name "first target". The FieldGoto method can be used to scroll to this target:

When HTML, RTF or Word documents are loaded, source and target fields for hypertext links are automatically created. To perform this, set the txEnableLinks attribute with the LoadSaveAttribute property before using the Load method.

Fields of the type txFieldPageNumber display the current page number and can only be used in headers or footers. The following Basic example inserts a page number field:

TXTextControl1.FieldInsert ""
TXTextControl1.FieldType(TXTextControl1.FieldCurrent) = _
      txFieldPageNumber

Fields of the type txFieldHighlight can be used to mark pieces of text in a document that can be highlighted. This is useful, for instance, to highlight occurrences of a word found during a global search. The highlight color is stored as additional data for these fields. The FieldGoto method enables the programmer to scroll fom highlight to highlight. When RTF documents are loaded with the Load method and the txEnableHighlights attribute has been set previously with the LoadSaveAttribute property, all RTF '\cbN' keywords are automatically converted to fields of the type txFieldHighlight. N is the index of a color in the RTF color table.

Fields of the type txFieldTopic are text positions in a document defining the beginning of a topic. The FieldGoto method can be used to scroll to a topic with a certain number. When RTF documents are loaded with the Load method and the txEnableTopics attribute has been set previously with the LoadSaveAttribute property, all RTF '\sect' keywords are automatically converted to fields of the type txFieldTopic. These topics are numbered from 1 to n in the order they appear in the RTF document.


Properties, Methods and Events

For a list of all properties, methods and events that can be used to program with marked text fields see the chapters Programming Categories - Text Fields and Programming Categories - Hypertext Links.


Resources

Text Control has several built-in resources like information strings, error messages and dialog boxes. These resources are available in different languages. When a new control is created Text Control selects the current set system language as the default one. With the Language property this setting can be altered independent of the system language. The description of the Language property lists all currently available built-in languages. To alter the language of the Button Bar and Status Bar the appropriate Language properties must be used.

To display resources in additional languages external resource libraries can be built and then set with the ResourceFile property. A resource library is a dynamic link library that only contains resources. The ResourceKit subdiretory contains the basic files to create such a DLL file. The following is a list of these files:

  • TXRES.C (Contains the DLL's entry point)
  • TXRES.RC (Contains Text Control's resources in English)
  • TXRES.H (Contains the definitions of all resource identifiers)

Furthermore Microsoft Visual C++ project files are contained that can be used to build the resource library.

The TXRES.RC file has the following contents:

  • Dialog box templates for the built-in dialog boxes.
  • String tables that contain information strings, error messages and the status strings of the Status Bar. Strings must not be larger than 255 characters.
  • Bitmaps for the bold, italic and underline buttons of the button bar. The bitmap files are in the \BMP subdirectory.

To avoid conflicts with other programs that also uses own resources or with future versions of TX Text Control the following points are important:

  • The resource library should have a unique file name. The resource kit project builds a DLL file named TXRES.DLL. This name should be changed.
  • The resource library should be placed in the same directory as the final application. Get the full path name of the apllication's executable file at run time and specify the resource library's file name including this path when setting the ResourceFile property.

At runtime Text Control determines resources in the following way:

  • The Language property is initialized with the system default language. If the system language is not built-in, Text Control displays English resources.
  • When the Language property has been changed with an identifier of a built-in language, Text Control displays resources in this language independent of the system language.
  • When the ResourceFile property has been set, Text Control tries to load the resources from this library. In this case the Language property is ignored. When the resource library does not contain a needed resource or when the specified file could not be found, Text Control displays English resources without reporting an error.
  • Setting the ResourceFile and Language properties of a Text Control does not automatically set the appropriate properties of a connected Button Bar or Status Bar to the same values. These properties must be changed independently.


Working with XML Files

Loading and Saving XML Files
Editing XML Files
Programming XML Documents
Inserting and Deleting XML Elements


Loading and Saving XML Files

Text Control offers several built-in features to edit and to manipulate XML files. XML files can be loaded and saved like all other files using the Load or Save method.

When an XML file is loaded Text Control considers the corresponding document type description file (DTD) and checks the document for validation. If the document is invalid (which means that it does not fulfill the rules in the DTD) an XMLInvalid event occurs, however, Text Control still loads the document's text and its formatting styles. The document can then be edited as a normal text document with all the editing features Text Control offers.

Otherwise if the document is valid according to the corresponding DTD Text Control loads the document's text and formatting styles and switches to a special XML editor mode which guarantees that the document remains valid during editing. This article describes how the XML editor mode works and how an application can manipulate an XML document. The XMLEditMode property informs about the state of the XML editor.

If an XML document is not well-formed (which means that it contains invalid XML syntax) an XMLNotWellFormed event occurs and the document is not loaded. Both the XMLInvalid event and the XMLNotWellFormed event informs the application about the positon in the file where the error occurs and the error's reason.

During loading, Text Control looks for corresponding formatting styles contained in a CSS file. If such a file could be found Text Control loads the styles and displays all formatting attributes. All further editing and manipulation of the XML Document can be performed in WYSIWYG mode.

Because an XML document becomes invalid if it is inserted into another existing document, Text Control does not load an XML document if the CurSelection parameter of the Load method is set to True.

If an XML document is saved using the Save method only the document's text is saved into the XML file. To save the document's formatting styles into the corresponding CSS file a second call of the Save method must be performed. Changing and saving the document's DTD is not supported. Text Control also does not support the creation of completely new XML documents.


Editing XML Files

XML documents consist of elements. Some of these elements contain the document's text, other elements represent the document's structure. Assume the following XML document that contains a list of addresses:

<?xml version="1.0"?>
<?XML:stylesheet type="text/css" href="addresses.css"?>
<!DOCTYPE Addresses SYSTEM "addresses.dtd">
<Addresses>
   <DocumentHeadline>Addresses</DocumentHeadline>
   <AddressTable>
      <Address>
         <Name>Jack Miller</Name>
         <Street>Baker Street</Street>
         <City>New York</City>
      </Address>
      <Address>
         <Name>Tom Baker</Name>
         <Street>Miller Street</Street>
         <City>Los Angeles</City>
      </Address>
      <Address>
         <Name>Bill Taylor</Name>
         <Street>Old Street</Street>
         <City>Washington</City>
      </Address>
   </AddressTable>
</Addresses>

In this example the elements DocumentHeadline, Name, Street and City contain the document's text, the other elements Addresses, AddressTable and Address are structural elements without any text. After this document has been loaded Text Control displays it WYSIWYG with the formatting styles found in the specified CSS file and automatically switches to the XML editor mode. In this mode, text can be inserted or deleted like in any other document. Text selections are possible only inside of single XML elements. If a user tries to select more than one element Text Control expands the selection to its maximum which is the complete text of the single element.

Like in tables the TAB (Shift TAB) key can be used to select the complete text of the next (previous) element. Clipboard operations are possible as in any other document, but if text is inserted from another document Text Control inserts the text without any formatting attributes.

Because XML documents does not contain formatting attributes they can be changed only via formatting styles. Formatting via the Button Bar changes the attributes of the current style. Formatting via formatting functions is disabled in XML documents. To change formatting attributes either the built-in style dialog boxes or the style collection interface can be used. To make these changes permanent, the new attributes must explicitly be saved in the CSS file.


Programming XML Documents

Text Control exposes the elements of an XML document through collections of XMLElement objects. The "XMLElements property returns an XML collection. There is one collection for each kind of elements. In the example document above there is a collection for all Address elements and another collection for all Name elements. The following line of code gets the collection of the Name elements:

Set NameElements = TXTextControl1.XMLElements("Name")

A collection object has the standard Item method to access a single element. With the XMLElement object's Text method the following line of code displays the content of the second Nameelement:

MsgBox TXTextControl1.XMLElements("Name").Item(2).Text

The Item method is the default method of the XMLElements collection thus the following line of code is equivalent:

MsgBox TXTextControl1.XMLElements("Name")(2)

The Text property of elements containing sub-elements is the complete text of all sub-elements separated through Chr(10) characters. For example the line of code:

TXTextControl1.XMLElements("Address")(2)
= "Paul Baskerville" & Chr(10) & "Jackson Street" & Chr(10) & "London"

in the example above displays:

Tom Baker
Miller Street
Los Angeles

To set a new text with the Text property specify a text string separated through Chr(10) characters:

TXTextControl1.XMLElements("Address")(2)
= "Paul Baskerville" & Chr(10) & "Jackson Street" & Chr(10) & "London"

With a For Each statement a program can iterate through an XML collection. The following example displays all names:

For Each element in TXTextControl1.XMLElements("Name")
   MsgBox element.Text
Next

For development enviroments that do not support For Each processing, the above code is equivalent to the following code using the collection's Count property:

Set elements = TXTextControl1.XMLElements("Name")
For i = 1 To elements.Count
   MsgBox elements(i).Text
Next i

A Text Control XML collection also has an Add and a Remove method to insert or delete elements. This is explained in the following section.


Inserting and Deleting XML Elements

The structure of an XML document is described through a document type description (DTD) either contained inline in the XML file or in a separate DTD file. The following is an example of a DTD file belonging to the XML example above (addresses.dtd):

<!ELEMENT Addresses (DocumentHeadline, AddressTable)>
<!ELEMENT DocumentHeadline (#PCDATA)>
<!ELEMENT AddressTable (Address+)>
<!ELEMENT Address (Name, Street, City)>
<!ELEMENT Name (#PCDATA)>
<!ELEMENT Street (#PCDATA)>
<!ELEMENT City (#PCDATA)>

The DTD allows text only for elements with the #PCDATA statement. Furthermore, the document must have a single document headline and a single address table. The address table can have one or more addresses and each address must have three sub-elements: Name Street and City.

With all of these instructions, inserting or removing elements is allowed only for complete addresses. Inserting or removing one of the other elements results in an invalid document and an XMLInvalid event occurs if a program tries it.

To insert an address first create a new XMLElement object, initialize it with text and then use the Address collection's Add method:

Dim NewAddress As Object
Set NewAddress = CreateObject("TIS.TX.XMLElement.12")
NewAddress.Text = "Paul Baskerville" & Chr(10) & "Jackson Street" & Chr(10) & "London"
TXTextControl1.XMLElements("Address").Add NewAddress, , 2

This code inserts the new address after the second address in the document. Using the Add method's before parameter an element can also be inserted before a certain element.

The following line of code removes the address just inserted:

TXTextControl1.XMLElements("Address").Remove(3)

Because the DTD enforces at least one address, trying to remove the last address also results in an invalid document and an XMLInvalid event occurs.


Server Programming

Text Control can be enabled to work as an automation server in scripting engines such as Windows Scripting Host or Internet Information Server. Text Control offers the EnableAutomationServer method that must be called first after creating the automation object.

All Text Control properties and methods can be used with the exception of those needing a visible surface like dialog boxes, toolbars and all features manipulating the display of a document.

Property Overview

The following is a list of properties and methods that cannot be used when Text Control works as an automation server:

Property/Method | Description
BackStyle Property | Returns or sets a value indicating whether the background of a Text Control is transparent or opaque.
ButtonBarHandle Property | Specifies the button bar control to be used with a Text Control.
CanCopy Property | Informs whether a part of a Text Control's document has been selected and can be copied to the clipboard.
CanPaste Property | Informs whether the clipboard contains a format that can be pasted into a Text Control's document.
Clip Method | Performs clipboard operations.
ClipChildren Property | Determines whether child controls are excluded from the update area.
ClipSiblings Property | Determines whether sibling controls are excluded from the update area.
ControlChars Property | Specifies whether control characters are visible.
DataText Property | Enables a Text Control to be used as a bound control.
DataTextFormat Property | Determines the data format when Text Control is used as a bound control.
Enabled Property | Returns or sets a value that determines whether a Text Control can respond to user-generated events.
FindReplace Method | Displays a 'Find' or 'Replace' dialog box.
FontDialog Method | Invokes Text Control's built-in font dialog box.
GetLineFromPoint Method | Returns the index of the line which contains a given point.
hWnd Property | Returns a handle to a Text Control.
InputPosFromPoint Method | Returns the text input position belonging to a certain geometric position.
ListAttrDialog Method | Invokes Text Control's built-in dialog box to set the attributes of bulleted and numbered lists.
LockWindowUpdate Property | Disables or reenables redrawing.
MousePointer Property | Returns or sets a value indicating the type of mouse pointer.
ParagraphDialog Method | Invokes Text Control's built-in paragraph attributes dialog box.
Refresh Method | Forces a complete repaint of a Text Control.
RulerHandle Property | Specifies the ruler control to be used with a Text Control.
SaveToMemory Method | Returns a byte array containing text data in a specified format. Use SaveToMemoryBuffer instead.
ScrollBars Property | Returns or sets a value indicating whether a Text Control has horizontal or vertical scroll bars.
ScrollPosX Property | Specifies the position of the horizontal scroll bar.
ScrollPosY Property | Specifies the position of the vertical scroll bar.
SizeMode Property | Specifies whether the Text Control can be moved or resized at run time.
StatusBarHandle Property | Specifies the status bar control to be used with a Text Control.
StyleDialog Method | Invokes the built-in dialog box for creating, deleting and modifying formatting styles.
TabDialog Method | Invokes the built-in dialog box that enables tabs to be set.
TableAttrDialog Method | Invokes Text Control's built-in table attributes dialog box.
ZoomFactor Property | Specifies the zoom factor for a Text Control.


Specifying a Serial Number in C++

If you are not using the TX Text Control with Visual Basic or Delphi you may have to set the license information for the control from your application. This is necessary for distributing your application correctly. Otherwise, you will have the problem that the dialog with the trial version information will be displayed all the time on the end users machine.

Visual C++ is one of the development systems that does not support the licensing model of Visual Basic.

Adding Code to the WM_CREATE Handler

To ensure a correct license for your application you must set the serial information prior any other call to the TX Text Control. Take a look of the following code snippet from the WM_CREATE handler of a Visual C++ sample application:

   ...
   if (CWnd::Create(lpszClassName, lpszWindowName, dwStyle,rect,
      pParentWnd, nID, pContext) == 0)
      return 0;
   WCHAR szLic[] = L"TS-1234567890";
   BSTR bstrKey = SysAllocString(szLic);
   BOOL bSuccess = m_txctrl.Create(NULL, dwStyle, rect,
      this, 1000, NULL, NULL,bstrKey);
   SysFreeString(bstrKey);
   if (!bSuccess)
      return 0;
   ...

The license string must be a valid Text Control serial number. Replace the example string "TS-1234567890" with your serial number.

Note: If you are using the trial version of TX Text Control, you do not have any license information. Please call the Create method with an empty string for the serial number.


Programmming Overview

This part contains an overview of TX Text Control's properties, methods and events sorted by programming categories, lists all used data types and contains a reference of the mouse- and keyboard interface.

Programming Categories
Data Types
Mouse and Keyboard Assignment


Programming Categories

The following provides a complete list of Text Control's properties, methods and events sorted by category.

Character Formatting
Paragraph Formatting
Bullets and Numbered Lists
Headers and Footers
Page and Document Settings
Stylesheet Formatting
Integrated Dialog Boxes
Tables
Zooming
Loading, Saving and Database Support
Images, Text Frames and OLE Objects
Hypertext Links
Clipboard Operations
Undo
Printing and Print Preview
Search and Replace
Line and Character Operations
Control Settings
Text Selections and Character Input
Scrolling
Text Fields
Tool Bars
XML Programming
Stylesheet Programming
Server Programming


Character Formatting

Properties
Property | Description
TXTextControl.BaseLine Specifies the baseline alignment for selected text.
TXTextControl.FontBold Returns or sets the bold font style.
TXTextControl.FontItalic Returns or sets the italic font style.
TXTextControl.FontName Returns or sets the font used to display text.
TXTextControl.FontSize Returns or sets a value that specifies the size of the font used to display text.
TXTextControl.FontStrikethru Returns or sets the strike thru font style.
TXTextControl.FontUnderline Returns or sets the underline font style.
TXTextControl.FontUnderlineStyle This property determines styles for the FontUnderline property.
TXTextControl.ForeColor Returns or sets the color used to display text in a Text Control.
TXTextControl.TextBkColor Returns or sets the background color for selected text.

Methods
Method | Description
TXTextControl.FontDialog Invokes the Text Control's built-in font dialog box and, after the user has closed the dialog box, specifies whether he has changed something.

Events
Event | Description
TXTextControl.CharFormatChange Occurs when the formatting attributes of the selected characters have been changed.


Paragraph Formatting

Properties
Property | Description
TXTextControl.Alignment Specifies the alignment of text in a Text Control.
TXTextControl.FrameDistance Returns or sets the distance between text and paragraph frame for the currently selected paragraph(s).
TXTextControl.FrameLineWidth Specifies the line widths of the currently selected paragraphs' frames.
TXTextControl.FrameStyle Returns or sets the style of the currently selected paragraphs' frames.
TXTextControl.IndentB Returns or sets an additional bottom distance (in twips) for a paragraph or a selected range of paragraphs.
TXTextControl.IndentFL Returns or sets an additional left indent (in twips) for the first line of a paragraph or a selected range of paragraphs.
TXTextControl.IndentL Returns or sets the left indent (in twips) for a paragraph or a selected range of paragraphs.
TXTextControl.IndentR Returns or sets the right indent (in twips) for a paragraph or a selected range of paragraphs.
TXTextControl.IndentT Returns or sets an additional top distance (in twips) for a paragraph or a selected range of paragraphs.
TXTextControl.LineSpacing Specifies the line spacing for the currently selected paragraphs as a percentage of the font size.
TXTextControl.LineSpacingT Specifies the line spacing for the currently selected paragraphs in twips.
TXTextControl.TabCurrent Specifies the current tab number for the properties TabPos and TabType.
TXTextControl.TabPos Determines the position, in twips, of a certain tab.
TXTextControl.TabType Determines the type of a certain tab.

Methods
Method | Description
TXTextControl.ParagraphDialog Invokes the Text Control's built-in paragraph attributes dialog box and, after the user has closed the dialog box, specifies whether he has changed something.
TXTextControl.TabDialog Invokes the Text Control's built-in dialog box for setting tabs.

Events
Event | Description
TXTextControl.ParagraphChange Occurs when the character input position has been moved to another paragraph.
TXTextControl.ParagraphFormatChange Occurs when the paragraph attributes of the selected paragraphs have been changed.


Bullets and Numbered Lists

Properties
Property | Description
TXTextControl.BulletAttribute This property returns or sets attributes for bulleted lists.
TXTextControl.ListType Returns or sets a list type for a paragraph or a selected range of paragraphs. Possible lists are bulleted and numbered lists.
TXTextControl.NumberingAttribute This property returns or sets attributes for numbered lists.

Methods
Method | Description
TXTextControl.ListAttrDialog Invokes the Text Control's built-in dialog box for setting attributes of bulleted and numbered lists.


Headers and Footers

Properties
Property | Description
TXTextControl.HeaderFooter This property determines which kind of headers and/or footers the document contains.
TXTextControl.HeaderFooterAtInputPos Returns which header or footer owns the current text input position.
TXTextControl.HeaderFooterPosition This property specifies the position of a header or footer.
TXTextControl.HeaderFooterStyle This property determines how headers and footers can be activated and how activated headers and footers appear on the screen.

Methods
Method | Description
TXTextControl.HeaderFooterActivate Activates or deactivates a header or a footer.
TXTextControl.HeaderFooterSelect This method determines whether a certain Text Control property or method manipulates a header or a footer or the main text.

Events
Event | Description
TXTextControl.HeaderFooterActivated Occurs when a header or footer has been activated.
TXTextControl.HeaderFooterDeactivated Occurs when a header or footer has been deactivated.


Page and Document Settings

Properties
Property | Description
TXTextControl.PageHeight Specifies the height of the page for the current document.
TXTextControl.PageMarginB Returns or sets the bottom margin for the pages of the current document.
TXTextControl.PageMarginL Returns or sets the left margin for the pages of the current document.
TXTextControl.PageMarginR Returns or sets the right margin for the pages of the current document.
TXTextControl.PageMarginT Returns or sets the top margin for the pages of the current document.
TXTextControl.PageWidth Specifies the width of the page for the current document.

Events
Event | Description
TXTextControl.PageFormatChange Occurs when the page format settings have been changed.


Stylesheet Formatting

Properties
Property | Description
TXTextControl.StyleCurrent Returns or sets the formatting style at the current input position or, if text is selected, changes all styles of the selected text to the specified style.

Methods
Method | Description
TXTextControl.StyleDialog Invokes the Text Control's built-in dialog box for creating, deleting and modifying formatting styles.

Events
Event | Description
TXTextControl.StyleChanged Occurs after the character input position has been moved to a text part formatted with another style.
TXTextControl.StyleListChanged Occurs after one or more formatting styles have been added or removed.


Integrated Dialog Boxes

Methods
Method Description
TXTextControl.FindReplace Displays a 'Find' or 'Replace' dialog box.
TXTextControl.FontDialog Invokes the Text Control's built-in font dialog box and, after the user has closed the dialog box, specifies whether he has changed something.
TXTextControl.ListAttrDialog Invokes the Text Control's built-in dialog box for setting attributes of bulleted and numbered lists.
TXTextControl.ObjectAttrDialog This method invokes the built-in dialog box for setting attributes of images, text frames and OLE objects.
TXTextControl.ParagraphDialog Invokes the Text Control's built-in paragraph attributes dialog box and, after the user has closed the dialog box, specifies whether he has changed something.
TXTextControl.StyleDialog Invokes the Text Control's built-in dialog box for creating, deleting and modifying formatting styles.
TXTextControl.TabDialog Invokes the Text Control's built-in dialog box for setting tabs.
TXTextControl.TableAttrDialog This method invokes the built-in dialog box for setting table attributes and, after the user has closed the dialog box, specifies whether he has changed something.


Tables

Properties
Property | Description
TXTextControl.TableAtInputPos Returns the table identifier of the table containing the input position.
TXTextControl.TableCanChangeAttr This property provides information about whether the attributes of all the selected table cells can be altered.
TXTextControl.TableCanDeleteColumn This property provides information about whether a table column can be deleted.
TXTextControl.TableCanDeleteLines This property provides information about whether table lines can be deleted.
TXTextControl.TableCanInsert This property provides information about whether a table can be inserted.
TXTextControl.TableCanInsertColumn This property provides information about whether a table column can be inserted.
TXTextControl.TableCanInsertLines This property provides information about whether table lines can be inserted.
TXTextControl.TableCanSplit Checks whether a table can be split.
TXTextControl.TableCellAttribute Returns or sets attributes of a table cell.
TXTextControl.TableCellLength Returns the number of characters in a table cell.
TXTextControl.TableCellStart Returns the character index (one-based) of the first character in a table cell.
TXTextControl.TableCellText Returns or sets the text of a table cell.
TXTextControl.TableColAtInputPos Returns the number of the current input column in a table.
TXTextControl.TableColumns Informs about the number of columns a specified table contains.
TXTextControl.TableGridLines This property determines whether or not grid lines in tables are visible.
TXTextControl.TableNestedLevel Gets the nested level for the specified table.
TXTextControl.TableRowAtInputPos Returns the number of the current input row in a table.
TXTextControl.TableRows Informs about the number of rows a specified table contains.

Methods
Method | Description
TXTextControl.TableAttrDialog This method invokes the built-in dialog box for setting table attributes and, after the user has closed the dialog box, specifies whether he has changed something.
TXTextControl.TableDeleteColumn This method deletes the table column with the current input position.
TXTextControl.TableDeleteLines This method deletes the currently selected table lines or the table line at the current input position.
TXTextControl.TableGetOuter This method returns a table's outer table.
TXTextControl.TableGetOuterMost This method returns a table's outermost table.
TXTextControl.TableInsert This method inserts a new table in the text.
TXTextControl.TableInsertColumn This method inserts a table column left or right of the column with the current input position.
TXTextControl.TableInsertLines This member function inserts table lines above or below the table line with the current input position.
TXTextControl.TableNext This method returns a enumaration number of the table that follows the specified table in the Text Control's current text.
TXTextControl.TableSplit Splits a table below or above the current input position.

Events
Event | Description
TXTextControl.TableCreated Occurs after a new table has been created as a result of a text insertion via the clipboard.
TXTextControl.TableDeleted Occurs after a table has been deleted.
TXTextControl.TableFormatChanged Occurs after a table has been formatted with the built-in mouse-interface.


Zooming

Properties
Property | Description
TXTextControl.ZoomFactor Specifies the zoom factor for a Text Control.

Events
Event | Description
TXTextControl.Zoomed Occurs when the Text Control has been zoomed.


Loading, Saving and Database Support

Properties
Property | Description
TXTextControl.DataText The DataText property is used internally by Visual Basic when a Text Control is used as a bound control.
TXTextControl.DataTextFormat When using a Text Control as a bound control, this property specifies if the data which is exchanged with a database is text or binary data.
TXTextControl.Device This property returns or sets the device for which the current Text Control document is formatted.
TXTextControl.LoadSaveAttribute This property enables an application to specify several attributes that can be used in combination with the Load and Save methods for the following situations: 1.
TXTextControl.RTFSelText This property works much like the standard SelText property.
TXTextControl.Text Returns or sets the complete text of a Text Control.

Methods
Method | Description
TXTextControl.Load Loads text in a certain format from a file and inserts it into the Text Control.
TXTextControl.LoadFromMemory Loads text in a certain format from a buffer and inserts it into the Text Control.
TXTextControl.ResetContents Deletes the complete contents of a Text Control including tables, objects, marked text fields and headers and footers.
TXTextControl.Save Saves data in a file with a specified format.
TXTextControl.SaveToMemory Returns a one-dimensional byte array containing text data in a specified format.
TXTextControl.SaveToMemoryBuffer Returns a buffer containing text data in a specified format.

Events
Event | Description
TXTextControl.Change Indicates that the contents of a Text Control have changed.


Images, Text Frames and OLE Objects

Properties
Property | Description
TXTextControl.ImageDisplayMode Provides several modes to set the way in which images are displayed or refreshed.
TXTextControl.ImageExportCompressionQuality Determines a value between 1 and 100, which is the quality of a lossy data compression used, if the image is saved.
TXTextControl.ImageExportFilename Determines the file name of an image used if a document is saved.
TXTextControl.ImageExportFilters This property returns a string which specifies the available filters for exporting images.
TXTextControl.ImageExportFormat Determines the format used if an image is saved.
TXTextControl.ImageExportMaxResolution Determines the maximum resolution in dots per inch used, if the image is saved.
TXTextControl.ImageFilename Determines the image file name of an inserted image.
TXTextControl.ImageFilters This property returns a string which specifies the available image filters.
TXTextControl.ImageSaveMode When saving a document using the Save method, this property determines whether the image data or the image file name is stored.
TXTextControl.ObjectCurrent Returns or sets the current object for setting properties of images, text frames or OLE objects.
TXTextControl.ObjectDistance Specifies the distance (in twips) between an image, text frame or OLE object and the text that flows around it.
TXTextControl.ObjectHeight Returns or sets the natural height, in twips, of an image, text frame or OLE object.
TXTextControl.ObjectItem Returns a reference to an OLE object.
TXTextControl.ObjectScaleX Specifies the object's horizontal scaling factor as a percentage.
TXTextControl.ObjectScaleY Specifies the object's vertical scaling factor as a percentage.
TXTextControl.ObjectSizeMode Specifies whether an inserted image, text frame or OLE object can be moved or resized at run time.
TXTextControl.ObjectTextflow Informs about the way in which text flows around an image, text frame or OLE object.
TXTextControl.ObjectWidth Returns or sets the natural width, in twips, of an image, text frame or OLE object.
TXTextControl.TextFrameBackColor Returns or sets the background color of a text frame.
TXTextControl.TextFrameBorderWidth Specifies the width, in twips, of a text frame's border line.
TXTextControl.TextFrameInternalMargin Specifies the distance (in twips) between a text frame's border line and the text.
TXTextControl.TextFrameMarkerLines This property determines whether or not marker lines for text frames are visible.

Methods
Method | Description
TXTextControl.ImageInsert This method inserts a new image anchored to a paragraph.
TXTextControl.ImageInsertAsChar This method inserts a new image which is then handled like a single character in the text.
TXTextControl.ImageInsertFixed This method inserts a new image at a fixed geometrical position.
TXTextControl.ObjectAttrDialog This method invokes the built-in dialog box for setting attributes of images, text frames and OLE objects.
TXTextControl.ObjectDelete This method deletes an image, text frame or OLE object.
TXTextControl.ObjectGetSelected This method returns the identifier of the currently selected object.
TXTextControl.ObjectInsert This method inserts a new OLE object or other control anchored to a paragraph.
TXTextControl.ObjectInsertAsChar This method inserts a new OLE object or other control which is then handled like a single character in the text.
TXTextControl.ObjectInsertFixed This method inserts a new OLE object or other control at a fixed geometrical position.
TXTextControl.ObjectNext This method returns the identifier of the object that follows the specified object in a Text Control's internal list of objects.
TXTextControl.TextFrameInsert This method inserts a new text frame anchored to a paragraph.
TXTextControl.TextFrameInsertAsChar This method inserts a new text frame, which is then handled as a single character in the text.
TXTextControl.TextFrameInsertFixed This method inserts a new text frame at a fixed geometrical position.
TXTextControl.TextFrameSelect This method determines whether a certain Text Control property or method manipulates a text frame or the main text.

Events
Event | Description
TXTextControl.ObjectClicked Occurs when an object has been clicked on.
TXTextControl.ObjectCreated This event specifies that a new object has been created.
TXTextControl.ObjectDblClicked Occurs when an object has been double-clicked on.
TXTextControl.ObjectDeleted Occurs when an object has been deleted.
TXTextControl.ObjectGetData Occurs when a document which contains objects, is saved.
TXTextControl.ObjectGethWnd Occurs when a document which contains objects, is loaded.
TXTextControl.ObjectGetZoom Occurs when an object's zoom factor is requested.
TXTextControl.ObjectMoved Occurs if an image, text frame or OLE object has been moved with the built-in mouse interface.
TXTextControl.ObjectPrint Occurs when a document containing objects is printed.
TXTextControl.ObjectRightClicked Occurs when an object has been clicked on with the right mouse button.
TXTextControl.ObjectScrollOut Occurs when an object is scrolled out of the visible area.
TXTextControl.ObjectSetData Occurs when a document which contains objects, is loaded.
TXTextControl.ObjectSetZoom Occurs when an object's zoom factor is to be changed.
TXTextControl.ObjectSized Occurs if an image, text frame or OLE object has been resized with the built-in mouse interface.
TXTextControl.TextFrameActivated Occurs when a text frame has obtained the input focus.
TXTextControl.TextFrameDeactivated Occurs when a text frame has lost the input focus.


Hypertext Links

Properties
Property | Description
TXTextControl.FieldType This property sets or returns the type of a marked text field.
TXTextControl.FieldTypeData This property sets or returns the data that belongs to a marked text field of a special type.

Events
Event | Description
TXTextControl.FieldLinkClicked Occurs when a marked text field has been clicked on that represents the source of a hypertext link.


Clipboard Operations

Properties
Property | Description
TXTextControl.CanCopy Informs whether a part of a Text Control's document has been selected and can be copied to the clipboard.
TXTextControl.CanPaste Informs whether the clipboard contains a format that can be pasted into a Text Control's document.

Methods
Method | Description
TXTextControl.Clip Performs Text Control clipboard actions.


Undo

Properties
Property | Description
TXTextControl.AllowUndo Determines whether the undo buffer is active or not.
TXTextControl.CanRedo Informs whether an operation can be re-done using the Redo method.
TXTextControl.CanUndo Informs whether an operation can be undone using the Undo method.

Methods
Method | Description
TXTextControl.EndUndoAction Defines the end of an undo action.
TXTextControl.Redo This method can be used to redo the last Text Control operation.
TXTextControl.StartUndoAction Defines the beginning of an undo action.
TXTextControl.Undo This method can be used to undo the last Text Control operation.


Printing and Print Preview

Properties
Property | Description
TXTextControl.CurrentPages Returns the number of pages contained in the current document.
TXTextControl.PrintColors Specifies whether text colors are printed as colors or in black.
TXTextControl.PrintDevice Sets the printer device context for TextContol's built-in printing function.
TXTextControl.PrintOffset Determines whether Text Control starts printing exactly at the top left corner of the page, or at the printer's physical printing offset.
TXTextControl.PrintZoom Specifies a zoom factor for printing.

Methods
Method | Description
TXTextControl.PrintDoc Prints a Text Control document or a part of a Text Control document on the default printer.
TXTextControl.PrintPage Prints a page of text on the default printer.


Search and Replace

Methods
Method Description
TXTextControl.Find Searches the text in a Text Control for a given string.
TXTextControl.FindReplace Displays a 'Find' or 'Replace' dialog box.


Line and Character Operations

Methods
Method Description
TXTextControl.GetBaseLinePos Returns the baseline position of the specified line.
TXTextControl.GetCharFromLine Returns the position of a line's first character.
TXTextControl.GetLineCount Returns the number of text lines in a Text Control.
TXTextControl.GetLineFromChar Returns the index of the line which contains the character with the specified character position.
TXTextControl.GetLineFromPoint Returns the index of the line which contains a given point.
TXTextControl.GetLineRect Returns the rectangular area covered by a line of text.


Control Settings

Properties
Property | Description
TXTextControl.AutoExpand Specifies whether the control size should expand automatically when the text insertion or format changes results in text that does not fit into the Text Control anymore.
TXTextControl.BackColor Returns or sets the background color of a Text Control.
TXTextControl.BackStyle Returns or sets a value indicating whether the background of a Text Control is transparent or opaque.
TXTextControl.BorderStyle Returns or sets the border style for a Text Control.
TXTextControl.CaretWidth This property returns or sets the width of the caret in pixels.
TXTextControl.ClipChildren This property is only used for Text Controls which act as a container for other Text Controls or embedded objects.
TXTextControl.ClipSiblings This property determines the clipping behaviour of each of the child controls which belong to a common container control.
TXTextControl.ControlChars Specifies if control characters are visible.
TXTextControl.EditMode Specifies whether the Text Control operates in edit mode or in one of the two read-only modes.
TXTextControl.Enabled Returns or sets a value that determines whether a Text Control can respond to user-generated events.
TXTextControl.hWnd Returns a handle to a Text Control.
TXTextControl.Language Determines the language in which Text Control displays dialog boxes and error messages.
TXTextControl.LockWindowUpdate Disables or reenables redrawing.
TXTextControl.MousePointer Returns or sets a value indicating the type of mouse pointer displayed when the mouse is over a particular part of a Text Control at run time.
TXTextControl.ResourceFile Returns or sets the file name of a resource library which Text Control loads to display resources like information strings, error messages and built-in dialog boxes.
TXTextControl.SizeMode Specifies whether the Text Control can be moved or resized at run time.
TXTextControl.TabKey Determines if the keyboard's tab key moves the input focus to the next control or to insert tabulators in the Text Control's text.
TXTextControl.ViewMode Returns or sets the mode in which Text Control displays its text contents.
TXTextControl.WordWrapMode This property returns or sets the mode how Text Control handles word wrapping in lines without space or other word breaking characters.

Methods
Method | Description
TXTextControl.GetTextExtent Returns the extension of the complete text in twips.
TXTextControl.Refresh This method forces a complete repaint of a Text Control.

Events
Event | Description
TXTextControl.Error Occurs when the Text Control reports an error.
TXTextControl.HExpand Occurs when the Text Control has changed its window size horizontally.
TXTextControl.Move Occurs when a Text Control has been moved with the mouse.
TXTextControl.Size Occurs when a Text Control has been resized with the mouse.
TXTextControl.VExpand Occurs when the Text Control has changed its window size vertically.


Text Selections and Character Input

Properties
Property | Description
TXTextControl.CurrentInputPosition Returns or sets an array of three values which specify the page, line and column number of the current text input position.
TXTextControl.FormatSelection Specifies whether character and paragraph formatting properties apply to the whole text or to a particular selection only.
TXTextControl.HideSelection Specifies whether a text selection is hidden when the Text Control looses the input focus.
TXTextControl.InsertionMode Specifies whether text is inserted or overwrites existing text.
TXTextControl.SelLength Returns or sets the number of characters selected.
TXTextControl.SelStart Returns or sets the starting point of text selected or indicates the position of the insertion point if no text is selected.
TXTextControl.SelText Returns or sets the string containing the currently selected text.

Methods
Method | Description
TXTextControl.InputPosFromPoint Returns the text input position belonging to a certain geometric position.

Events
Event | Description
TXTextControl.Click Occurs when the user presses and then releases a mouse button over a Text Control.
TXTextControl.DblClick Occurs when the user presses and releases a mouse button and then presses and releases it again over a Text Control.
TXTextControl.KeyDown Occurs when the user presses a key while the Text Control has the input focus.
TXTextControl.KeyPress Occurs when the user presses and releases an ANSI key while the Text Control has the input focus.
TXTextControl.KeyStateChange Occurs when the character insertion mode or when the state of the NUMLOCK or CAPSLOCK key has been changed.
TXTextControl.KeyUp Occurs when the user releases a key while the Text Control has the input focus.
TXTextControl.MouseDown Occurs when the user presses a mouse button.
TXTextControl.MouseMove Occurs when the user moves the mouse.
TXTextControl.MouseUp Occurs when the user releases a mouse button.
TXTextControl.PosChange Occurs when the current character input position has been changed.


Scrolling

Properties
Property | Description
TXTextControl.ScrollBars Returns or sets a value indicating whether a Text Control has horizontal or vertical scroll bars.
TXTextControl.ScrollPosX Specifies the position of the horizontal scroll bar in twips.
TXTextControl.ScrollPosY Specifies the position of the vertical scroll bar in twips.

Events
Event | Description
TXTextControl.AutoScroll This event occurs when the cursor leaves the visible portion of a Text Control's client area whilst a text selection is being expanded with the mouse.
TXTextControl.CaretOut Occurs when the current input position indicated through the caret has been moved to a control that is completely out of the visible area.
TXTextControl.CaretOutBottom Occurs when the current input position indicated through the caret has been moved out of the visible area at the bottom.
TXTextControl.CaretOutLeft Occurs when the current input position indicated through the caret has been moved out of the visible area at the left side.
TXTextControl.CaretOutRight Occurs when the current input position indicated through the caret has been moved out of the visible area at the right side.
TXTextControl.CaretOutTop Occurs when the current input position indicated through the caret has been moved out of the visible area at the top.
TXTextControl.HScroll Occurs when the horizontal scroll position has been changed.
TXTextControl.VScroll Occurs when the vertical scroll position has been changed.


Text Fields

Properties
Property | Description
TXTextControl.FieldAtInputPos Returns the field identifier of the field containing the input position.
TXTextControl.FieldChangeable Specifies if the contents of a marked text field can be changed by the user.
TXTextControl.FieldCurrent Returns or sets the identifier of the current marked text field for the Fieldxxx properties, methods and events.
TXTextControl.FieldData This property relates numeric or string data to a marked text field.
TXTextControl.FieldDeleteable Specifies whether a marked text field can be deleted by the user.
TXTextControl.FieldEditAttr This property returns or sets attributes for advanced editing inside marked text fields.
TXTextControl.FieldEnd Returns the end position of a marked text field.
TXTextControl.FieldPosX Returns the horizontal position of a marked text field.
TXTextControl.FieldPosY Returns the vertical position of a marked text field.
TXTextControl.FieldStart Specifies the start position of a marked text field.
TXTextControl.FieldText Returns or sets the text which is contained within a marked text field.

Methods
Method | Description
TXTextControl.FieldDelete Deletes the marked text field specified by the FieldCurrent property, or changes it to simple text.
TXTextControl.FieldGoto Sets the current input position to the beginning of the specified marked text field and scrolls the text so that this position is at the top of the control's visible text.
TXTextControl.FieldInsert Inserts a new marked text field at the current caret position.
TXTextControl.FieldNext This method returns the identifier of the marked text field that follows the specified field in the Text Control's current text.

Events
Event | Description
TXTextControl.FieldChanged Occurs when the text of a marked text field has been changed.
TXTextControl.FieldClicked Occurs when a marked text field has been clicked on.
TXTextControl.FieldCreated Occurs when a marked text field has been pasted from the clipboard.
TXTextControl.FieldDblClicked Occurs when a marked text field has been double-clicked on.
TXTextControl.FieldDeleted Occurs when a marked text field has been deleted.
TXTextControl.FieldEntered Occurs when the current input position, indicated by the caret, has been moved to a position that belongs to a marked text field.
TXTextControl.FieldLeft Occurs when the current input position indicated by the caret has been moved to a position that does not belong to the marked text field at the previous input position.
TXTextControl.FieldSetCursor Occurs when the cursor is moved over a marked text field.


Tool Bars

Controls and Objects
Control/Object | Description
TXButtonBar A TXButtonBar control represents a button bar for a Text Control.
TXRulerBar A TXRulerBar control represents a ruler bar for a Text Control.
TXStatusBar A TXStatusBar control represents a status bar for a Text Control.
TXTextControl The TXTextControl control is the main control that is used to display and edit a text document.

Properties
Property | Description
TXTextControl.ButtonBarHandle Specifies the button bar control to be used with a Text Control.
TXTextControl.RulerHandle Specifies the ruler control to be used with a Text Control.
TXTextControl.StatusBarHandle Specifies the status bar control to be used with a Text Control.

Events
Event | Description
TXTextControl.ConnectTools MS Access only: Occurs after all Text Controls, Rulers, Button Bars and Status Bars have been created and are ready to be connected.


XML Programming

Controls and Objects
Control/Object | Description
XMLElement An XMLElement object is an OLE Automation object that represents an element in an XML document.
XMLElements A XMLElements collection object is an OLE Automation object whose members represent all XML elements with a certain tag name.

Properties
Property | Description
TXTextControl.XMLEditMode Specifies whether Text Control operates in an edit mode that validates the XML document according to the document's DTD.
TXTextControl.XMLElements Returns a collection of all XML elements with the same tag name.

Events
Event | Description
TXTextControl.XMLInvalid Occurs when a loaded XML document cannot be validated with the document type definition (DTD) referenced in the document.
TXTextControl.XMLNotWellFormed Occurs when a loaded XML document is not well-formed.


Stylesheet Programming

Controls and Objects
Control/Object | Description
Style A Style object is an OLE Automation object that represents a formatting style.
Styles A Styles collection object is an OLE Automation object whose members represent all formatting styles a Text Control document contains.

Properties
Property | Description
TXTextControl.Styles Returns a collection of all formatting styles in a document.


Server Programming

Methods
Method Description
TXTextControl.EnableAutomationServer Enables a Text Control to work as an automation server.


Data Types

The Text Control reference uses the following data types:

Data Type | Description
Byte | Is a one-byte value with the range 0 to 255.
Boolean | Is a two-byte value that can be True or False.
Integer | Is a two-byte value with the range -32,768 to 32,767.
Long | Is a four-byte value with the range -2,147,483,648 to 2,147,483,647
Handle | Is a four-byte value with the range 0 to 4,294,967,295.
String | Is a length-prefixed string of unlimited size.
Variant | Can be any of the previously explained data types, including arrays of these types.


Mouse and Keyboard Assignment

Mouse Assignment
Keyboard Assignment


Mouse Assignment

Mouse Action | Reaction of Text Control
Click | Moves cursor to point of click or selects an image, text frame or OLE object.
Click and Drag | Selects text from point of button down to point where button is released or moves an image, text frame or OLE object.
Shift+Click | Extends the selection to the point of click.
Double-click | Selects the word that is clicked on.
Double-click and drag | Extends the selection from word to word.
Triple-click | Selects the line that is clicked on.
Triple-click and drag | Extends the selection from row to row.
PgUp/PgDown | Scrolls the text up or down one client area height minus the height of one line of text. Active only if a vertical scrollbar exists.


Keyboard Assignment

Key type | Reaction of Text Control
HOME | Moves the caret to the beginning of the line.
END | Moves the caret to the end of the line.
(Left Arrow) | Moves the caret one character to the left.
(Right Arrow) | Moves the caret one character to the right.
(Up Arrow) | Moves the caret one line up.
(Down Arrow) | Moves the caret one line down.
CTRL+(Left Arrow) | Moves the caret to the beginning of the current word.
CTRL+(Right Arrow) | Moves the caret to the beginning of the next word.
CTRL+HOME | Moves the caret to start of text.
CTRL+END | Moves the caret to end of text.
CTRL+ENTER | Inserts a new page.
SHIFT+ENTER | Creates a line feed without beginning a new paragraph.
CTRL+(-) | Inserts an end-of-line hyphen.
DEL | Deletes selected text.
CTRL+X | Copies selected text to the Clipboard and deletes the selection.
CTRL+V | Copies selected text to the clipboard.
CTRL+Z | Undos the last action.
CTRL+Y | Restores the last action.
CTRL+SHIFT+(Spacebar) | Inserts a non-breaking space.
CTRL+(Backspace) | Deletes the previous word.
SHIFT+(Backspace) | Deletes the previous word.

Pressing a key while SHIFT is pressed extends the current selection to the new caret position.


Reference

Contains a complete reference of all properties, methods and events provided through the implemented TX Text Control controls and objects. All properties, methods and events are sorted in alphabetical order.

TXTextControl Control
TXButtonBar Control
TXRulerBar Control
TXStatusBar Control
Style Object
Styles Collection Object
XMLElement Object
XMLElements Collection Object
Obsolete Properties, Methods and Events


TXTextControl Control

The TXTextControl control is the main control that is used to display and edit a text document. The large amout of this control's properties, methods and events are listed in alphabetical order here and are sorted by category in the Programming Categories chapter.
Syntax: TXTextControl

Properties
Property | Description
Alignment Specifies the alignment of text in a Text Control.
AllowUndo Determines whether the undo buffer is active or not.
AutoExpand Specifies whether the control size should expand automatically when the text insertion or format changes results in text that does not fit into the Text Control anymore.
BackColor Returns or sets the background color of a Text Control.
BackStyle Returns or sets a value indicating whether the background of a Text Control is transparent or opaque.
BaseLine Specifies the baseline alignment for selected text.
BorderStyle Returns or sets the border style for a Text Control.
BulletAttribute This property returns or sets attributes for bulleted lists.
ButtonBarHandle Specifies the button bar control to be used with a Text Control.
CanCopy Informs whether a part of a Text Control's document has been selected and can be copied to the clipboard.
CanPaste Informs whether the clipboard contains a format that can be pasted into a Text Control's document.
CanRedo Informs whether an operation can be re-done using the Redo method.
CanUndo Informs whether an operation can be undone using the Undo method.
CaretWidth This property returns or sets the width of the caret in pixels.
ClipChildren This property is only used for Text Controls which act as a container for other Text Controls or embedded objects.
ClipSiblings This property determines the clipping behaviour of each of the child controls which belong to a common container control.
ControlChars Specifies if control characters are visible.
CurrentInputPosition Returns or sets an array of three values which specify the page, line and column number of the current text input position.
CurrentPages Returns the number of pages contained in the current document.
DataText The DataText property is used internally by Visual Basic when a Text Control is used as a bound control.
DataTextFormat When using a Text Control as a bound control, this property specifies if the data which is exchanged with a database is text or binary data.
Device This property returns or sets the device for which the current Text Control document is formatted.
EditMode Specifies whether the Text Control operates in edit mode or in one of the two read-only modes.
Enabled Returns or sets a value that determines whether a Text Control can respond to user-generated events.
FieldAtInputPos Returns the field identifier of the field containing the input position.
FieldChangeable Specifies if the contents of a marked text field can be changed by the user.
FieldCurrent Returns or sets the identifier of the current marked text field for the Fieldxxx properties, methods and events.
FieldData This property relates numeric or string data to a marked text field.
FieldDeleteable Specifies whether a marked text field can be deleted by the user.
FieldEditAttr This property returns or sets attributes for advanced editing inside marked text fields.
FieldEnd Returns the end position of a marked text field.
FieldPosX Returns the horizontal position of a marked text field.
FieldPosY Returns the vertical position of a marked text field.
FieldStart Specifies the start position of a marked text field.
FieldText Returns or sets the text which is contained within a marked text field.
FieldType This property sets or returns the type of a marked text field.
FieldTypeData This property sets or returns the data that belongs to a marked text field of a special type.
FontBold Returns or sets the bold font style.
FontItalic Returns or sets the italic font style.
FontName Returns or sets the font used to display text.
FontSize Returns or sets a value that specifies the size of the font used to display text.
FontStrikethru Returns or sets the strike thru font style.
FontUnderline Returns or sets the underline font style.
FontUnderlineStyle This property determines styles for the FontUnderline property.
ForeColor Returns or sets the color used to display text in a Text Control.
FormatSelection Specifies whether character and paragraph formatting properties apply to the whole text or to a particular selection only.
FrameDistance Returns or sets the distance between text and paragraph frame for the currently selected paragraph(s).
FrameLineWidth Specifies the line widths of the currently selected paragraphs' frames.
FrameStyle Returns or sets the style of the currently selected paragraphs' frames.
HeaderFooter This property determines which kind of headers and/or footers the document contains.
HeaderFooterAtInputPos Returns which header or footer owns the current text input position.
HeaderFooterPosition This property specifies the position of a header or footer.
HeaderFooterStyle This property determines how headers and footers can be activated and how activated headers and footers appear on the screen.
HideSelection Specifies whether a text selection is hidden when the Text Control looses the input focus.
hWnd Returns a handle to a Text Control.
ImageDisplayMode Provides several modes to set the way in which images are displayed or refreshed.
ImageExportCompressionQuality Determines a value between 1 and 100, which is the quality of a lossy data compression used, if the image is saved.
ImageExportFilename Determines the file name of an image used if a document is saved.
ImageExportFilters This property returns a string which specifies the available filters for exporting images.
ImageExportFormat Determines the format used if an image is saved.
ImageExportMaxResolution Determines the maximum resolution in dots per inch used, if the image is saved.
ImageFilename Determines the image file name of an inserted image.
ImageFilters This property returns a string which specifies the available image filters.
ImageSaveMode When saving a document using the Save method, this property determines whether the image data or the image file name is stored.
IndentB Returns or sets an additional bottom distance (in twips) for a paragraph or a selected range of paragraphs.
IndentFL Returns or sets an additional left indent (in twips) for the first line of a paragraph or a selected range of paragraphs.
IndentL Returns or sets the left indent (in twips) for a paragraph or a selected range of paragraphs.
IndentR Returns or sets the right indent (in twips) for a paragraph or a selected range of paragraphs.
IndentT Returns or sets an additional top distance (in twips) for a paragraph or a selected range of paragraphs.
InsertionMode Specifies whether text is inserted or overwrites existing text.
Language Determines the language in which Text Control displays dialog boxes and error messages.
LineSpacing Specifies the line spacing for the currently selected paragraphs as a percentage of the font size.
LineSpacingT Specifies the line spacing for the currently selected paragraphs in twips.
ListType Returns or sets a list type for a paragraph or a selected range of paragraphs. Possible lists are bulleted and numbered lists.
LoadSaveAttribute This property enables an application to specify several attributes that can be used in combination with the Load and Save methods for the following situations: 1.
LockWindowUpdate Disables or reenables redrawing.
MousePointer Returns or sets a value indicating the type of mouse pointer displayed when the mouse is over a particular part of a Text Control at run time.
NumberingAttribute This property returns or sets attributes for numbered lists.
ObjectCurrent Returns or sets the current object for setting properties of images, text frames or OLE objects.
ObjectDistance Specifies the distance (in twips) between an image, text frame or OLE object and the text that flows around it.
ObjectHeight Returns or sets the natural height, in twips, of an image, text frame or OLE object.
ObjectItem Returns a reference to an OLE object.
ObjectScaleX Specifies the object's horizontal scaling factor as a percentage.
ObjectScaleY Specifies the object's vertical scaling factor as a percentage.
ObjectSizeMode Specifies whether an inserted image, text frame or OLE object can be moved or resized at run time.
ObjectTextflow Informs about the way in which text flows around an image, text frame or OLE object.
ObjectWidth Returns or sets the natural width, in twips, of an image, text frame or OLE object.
PageHeight Specifies the height of the page for the current document.
PageMarginB Returns or sets the bottom margin for the pages of the current document.
PageMarginL Returns or sets the left margin for the pages of the current document.
PageMarginR Returns or sets the right margin for the pages of the current document.
PageMarginT Returns or sets the top margin for the pages of the current document.
PageWidth Specifies the width of the page for the current document.
PrintColors Specifies whether text colors are printed as colors or in black.
PrintDevice Sets the printer device context for TextContol's built-in printing function.
PrintOffset Determines whether Text Control starts printing exactly at the top left corner of the page, or at the printer's physical printing offset.
PrintZoom Specifies a zoom factor for printing.
ResourceFile Returns or sets the file name of a resource library which Text Control loads to display resources like information strings, error messages and built-in dialog boxes.
RTFSelText This property works much like the standard SelText property.
RulerHandle Specifies the ruler control to be used with a Text Control.
ScrollBars Returns or sets a value indicating whether a Text Control has horizontal or vertical scroll bars.
ScrollPosX Specifies the position of the horizontal scroll bar in twips.
ScrollPosY Specifies the position of the vertical scroll bar in twips.
SelLength Returns or sets the number of characters selected.
SelStart Returns or sets the starting point of text selected or indicates the position of the insertion point if no text is selected.
SelText Returns or sets the string containing the currently selected text.
SizeMode Specifies whether the Text Control can be moved or resized at run time.
StatusBarHandle Specifies the status bar control to be used with a Text Control.
StyleCurrent Returns or sets the formatting style at the current input position or, if text is selected, changes all styles of the selected text to the specified style.
Styles Returns a collection of all formatting styles in a document.
TabCurrent Specifies the current tab number for the properties TabPos and TabType.
TabKey Determines if the keyboard's tab key moves the input focus to the next control or to insert tabulators in the Text Control's text.
TableAtInputPos Returns the table identifier of the table containing the input position.
TableCanChangeAttr This property provides information about whether the attributes of all the selected table cells can be altered.
TableCanDeleteColumn This property provides information about whether a table column can be deleted.
TableCanDeleteLines This property provides information about whether table lines can be deleted.
TableCanInsert This property provides information about whether a table can be inserted.
TableCanInsertColumn This property provides information about whether a table column can be inserted.
TableCanInsertLines This property provides information about whether table lines can be inserted.
TableCanSplit Checks whether a table can be split.
TableCellAttribute Returns or sets attributes of a table cell.
TableCellLength Returns the number of characters in a table cell.
TableCellStart Returns the character index (one-based) of the first character in a table cell.
TableCellText Returns or sets the text of a table cell.
TableColAtInputPos Returns the number of the current input column in a table.
TableColumns Informs about the number of columns a specified table contains.
TableGridLines This property determines whether or not grid lines in tables are visible.
TableNestedLevel Gets the nested level for the specified table.
TableRowAtInputPos Returns the number of the current input row in a table.
TableRows Informs about the number of rows a specified table contains.
TabPos Determines the position, in twips, of a certain tab.
TabType Determines the type of a certain tab.
Text Returns or sets the complete text of a Text Control.
TextBkColor Returns or sets the background color for selected text.
TextFrameBackColor Returns or sets the background color of a text frame.
TextFrameBorderWidth Specifies the width, in twips, of a text frame's border line.
TextFrameInternalMargin Specifies the distance (in twips) between a text frame's border line and the text.
TextFrameMarkerLines This property determines whether or not marker lines for text frames are visible.
ViewMode Returns or sets the mode in which Text Control displays its text contents.
WordWrapMode This property returns or sets the mode how Text Control handles word wrapping in lines without space or other word breaking characters.
XMLEditMode Specifies whether Text Control operates in an edit mode that validates the XML document according to the document's DTD.
XMLElements Returns a collection of all XML elements with the same tag name.

ZoomFactor Specifies the zoom factor for a Text Control.

Methods
Method | Description
Clip Performs Text Control clipboard actions.
EnableAutomationServer Enables a Text Control to work as an automation server.
EndUndoAction Defines the end of an undo action.
FieldDelete Deletes the marked text field specified by the FieldCurrent property, or changes it to simple text.
FieldGoto Sets the current input position to the beginning of the specified marked text field and scrolls the text so that this position is at the top of the control's visible text.
FieldInsert Inserts a new marked text field at the current caret position.
FieldNext This method returns the identifier of the marked text field that follows the specified field in the Text Control's current text.
Find Searches the text in a Text Control for a given string.
FindReplace Displays a 'Find' or 'Replace' dialog box.
FontDialog Invokes the Text Control's built-in font dialog box and, after the user has closed the dialog box, specifies whether he has changed something.
GetBaseLinePos Returns the baseline position of the specified line.
GetCharFromLine Returns the position of a line's first character.
GetLineCount Returns the number of text lines in a Text Control.
GetLineFromChar Returns the index of the line which contains the character with the specified character position.
GetLineFromPoint Returns the index of the line which contains a given point.
GetLineRect Returns the rectangular area covered by a line of text.
GetTextExtent Returns the extension of the complete text in twips.
HeaderFooterActivate Activates or deactivates a header or a footer.
HeaderFooterSelect This method determines whether a certain Text Control property or method manipulates a header or a footer or the main text.
ImageInsert This method inserts a new image anchored to a paragraph.
ImageInsertAsChar This method inserts a new image which is then handled like a single character in the text.
ImageInsertFixed This method inserts a new image at a fixed geometrical position.
InputPosFromPoint Returns the text input position belonging to a certain geometric position.
ListAttrDialog Invokes the Text Control's built-in dialog box for setting attributes of bulleted and numbered lists.
Load Loads text in a certain format from a file and inserts it into the Text Control.
LoadFromMemory Loads text in a certain format from a buffer and inserts it into the Text Control.
ObjectAttrDialog This method invokes the built-in dialog box for setting attributes of images, text frames and OLE objects.
ObjectDelete This method deletes an image, text frame or OLE object.
ObjectGetSelected This method returns the identifier of the currently selected object.
ObjectInsert This method inserts a new OLE object or other control anchored to a paragraph.
ObjectInsertAsChar This method inserts a new OLE object or other control which is then handled like a single character in the text.
ObjectInsertFixed This method inserts a new OLE object or other control at a fixed geometrical position.
ObjectNext This method returns the identifier of the object that follows the specified object in a Text Control's internal list of objects.
ParagraphDialog Invokes the Text Control's built-in paragraph attributes dialog box and, after the user has closed the dialog box, specifies whether he has changed something.
PrintDoc Prints a Text Control document or a part of a Text Control document on the default printer.
PrintPage Prints a page of text on the default printer.
Redo This method can be used to redo the last Text Control operation.
Refresh This method forces a complete repaint of a Text Control.
ResetContents Deletes the complete contents of a Text Control including tables, objects, marked text fields and headers and footers.
Save Saves data in a file with a specified format.
SaveToMemory Returns a one-dimensional byte array containing text data in a specified format.
SaveToMemoryBuffer Returns a buffer containing text data in a specified format.
StartUndoAction Defines the beginning of an undo action.
StyleDialog Invokes the Text Control's built-in dialog box for creating, deleting and modifying formatting styles.
TabDialog Invokes the Text Control's built-in dialog box for setting tabs.
TableAttrDialog This method invokes the built-in dialog box for setting table attributes and, after the user has closed the dialog box, specifies whether he has changed something.
TableDeleteColumn This method deletes the table column with the current input position.
TableDeleteLines This method deletes the currently selected table lines or the table line at the current input position.
TableGetOuter This method returns a table's outer table.
TableGetOuterMost This method returns a table's outermost table.
TableInsert This method inserts a new table in the text.
TableInsertColumn This method inserts a table column left or right of the column with the current input position.
TableInsertLines This member function inserts table lines above or below the table line with the current input position.
TableNext This method returns a enumaration number of the table that follows the specified table in the Text Control's current text.
TableSplit Splits a table below or above the current input position.
TextFrameInsert This method inserts a new text frame anchored to a paragraph.
TextFrameInsertAsChar This method inserts a new text frame, which is then handled as a single character in the text.
TextFrameInsertFixed This method inserts a new text frame at a fixed geometrical position.
TextFrameSelect This method determines whether a certain Text Control property or method manipulates a text frame or the main text.
Undo This method can be used to undo the last Text Control operation.

Events
Event | Description
AutoScroll This event occurs when the cursor leaves the visible portion of a Text Control's client area whilst a text selection is being expanded with the mouse.
CaretOut Occurs when the current input position indicated through the caret has been moved to a control that is completely out of the visible area.
CaretOutBottom Occurs when the current input position indicated through the caret has been moved out of the visible area at the bottom.
CaretOutLeft Occurs when the current input position indicated through the caret has been moved out of the visible area at the left side.
CaretOutRight Occurs when the current input position indicated through the caret has been moved out of the visible area at the right side.
CaretOutTop Occurs when the current input position indicated through the caret has been moved out of the visible area at the top.
Change Indicates that the contents of a Text Control have changed.
CharFormatChange Occurs when the formatting attributes of the selected characters have been changed.
Click Occurs when the user presses and then releases a mouse button over a Text Control.
ConnectTools MS Access only: Occurs after all Text Controls, Rulers, Button Bars and Status Bars have been created and are ready to be connected.
DblClick Occurs when the user presses and releases a mouse button and then presses and releases it again over a Text Control.
Error Occurs when the Text Control reports an error.
FieldChanged Occurs when the text of a marked text field has been changed.
FieldClicked Occurs when a marked text field has been clicked on.
FieldCreated Occurs when a marked text field has been pasted from the clipboard.
FieldDblClicked Occurs when a marked text field has been double-clicked on.
FieldDeleted Occurs when a marked text field has been deleted.
FieldEntered Occurs when the current input position, indicated by the caret, has been moved to a position that belongs to a marked text field.
FieldLeft Occurs when the current input position indicated by the caret has been moved to a position that does not belong to the marked text field at the previous input position.
FieldLinkClicked Occurs when a marked text field has been clicked on that represents the source of a hypertext link.
FieldSetCursor Occurs when the cursor is moved over a marked text field.
HeaderFooterActivated Occurs when a header or footer has been activated.
HeaderFooterDeactivated Occurs when a header or footer has been deactivated.
HExpand Occurs when the Text Control has changed its window size horizontally.
HScroll Occurs when the horizontal scroll position has been changed.
KeyDown Occurs when the user presses a key while the Text Control has the input focus.
KeyPress Occurs when the user presses and releases an ANSI key while the Text Control has the input focus.
KeyStateChange Occurs when the character insertion mode or when the state of the NUMLOCK or CAPSLOCK key has been changed.
KeyUp Occurs when the user releases a key while the Text Control has the input focus.
MouseDown Occurs when the user presses a mouse button.
MouseMove Occurs when the user moves the mouse.
MouseUp Occurs when the user releases a mouse button.
Move Occurs when a Text Control has been moved with the mouse.
ObjectClicked Occurs when an object has been clicked on.
ObjectCreated This event specifies that a new object has been created.
ObjectDblClicked Occurs when an object has been double-clicked on.
ObjectDeleted Occurs when an object has been deleted.
ObjectGetData Occurs when a document which contains objects, is saved.
ObjectGethWnd Occurs when a document which contains objects, is loaded.
ObjectGetZoom Occurs when an object's zoom factor is requested.
ObjectMoved Occurs if an image, text frame or OLE object has been moved with the built-in mouse interface.
ObjectPrint Occurs when a document containing objects is printed.
ObjectRightClicked Occurs when an object has been clicked on with the right mouse button.
ObjectScrollOut Occurs when an object is scrolled out of the visible area.
ObjectSetData Occurs when a document which contains objects, is loaded.
ObjectSetZoom Occurs when an object's zoom factor is to be changed.
ObjectSized Occurs if an image, text frame or OLE object has been resized with the built-in mouse interface.
PageFormatChange Occurs when the page format settings have been changed.

ParagraphChange Occurs when the character input position has been moved to another paragraph.
ParagraphFormatChange Occurs when the paragraph attributes of the selected paragraphs have been changed.
PosChange Occurs when the current character input position has been changed.
Size Occurs when a Text Control has been resized with the mouse.
StyleChanged Occurs after the character input position has been moved to a text part formatted with another style.
StyleListChanged Occurs after one or more formatting styles have been added or removed.
TableCreated Occurs after a new table has been created as a result of a text insertion via the clipboard.
TableDeleted Occurs after a table has been deleted.
TableFormatChanged Occurs after a table has been formatted with the built-in mouse-interface.
TextFrameActivated Occurs when a text frame has obtained the input focus.
TextFrameDeactivated Occurs when a text frame has lost the input focus.
VExpand Occurs when the Text Control has changed its window size vertically.
VScroll Occurs when the vertical scroll position has been changed.
XMLInvalid Occurs when a loaded XML document cannot be validated with the document type definition (DTD) referenced in the document.
XMLNotWellFormed Occurs when a loaded XML document is not well-formed.
Zoomed Occurs when the Text Control has been zoomed.


TXTextControl.Alignment Property
Description: Specifies the alignment of text in a Text Control.
Syntax: TXTextControl.Alignment [= value]

Setting | Description
0 | (Default) Text is left-aligned.
1 | Text is right-aligned.
2 | Text is centered.
3 | Text is justified.
4 | This value cannot be assigned to the property. Its purpose is to indicate that the selected text contains paragraphs which have different types of alignment.
Remarks: If the FormatSelection property has previously been set to True, changing the Alignment property affects only the currently selected paragaph. If FormatSelection has been set to False the setting applies to the entire control, in which case a value of 4 does not occur.
Data Types: Integer.


TXTextControl.AllowUndo Property
Description: Determines whether the undo buffer is active or not. If a Text Control is used for tasks like generating reports, it can be useful to deactivate the undo buffer to save time and memory. By default the undo buffer is active. When running on a server the undo buffer is deactivated by default.
Syntax: TXTextControl.AllowUndo
Data Types: Boolean.

Introduced: 11.0
See also: Undo Method, Redo Method.


TXTextControl.AutoExpand Property
Description: Specifies whether the control size should expand automatically when the text insertion or format changes results in text that does not fit into the Text Control anymore. This property is only available if the ViewMode property has been set to Simple Control.
Syntax: TXTextControl.AutoExpand [= boolean]

Setting | Description
True | The window size expands automatically.
False | Fixed window size.
Data Types: Integer.

Limitations: Run time only.


TXTextControl.AutoScroll Event
Description: This event occurs when the cursor leaves the visible portion of a Text Control's client area whilst a text selection is being expanded with the mouse. It is only sent if the cursor movement does not result in a caret movement. This happens if the cursor is moved outside the client area or if the cursor is moved over parts which are not covered with text below the last line. In all cases where the cursor movement results in a caret movement, the Text Control sends CaretOutxxx events. This event occurs only if the ViewMode property has been set to Simple Control.
Syntax: AutoScroll( )
See also: CaretOut Event.


TXTextControl.BackColor Property
Description: Returns or sets the background color of a Text Control. Text Control uses the Microsoft Windows operating enviroment red-green-blue (RGB) color scheme.
Syntax: TXTextControl.BackColor [= value]

Setting | Description
RGB colors | The valid range for a RGB color is 0 to &HFFFFFF. The high byte of a number in this range equals 0; the lower 3 bytes, from least to most significant byte, determine the amount of red, green, and blue, respectively. The red, green, and blue components are each represented by a number between 0 and 255 (&HFF).
System colors | Colors specified by the system color constants. If the high byte isn't 0, Text Control uses the system colors, as defined in the user's Control Panel settings.
Data Types: Long.

See also: ForeColor Property.


TXTextControl.BackStyle Property
Description: Returns or sets a value indicating whether the background of a Text Control is transparent or opaque. This property is only available if the ViewMode property has been set to Simple Control.
Syntax: TXTextControl.BackStyle [= value]

Setting | Description
0 - Transparent | The Text Control has a transparent background.
1 - Opaque | (Default) The control's BackColor property setting fills the background.
Remarks: A transparent background is only possible when the control's container does not clip its controls. The most containers have a property to enable or disable clipping. For example a Visual Basic form has a ClipControls property.
Data Types: Integer.

See also: BackColor Property.


TXTextControl.BaseLine Property
Description: Specifies the baseline alignment for selected text. A negative value is used to specify a subscript offset, a positive value for superscript. Text Control limits the baseline alignment to 960 twips in both directions.
Syntax: TXTextControl.BaseLine [= value]
Data Types: Integer.

See also: FormatSelection Property.


TXTextControl.BorderStyle Property
Description: Returns or sets the border style for a Text Control.
Syntax: TXTextControl.BorderStyle [= value]

Setting | Description
0 - None | The Text Control has no border.
1 - Fixed Single | (Default) The Text Control has a fixed border.
Data Types: Integer.


TXTextControl.BulletAttribute Property
Description: This property returns or sets attributes for bulleted lists. A new attribute set with this property has only effect when the ListType Method property is used the next time.
Syntax: TXTextControl.BulletAttribute(Attribute) [= value]

Parameter | Description
Attribute | Determines the attribute that is to be changed or returned. Possible values are listed in Constants.
Constants: Valid values for the Attribute parameter are:

Constant Description
txBulletChar (0) Specifies the character code of the bullet character. This value must be the code of a character in the Windows Symbol character set.
txBulletFormatChar (1) Specifies the code of the character that defines the formatting of the gap between the bullet character and the following text. Possible codes are:

Code | Meaning
0 | The text immediately follows the bullet character.
9 | The text is displayed at the next tabulator position.
32 | The text follows the bullet character seperated with a space character.
txBulletLevel (2) Specifies the level of the bulleted list. The topmost level has the number one, the maximum possible level is 10.
txBulletPos (3) Defines the position of the bullet character in twips.
txBulletSize (4) Defines the font size of the bullet character in twips. If this attribute is -1, Text Control displays the bullet character with the font size of the following text.
txBulletTextPos (5) Defines, in twips, the position of the text that follows the bullet character.
Data Types:
txBulletChar | Integer
txBulletFormatChar | Integer
txBulletLevel | Integer
txBulletPos | Integer
txBulletSize | Integer
txBulletTextPos | Integer
Limitations: Run time only.

See also: ListAttrDialog Method, ListType Property, NumberingAttribute Property.


TXTextControl.ButtonBarHandle Property
Description: Specifies the button bar control to be used with a Text Control.
Syntax: TXTextControl.ButtonBarHandle [= ButtonBar.hWnd]
Remarks: The Button Bar, like the Status Bar and the Ruler, is one of the additional controls which are contained in the Text Control OCX file.
Data Types: Handle.

Limitations: Run time only.

See also: RulerHandle Property, StatusBarHandle Property.


TXTextControl.CanCopy Property
Description: Informs whether a part of a Text Control's document has been selected and can be copied to the clipboard.
Syntax: TXTextControl.CanCopy
Data Types: Boolean.

Limitations: Read only, run time only.

See also: CanPaste Property, Clip Method.


TXTextControl.CanPaste Property
Description: Informs whether the clipboard contains a format that can be pasted into a Text Control's document.
Syntax: TXTextControl.CanPaste
Data Types: Boolean.

Limitations: Read only, run time only.

See also: CanCopy Property, Clip Method.


TXTextControl.CanRedo Property
Description: Informs whether an operation can be re-done using the Redo method.
Syntax: TXTextControl.CanRedo

Setting | Description
0 | Nothing to redo.
10 | Redo Insert Text
11 | Redo Delete Text
12 | Redo Format Text
15 | Redo Insert Style
16 | Redo Delete Style
17 | Redo Style Attributes
18 | Redo Style
19 | Redo Insert Image
20 | Redo Delete Image
21 | Redo Image Attributes
22 | Redo Table Attributes
23 | Redo Insert Table
24 | Redo Delete Table Column
25 | Redo Insert Table Column
26 | Redo Delete Table Rows
27 | Redo Insert Table Rows
28 | Redo Character Formatting
29 | Redo Paragraph Formatting
30 | Redo Bullets and Numbering
31 | Redo Text Field Attributes
32 | Redo Insert Text Field
33 | Redo Delete Text Field
34 | Redo Replace
35 | Redo Insert Text Frame
36 | Redo Delete Text Frame
37 | Redo Text Frame Attributes
38 | Redo Edit Text Frame
39 | Redo Insert Object
40 | Redo Delete Object
41 | Redo Object Attributes
Data Types: Integer.

Limitations: Read only, Runtime only.

See also: CanUndo Property, Undo Method, Redo Method.


TXTextControl.CanUndo Property
Description: Informs whether an operation can be undone using the Undo method.
Syntax: TXTextControl.CanUndo

Setting | Description
0 | Nothing to undo.
10 | Undo Insert Text
11 | Undo Delete Text
12 | Undo Format Text
15 | Undo Insert Style
16 | Undo Delete Style
17 | Undo Style Attributes
18 | Undo Style
19 | Undo Insert Image
20 | Undo Delete Image
21 | Undo Image Attributes
22 | Undo Table Attributes
23 | Undo Insert Table
24 | Undo Delete Table Column
25 | Undo Insert Table Column
26 | Undo Delete Table Rows
27 | Undo Insert Table Rows
28 | Undo Character Formatting
29 | Undo Paragraph Formatting
30 | Undo Bullets and Numbering
31 | Undo Text Field Attributes
32 | Undo Insert Text Field
33 | Undo Delete Text Field
34 | Undo Replace
35 | Undo Insert Text Frame
36 | Undo Delete Text Frame
37 | Undo Text Frame Attributes
38 | Undo Edit Text Frame
39 | Undo Insert Object
40 | Undo Delete Object
41 | Undo Object Attributes
Data Types: Integer.

Limitations: Read only, Runtime only.

See also: CanRedo Property, Undo Method, Redo Method.


TXTextControl.CaretOut Event
Description: Occurs when the current input position indicated through the caret has been moved to a control that is completely out of the visible area. This event occurs only if the ViewMode property has been set to Simple Control.
Syntax: CaretOut( )


TXTextControl.CaretOutBottom Event
Description: Occurs when the current input position indicated through the caret has been moved out of the visible area at the bottom. This event occurs only if the ViewMode property has been set to Simple Control.
Syntax: CaretOutBottom( )


TXTextControl.CaretOutLeft Event
Description: Occurs when the current input position indicated through the caret has been moved out of the visible area at the left side. This event occurs only if the ViewMode property has been set to Simple Control.
Syntax: CaretOutLeft( )


TXTextControl.CaretOutRight Event
Description: Occurs when the current input position indicated through the caret has been moved out of the visible area at the right side. This event occurs only if the ViewMode property has been set to Simple Control.
Syntax: CaretOutRight( )


TXTextControl.CaretOutTop Event
Description: Occurs when the current input position indicated through the caret has been moved out of the visible area at the top. This event occurs only if the ViewMode property has been set to Simple Control.
Syntax: CaretOutTop( )


TXTextControl.CaretWidth Property
Description: This property returns or sets the width of the caret in pixels. Text Control supports different settings for the caret in marked text fields and in standard text. A width value of zero indicates the default setting which is the system-defined window-border width in standard text and 2 pixels in marked text fields. The maximum width is 255 pixels. A different caret width in marked text fields is only used if the &H4 attribute has been set with the FieldEditAttr property.

Syntax: TXTextControl.CaretWidth(Caret) [= Width]
Parameter Description
Caret Specifies the caret. It can be one of the following settings:

Setting | Meaning
0 | Specifies the caret in standard text.
1 | Specifies the caret in marked text fields.
Data Types:
Caret: | Integer
Property value: | Integer
Limitations: Run time only.


TXTextControl.Change Event
Description: Indicates that the contents of a Text Control have changed.
Syntax: Change( )


TXTextControl.CharFormatChange Event
Description: Occurs when the formatting attributes of the selected characters have been changed. It also occurs if font settings have been changed because the Text Control has adapted fonts to a new output device.
Syntax: CharFormatChange( )


TXTextControl.Click Event
Description: Occurs when the user presses and then releases a mouse button over a Text Control.
Syntax: Click( )


TXTextControl.Clip Method
Description: Performs Text Control clipboard actions.
Syntax: TXTextControl.Clip Action

Parameter | Description
1 | Cuts out the selected text and copies it to the clipboard.
2 | Copies the selected text to the clipboard.
3 | Pastes text from the clipboard.
4 | Clears the selection.
Return Value: This method has no return value.
Data Types:
Action Integer

Example: This Basic example copies the selected text from a Text Control named "TXTextControl1" to the clipboard when the user selects the "Edit/Copy" menu item:
Sub mnuEdit_Copy_Click ()
   TXTextControl1.Clip 2
End Sub


TXTextControl.ClipChildren Property
Description: This property is only used for Text Controls which act as a container for other Text Controls or embedded objects. When this property is set to True, the areas occupied by the child controls are excluded from the update area.
Syntax: TXTextControl.ClipChildren [= boolean]

Setting | Description
True | Exclude areas which are occupied by child controls from the update area.
False | (Default) Update areas which are occupied by child controls.
Data Types: Boolean.

Example: See Forms2 Basic sample program.
See also: ClipSiblings Property.


TXTextControl.ClipSiblings Property
Description: This property determines the clipping behaviour of each of the child controls which belong to a common container control. It must be set to False if the program is to allow transparent Text Controls to overlap other Text Controls.

Syntax: TXTextControl.ClipSiblings [= boolean]

Setting | Description
True | (Default) Excludes those areas occupied by other child controls from the update area.
False | Updates areas which are occupied by other child controls.
Data Types: Boolean.

Example: See Forms2 Basic sample program.
See also: ClipChildren Property.


TXTextControl.ConnectTools Event
Description: MS Access only: Occurs after all Text Controls, Rulers, Button Bars and Status Bars have been created and are ready to be connected. This has to be done in 2 steps as shows in the example below. (The example assumes that you have created a Text Control named 'tx' and a Ruler Bar, Button Bar and Status Bar named Ruler, ButtonBar and StatusBar.)
Syntax: ConnectTools( )
Example: The following MS Access example shows the two-step process. The first step is code that must be added to the form's Load event the second step is code that must be added to this event.
Sub Form_Load ()
   Me!tx.object.RulerHandle = 1
   Me!tx.object.ButtonBarHandle = 1
   Me!tx.object.StatusBarHandle = 1
End Sub
Sub TX_ConnectTools ()
   Me!tx.object.RulerHandle = Me!Ruler.object.hWnd
   Me!tx.object.ButtonBarHandle = Me!ButtonBar.object.hWnd
   Me!tx.object.StatusBarHandle = Me!StatusBar.object.hWnd
End Sub


TXTextControl.ControlChars Property
Description: Specifies if control characters are visible.
Syntax: TXTextControl.ControlChars [= boolean]

Setting | Description
True | Control characters, like space or paragraph break, are visible.
False | Control characters are invisible.
Data Types: Boolean.


TXTextControl.CurrentInputPosition Property
Description: Returns or sets an array of three values which specify the page, line and column number of the current text input position. These values are the same as shown in Text Control's status bar.
Syntax: TXTextControl.CurrentInputPosition [= Array]

Index | Description
0 | Specifies the current page number. The first page has the number one.
1 | Specifies the current line number. The first line has the number one.
2 | Specifies the current column number. The first column has the number one.
Data Types: Array of 3 Long.

Limitations: Run time only.

Example: The following code snippet demonstrates how to use the CurrentInputPosition property to get the current position of the caret in the document and afterwards set its position to the very beginning of the text.
 ' Get current position
  cur = TXTextControl1.CurrentInputPosition
  deb = Str(cur(0)) + "-" + Str(cur(1)) + "-" + Str(cur(2))
  MsgBox deb
  ' Set new position
  cur(0) = 1 ' page
  cur(1) = 1 ' line
  cur(2) = 0 ' col
  TXTextControl1.CurrentInputPosition = cur


TXTextControl.CurrentPages Property
Description: Returns the number of pages contained in the current document.
Syntax: TXTextControl.CurrentPages
Remarks: The value of this property depends on the size of the text as well as on the settings of the PageHeight, PageWidth and PageMarginx properties.
Data Types: Long.

Limitations: Read only, run time only.

Example: See PrintPage method example.
See also: PageHeight Property, PageWidth Property, PageMarginx Properties, PrintDevice Property, PrintPage Method.


TXTextControl.DataText Property
Description: The DataText property is used internally by Visual Basic when a Text Control is used as a bound control. This property is not to be manipulated by the developer and will likely be hidden in future releases.
Syntax:


TXTextControl.DataTextFormat Property
Description: When using a Text Control as a bound control, this property specifies if the data which is exchanged with a database is text or binary data.
Syntax: TXTextControl.DataTextFormat [= value]

Setting | Description
0 | Data is stored as text.
1 | Text and formatting information are stored in the internal binary format.
Data Types: Integer.


TXTextControl.DblClick Event
Description: Occurs when the user presses and releases a mouse button and then presses and releases it again over a Text Control.
Syntax: DblClick( )


TXTextControl.Device Property
Description: This property returns or sets the device for which the current Text Control document is formatted.
Syntax: TXTextControl.Device [= Device]

Setting | Description
1 | The document is formatted for the screen.
2 | (Default) The document is formatted for the standard printer.
Otherwise | A character string identifying an installed printer. This string must be in the same format as that used in the Windows system settings, for example: Postscript Printer, PSCRIPT, LPT1:
Data Types: Integer or String.

Limitations: Run time only.


TXTextControl.EditMode Property
Description: Specifies whether the Text Control operates in edit mode or in one of the two read-only modes.
Syntax: TXTextControl.EditMode [= value]

Setting | Description
0 - Edit | (Default) Edit mode. This mode can be used to edit and display text. The cursor is the text I-beam cursor.
1 - Read and Select | Read-only mode. This mode can be used to display and select text. The cursor is the standard arrow cursor.
2 - Read only | This mode can be used to display text only. Text input and selecting text with the mouse or the keyboard is not possible. The cursor is the standard arrow cursor.
Data Types: Integer.


TXTextControl.EnableAutomationServer Method
Description: Enables a Text Control to work as an automation server.
Syntax: TXTextControl.EnableAutomationServer
Return Value: If the method was successful it returns True, otherwise it returns False.
Data Types:
Return value: Boolean


TXTextControl.Enabled Property
Description: Returns or sets a value that determines whether a Text Control can respond to user-generated events.
Syntax: TXTextControl.Enabled [= boolean]

Setting | Description
True | (Default) Allows a Text Control to respond to events.
False | Prevents a Text Control from responding to events.
Data Types: Boolean.


TXTextControl.EndUndoAction Method
Description: Defines the end of an undo action. It can be used, if more than one property or method call is to be defined as a single undo action. All property and/or method calls between StartUndoAction and EndUndoAction define a single undo action.
Syntax: TXTextControl.EndUndoAction
Introduced: 11.0
See also: StartUndoAction Method.


TXTextControl.Error Event
Description: Occurs when the Text Control reports an error.
Syntax: Error(Number, Description, Scode, Source, HelpFile, HelpContext, CancelDisplay)

Parameter | Description
Number | Is the error number.
Description | Is a corresponding error string. This string can be changed.
Scode | Is the OLE Status Code.
Source | Is the name of the module which caused the error.
HelpFile | Is the name of a help file.
HelpContext | Is the help context ID in this help file.
CancelDisplay | Can be set to True if the application wants to display its own error string. When this parameter is not set to True, the control will display a message box showing the error string.
Data Types:
Number: | Integer
Description: | String
Scode: | Long
Source: | String
HelpFile: | String
HelpContext: | Long
CancelDisplay | Boolean


TXTextControl.FieldAtInputPos Property
Description: Returns the field identifier of the field containing the input position. Zero is returned when the input position is not inside a field.
Syntax: TXTextControl.FieldAtInputPos
Data Types: Integer.

Limitations: Read only, run time only.


TXTextControl.FieldChangeable Property
Description: Specifies if the contents of a marked text field can be changed by the user. The field identifier must have previously been determined with the FieldCurrent property.
Syntax: TXTextControl.FieldChangeable [= boolean]

Setting | Description
True | The text which is contained in the field can be changed.
False | The text cannot be changed.
Data Types: Boolean.

Limitations: Run time only.

See also: FieldDeleteable Property.


TXTextControl.FieldChanged Event
Description: Occurs when the text of a marked text field has been changed.
Syntax: FieldChanged(FieldId)

Parameter | Description
FieldId | Is the identifier of the field that has been changed.
Remarks: The value of the FieldCurrent property is updated with the value given through the FieldId parameter.
Data Types:
FieldId: Integer

See also: FieldClicked Event, FieldCreated Event, FieldDblClicked Event, FieldDeleted Event, FieldSetCursor Event.


TXTextControl.FieldClicked Event
Description: Occurs when a marked text field has been clicked on.
Syntax: FieldClicked(FieldId)

Parameter | Description
FieldId | Is the identifier of the field that has been clicked on.
Remarks: The value of the FieldCurrent property is updated with the value given through the FieldId parameter.
Data Types:
FieldId: Integer

See also: FieldChanged Event, FieldCreated Event, FieldDblClicked Event, FieldDeleted Event, FieldSetCursor Event.


TXTextControl.FieldCreated Event
Description: Occurs when a marked text field has been pasted from the clipboard.
Syntax: FieldCreated(FieldId)

Parameter | Description
FieldId | Is the identifier of the field that has been created.
Remarks: The value of the FieldCurrent property is updated with the value given through the FieldId parameter.
Data Types:
FieldId: Integer

See also: FieldChanged Event, FieldClicked Event, FieldDblClicked Event, FieldDeleted Event, FieldSetCursor Event.


TXTextControl.FieldCurrent Property
Description: Returns or sets the identifier of the current marked text field for the Fieldxxx properties, methods and events.
Syntax: TXTextControl.FieldCurrent [= FieldId]
Data Types: Integer.

Limitations: Run time only.

Example: The Basic example creates a marked text field with a text content of 'New Field' and afterwards changes the text to 'Hello':
Sub Create()
   Dim FieldId As Integer
   'Create a marked text field and store its number
   TXTextControl.FieldInsert "New Field"
   FieldId = TXTextControl.FieldCurrent
   ..
   'Change the text
   TXTextControl.FieldCurrent = FieldId
   TXTextControl.FieldText = "Hello"
End Sub


TXTextControl.FieldData Property
Description: This property relates numeric or string data to a marked text field.
Syntax: TXTextControl.FieldData(FieldId) [= Data]

Parameter | Description
FieldId | Identifies the field that is to be manipulated.
Remarks: The specified data can be a long value or a character string. A long value of zero or an empty string deletes all data previously related to the specified marked text field.
Data Types: Long or String.

Limitations: Run time only.

See also: FieldInsert Method.


TXTextControl.FieldDblClicked Event
Description: Occurs when a marked text field has been double-clicked on.
Syntax: FieldDblClicked(FieldId)

Parameter | Description
FieldId | Is the identifier of the field that has been double-clicked on.
Remarks: The value of the FieldCurrent property is updated with the value given through the FieldId parameter.
Data Types:
FieldId: Integer

See also: FieldChanged Event, FieldClicked Event, FieldCreated Event, FieldDeleted Event, FieldSetCursor Event.


TXTextControl.FieldDelete Method
Description: Deletes the marked text field specified by the FieldCurrent property, or changes it to simple text.
Syntax: TXTextControl.FieldDelete DeleteTotal

Parameter | Description
DeleteTotal | Specifies whether only the field or the field including its text is deleted. If this parameter is True, the marked text field including its text is deleted. If this parameter is False, the marked text field is deleted, but its text contents are preserved.
Return Value: The method returns True when the operation could be performed, otherwise it returns False.
Data Types:
DeleteTotal: | Boolean
Return value: | Boolean


TXTextControl.FieldDeleteable Property
Description: Specifies whether a marked text field can be deleted by the user. The field identifier must have previously been determined with the FieldCurrent property.
Syntax: TXTextControl.FieldDeleteable [= boolean]

Setting | Description
True | The field can be deleted.
False | The field cannot be deleted.
Data Types: Boolean.

Limitations: Run time only.

See also: FieldChangeable Property.


TXTextControl.FieldDeleted Event
Description: Occurs when a marked text field has been deleted.
Syntax: FieldDeleted(FieldId)

Parameter | Description
FieldId | Is the identifier of the field that has been deleted.
Remarks: The value of the FieldCurrent property is set to zero.
Data Types:
FieldId: Integer

See also: FieldChanged Event, FieldClicked Event, FieldCreated Event, FieldDblClicked Event, FieldSetCursor Event.


TXTextControl.FieldEditAttr Property
Description: This property returns or sets attributes for advanced editing inside marked text fields.
Syntax: TXTextControl.FieldEditAttr(FieldId) [= Attr]

Parameter | Description
FieldId | Identifies the field that is to be manipulated. Possible property settings are listed in Constants.
Constants: The following lists the possible property values. These values can be combined by adding the desired constant values. Changing one option does not affect the other. The default value of a newly inserted field is: &H2 + &H8 + &H20 + &H80

Constant | Description
&H1 | Implements a second character input position at the beginning and the end of the specified marked text field.
&H2 | Performs normal editing at the beginning and the end of the specified marked text field.
&H4 | Changes the width of the caret when the character input position is inside the specified marked text field.
&H8 | Uses the normal text caret when the character input position is inside the specified marked text field.
&H10 | Displays the text of the specified marked text field with a gray background when the input position is inside this field.
&H20 | Displays the text of the specified marked text field with the standard control background when the input position is inside this field.
&H40 | Enables the normal double-click processing inside marked text fields that starts a wordwise selection.
&H80 | Disables the normal double-click processing inside marked text fields.
Data Types: Integer.

Limitations: Run time only.

See also: FieldInsert Method.


TXTextControl.FieldEnd Property
Description: Returns the end position of a marked text field. The field identifier must have previously been determined with the FieldCurrent property.
Syntax: TXTextControl.FieldEnd
Data Types: Long.

Limitations: Read only, run time only.

See also: FieldStart Property.


TXTextControl.FieldEntered Event
Description: Occurs when the current input position, indicated by the caret, has been moved to a position that belongs to a marked text field. It only occurs if the caret has been moved using the keyboard. If the caret has been moved with a mouse click a FieldClicked event is sent.
Syntax: FieldEntered(FieldId)

Parameter | Description
FieldId | Is the identifier of the field that has been entered.
Remarks: This event that does not change the value of the FieldCurrent property.
Data Types:
FieldId: Integer

See also: FieldLeft Event.


TXTextControl.FieldGoto Method
Description: Sets the current input position to the beginning of the specified marked text field and scrolls the text so that this position is at the top of the control's visible text.
Syntax: TXTextControl.FieldGoto FieldType, FieldIdOrName

Parameter | Description
FieldType | Specifies the type of the marked text field. See the Constants section of the FieldType property for valid values.
FieldIdOrName | Identifies the marked text field to which should be scrolled. It must be a valid field identifier. For fields of the type txFieldLinkTarget this parameter can also be the name of the field. For fields of the type txFieldTopic this parameter can also be a valid topic number.
Return Value: If the field could be found the method returns True, otherwise it returns False.
Data Types:
FieldType: | Integer
FieldIdOrName: | Integer or String
Return value: | Boolean


TXTextControl.FieldInsert Method
Description: Inserts a new marked text field at the current caret position.
Syntax: TXTextControl.FieldInsert FieldText

Parameter | Description
FieldText | Specifies the text contents for the new marked text field.
Return Value: The method returns True if a field could be inserted, otherwise it returns False.
Remarks: Selected text can be converted to a marked text field by using an empty string as FieldText. Inserting a marked text field changes the value of the FieldCurrent property to the identifier of the newly created field.
Data Types:
FieldText: | String
Return value: | Boolean
Example: See the description of the FieldCurrent property.


TXTextControl.FieldLeft Event
Description: Occurs when the current input position indicated by the caret has been moved to a position that does not belong to the marked text field at the previous input position.
Syntax: FieldLeft(FieldId)

Parameter | Description
FieldId | Is the identifier of the field that has been left.
Remarks: This event that does not change the value of the FieldCurrent property.
Data Types:
FieldId: Integer

See also: FieldEntered Event.


TXTextControl.FieldLinkClicked Event
Description: Occurs when a marked text field has been clicked on that represents the source of a hypertext link.
Syntax: FieldLinkClicked(FieldId, FieldType, TypeData)

Parameter | Description
FieldId | Is the identifier of the field that has been clicked on.
FieldType | Is the type of the field that has been clicked on. This event occurs only for fields of the types txFieldExternalLink and txFieldInternalLink.
TypeData | Specifies a character string that is the information to where the link points. This data has either been set with the FieldTypeData property or has been created through a text filter. For fields of the type txFieldExternalLink this can be any kind of address or file name. For fields of the type txFieldInternalLink this is the name of a marked text field of the type txFieldLinkTarget.
Data Types:
FieldId: | Integer
FieldType: | Integer
TypeData: | String
See also: FieldTypeData Property.


TXTextControl.FieldNext Method
Description: This method returns the identifier of the marked text field that follows the specified field in the Text Control's current text. It can be used to find the next field in the text or to enumerate all fields. In a list of linked Text Controls the search is performed in all controls.
Syntax: TXTextControl.FieldNext FieldId, FieldGroup
Parameter Description
FieldId Specifies a field identifier. If this parameter is zero the first field's identifier is returned.
FieldGroup This parameter can be the sum of one or more constants used to seperate fields with certain attributes. Valid values are described in the following list. If FieldGroup is zero, the method enumerates all fields.

Value | Description
0 | Returns the identifiers of all fields.
&H1 | Returns only identifiers of fields which are both changeable and deleteable.
&H2 | Returns only identifiers of fields which are unchangeable.
&H4 | Returns only identifiers of fields which are undeleteable.
&H100 | Returns only identifiers of fields which have the type txFieldLinkTarget.
&H200 | Returns only identifiers of fields which have the type txFieldExternalLink.
&H400 | Returns only identifiers of fields which have the type txFieldInternalLink.
&H800 | Returns only identifiers of fields which have the type txFieldPageNumber.
&H1000 | Returns only identifiers of fields which have the type txFieldHighlight.
&H2000 | Returns only identifiers of fields which have the type txFieldTopic.
Data Types:
FieldId: | Integer
FieldGroup: | Integer
Return value: | Integer
See also: FieldChangeable Property, FieldDeleteable Property, FieldType Property.


TXTextControl.FieldPosX Property
Description: Returns the horizontal position of a marked text field. The field identifier must have previously been determined with the FieldCurrent property.
Syntax: TXTextControl.FieldPosX
Remarks: The property value is the distance in horizontal direction between the left border of the marked text field and the left border of the Text Control. It is not affected by the scrollbar positions.
Data Types: Long.

Limitations: Read only, run time only.

See also: FieldPosY Property.


TXTextControl.FieldPosY Property
Description: Returns the vertical position of a marked text field. The field identifier must have previously been determined with the FieldCurrent property.
Syntax: TXTextControl.FieldPosY
Remarks: The property value is the distance in vertical direction between the upper left of the marked text field and the upper left of the Text Control. It is not affected by the scrollbar positions.
Data Types: Long.

Limitations: Read only, run time only.

See also: FieldPosX Property.


TXTextControl.FieldSetCursor Event
Description: Occurs when the cursor is moved over a marked text field.
Syntax: FieldSetCursor(FieldId, MousePointer)

Parameter | Description
FieldId | Is the identifier of the field where the cursor is moved over.
MousePointer | When this parameter is changed Text Control uses the specified cursor whilst moving over the marked text field. When this parameter is not changed, Text Control uses its standard cursor for marked text fields (Up Arrow). For possible values see the description of the MousePointer property.
Remarks: This event that does not change the value of the FieldCurrent property.
Data Types:
FieldId: | Integer
MousePointer: | Integer
See also: FieldChanged Event, FieldClicked Event, FieldCreated Event, FieldDblClicked Event, FieldDeleted Event.


TXTextControl.FieldStart Property
Description: Specifies the start position of a marked text field. The field identifier must have previously been determined with the FieldCurrent property.
Syntax: TXTextControl.FieldStart
Data Types: Long.

Limitations: Read only, run time only.

See also: FieldEnd Property.


TXTextControl.FieldText Property
Description: Returns or sets the text which is contained within a marked text field. The field identifier must have previously been determined with the FieldCurrent property.
Syntax: TXTextControl.FieldText [= string]
Data Types: String.

Limitations: Run time only.


TXTextControl.FieldType Property
Description: This property sets or returns the type of a marked text field. The chapter Technical Articles - Marked Text Fields - Special Types of Marked Text Fields describes all the types and the data belonging to these types. Type-related data must be set with the FieldTypeData property.
Syntax: TXTextControl.FieldType(FieldId) [= FieldType]

Parameter | Description
FieldId | Identifies the field that is to be manipulated. Possible property values are listed in Constants.
Constants: The following lists the possible property values:

Constant | Description
txFieldStandard (0) | Resets a field of a special type to a standard marked text field.
txFieldExternalLink (1) | Defines the source of a hypertext link to a location outside of the document. The FieldTypeData property must be used to define where the link points to.
txInternalLink (2) | Defines the source of a hypertext link to a location in the same document.The FieldTypeData property must be used to define where the link points to. It must be the name of a marked text field that has the txFieldLinkTarget type.
txFieldPageNumber (3) | This field displays the current page number. It can only be used in headers or footers. The FieldTypeData property can be used to define the starting number and its format.
txFieldLinkTarget (4) | Defines a position in a document which is the target of a hypertext link. The FieldTypeData property must be used to define the name of this field.
txFieldHighlight (5) | Defines a piece of text that can be highlighted. The FieldTypeData property must be used to define the color of the highlight.
txFieldTopic (6) | Defines a position in a document that is the beginning of a topic. The FieldTypeData property must be used to define the number of the topic.
Remarks: The types txFieldLinkTarget, txFieldPageNumber and txFieldTopic can only be set when the marked text field has no text.
Data Types:
FieldId: | Integer
Property value: | Integer
Limitations: Run time only.

See also: FieldInsert Method, FieldTypeData Property, FieldLinkClicked Event.


TXTextControl.FieldTypeData Property
Description: This property sets or returns the data that belongs to a marked text field of a special type. The chapter Technical Articles - Marked Text Fields - Special Types of Marked Text Fields informs about all the types and the data belonging to these types.
Syntax: TXTextControl.FieldTypeData(FieldId) [= TypeData]

Parameter | Description
FieldId | Identifies the field that is to be manipulated. The specified data can be a long value or a character string depending on the type of the field. For the different field types the corresponding data are listed in the following Constants section.
Constants: The following lists the possible data for each type of field. The corresponding data type is listed in Data Types:

Constant Description
txFieldExternalLink (1) Defines the external location where the link points to.
txInternalLink (2) Defines the location in the same document where the link points to.
txFieldPageNumber (3) Defines the starting number and the number format. To display the number in a certain format the following constants can be added to the starting number:

Constant | Description
&H30000 | Pages are numbered with Arabic numbers (1, 2, 3, ...).
&H40000 | Pages are numbered with small letters (a, b, c, ...).
&H50000 | Pages are numbered with capital letters (A, B, C, ...).
&H60000 | Pages are numbered with Roman numbers (I, II, III, ...).
&H70000 | Pages are numbered with small Roman numbers (i, ii, iii, ...).
txFieldLinkTarget (4) Defines the name of a target.
txFieldHighlight (5) Defines the color of the highlight.
txFieldTopic (6) Defines the number of the topic.
Data Types:
FieldId: | Integer
txFieldExternalLink | String
txInternalLink | String
txFieldPageNumber | Long
txFieldLinkTarget | String
txFieldHighlight | Long
txFieldTopic | Long
Limitations: Run time only.

Example: The following example numbers pages with Roman numbers starting with number 3:
TXTextControl1.FieldTypeData(1) = 3 + &H60000
See also: FieldInsert Method, FieldLinkClicked Event.


TXTextControl.Find Method
Description: Searches the text in a Text Control for a given string.
Syntax: TXTextControl.Find FindWhat[, Start[, Options]]
Parameter Description
FindWhat Specifies the string to search for.
Start Optional. An integer character index that determines where to begin the search. The first character of text in the control has an index of 0. When this parameter is omitted or set to -1, the search begins at the current input position.
Options Optional. Is the sum of one or more constants used to specify optional features, as described in the following list:

Constant | Description
1 - SearchUp | Determines the direction of searches through a document. If this flag is used, the search direction is up; if the flag is not used, the search direction is down.
4 - MatchCase | Determines if a match is based on the case of the specified string as well as the text of the string.
8 - NoHighLight | Determines if a match appears highlighted in the Text Control.
16 - NoMessageBox | Suppresses the built-in message boxes which inform the user that a match could not be found.
Return Value: If the text searched for is found, the Find method highlights the specified text and returns the index (zero-based) of the first character highlighted. If the specified text is not found, the Find method returns -1.
Data Types:
FindWhat: | String
Start: | Long
Options: | Long
Return value: | Long
See also: FindReplace Method.


TXTextControl.FindReplace Method
Description: Displays a 'Find' or 'Replace' dialog box.
Syntax: TXTextControl.FindReplace TypeOfDialog

Parameter | Description
TypeOfDialog | If this parameter is set to 1 a 'Find' dialog box is displayed, if this parameter is set to 2, a 'Find and Replace' dialog box is displayed.
Return Value: This method has no return value.
Data Types:
TypeOfDialog Integer


TXTextControl.FontBold Property
Description: Returns or sets the bold font style. At design time the property determines the style of the complete text. At runtime the property gets or sets the style of the selected text if the FormatSelection property has been set to True. If the FormatSelection property has been set to False the style setting is made for the complete text.
Syntax: TXTextControl.FontBold [= value]

Setting | Description
0 | Resets the bold font style to normal or indicates that no character is formatted with the bold font style.
1 | Sets all characters to the bold font style or indicates that all characters are formatted with the bold font style.
2 | Indicates that the selection contains a mix of bold and not bold characters. This value is only possible at runtime and when the FormatSelection property has been set to True.
Data Types: Integer.

See also: FontName Property, FontSize Property, FontDialog Method, FormatSelection Property.


TXTextControl.FontDialog Method
Description: Invokes the Text Control's built-in font dialog box and, after the user has closed the dialog box, specifies whether he has changed something.
Syntax: TXTextControl.FontDialog
Return Value: The method returns True when the user has changed one or more attibutes. The method returns False when the formatting remains unchanged.
Remarks: The changes, made in the dialog box, apply to the currently selected text.
Data Types:
Return value: Boolean


TXTextControl.FontItalic Property
Description: Returns or sets the italic font style. At design time the property determines the style of the complete text. At runtime the property gets or sets the style of the selected text if the FormatSelection property has been set to True. If the FormatSelection property has been set to False the style setting is made for the complete text.
Syntax: TXTextControl.FontItalic [= value]

Setting | Description
0 | Resets the italic font style to normal or indicates that no character is formatted with the italic font style.
1 | Sets all characters to the italic font style or indicates that all characters are formatted with the italic font style.
2 | Indicates that the selection contains a mix of italic and not italic characters. This value is only possible at runtime and when the FormatSelection property has been set to True.
Data Types: Integer.

See also: FontName Property, FontSize Property, FontDialog Method, FormatSelection Property.


TXTextControl.FontName Property
Description: Returns or sets the font used to display text. At design time this property changes or gets the font name of the complete text. At runtime this property determines the font of the selected text when the FormatSelection property has been set to True. When the FormatSelection property has been set to False the font of the complete text is set or returned.
Syntax: TXTextControl.FontName [= string]
Remarks: The property returns an empty string if the selected text contains different fonts. This can happen only at runtime and when the FormatSelection property has been set to True.
Data Types: String.

See also: FontDialog Method, FormatSelection Property.


TXTextControl.FontSize Property
Description: Returns or sets a value that specifies the size of the font used to display text. This value is in points. At design time this property changes or gets the font size of the complete text. At runtime this property determines the font size of the selected text when the FormatSelection property has been set to True. When the FormatSelection property has been set to False the font size of the complete text is set or returned.
Syntax: TXTextControl.FontSize [= value]
Remarks: The property returns 0 if the selected text contains fonts with different sizes. This can happen only at runtime and when the FormatSelection property has been set to True.
Data Types: Integer.

See also: FontDialog Method, FormatSelection Property.


TXTextControl.FontStrikethru Property
Description: Returns or sets the strike thru font style. At design time the property determines the style of the complete text. At runtime the property gets or sets the style of the selected text if the FormatSelection property has been set to True. If the FormatSelection property has been set to False the style setting is made for the complete text.
Syntax: TXTextControl.FontStrikethru [= value]

Setting | Description
0 | Resets the strike thru font style to normal or indicates that no character is formatted with the strike thru font style.
1 | Sets all characters to the strike thru font style or indicates that all characters are formatted with the strike thru font style.
2 | Indicates that the selection contains a mix of characters that have or have not the strike thru font style. This value is only possible at runtime and when the FormatSelection property has been set to True.
Data Types: Integer.

See also: FontName Property, FontSize Property, FontDialog Method, FormatSelection Property.


TXTextControl.FontUnderline Property
Description: Returns or sets the underline font style. At design time the property determines the style of the complete text. At runtime the property gets or sets the style of the selected text if the FormatSelection property has been set to True. If the FormatSelection property has been set to False the style setting is made for the complete text.
Syntax: TXTextControl.FontUnderline [= value]

Setting | Description
0 | Resets the underline font style to normal or indicates that no character is formatted with the underline font style.
1 | Sets all characters to the underline font style or indicates that all characters are formatted with the underline font style.
2 | Indicates that the selection contains a mix of underlined nd not underlined characters. This value is only possible at runtime and when the FormatSelection property has been set to True.
Data Types: Integer.

See also: FontName Property, FontSize Property, FontDialog Method, FormatSelection Property.


TXTextControl.FontUnderlineStyle Property
Description: This property determines styles for the FontUnderline property.
Syntax: TXTextControl.FontUnderlineStyle [= value]

Setting | Description
&H1 | Underline style is single underlined.
&H2 | Underline style is double underlined.
&H4 | Underline style is words only underlined. This value is possible only in combination with single or double underlined.
&H10 | The text contains single underlined parts.
&H20 | The text contains double underlined parts.
&H40 | The text contains parts that are underlined words only.
Remarks: The first group of values describes the underline styles. The second group are additional values that are only useful for the property return value. They inform about complex selections and are possible only when the FormatSelection property has been set to True.
Data Types: Integer.

Limitations: Run time only.

See also: FontUnderline Property, FormatSelection Property.


TXTextControl.ForeColor Property
Description: Returns or sets the color used to display text in a Text Control. Text Control uses the Microsoft Windows operating enviroment red-green-blue (RGB) color scheme. At design time this property changes or gets the text color of the complete text. At runtime this property determines the color of the selected text when the FormatSelection property has been set to True. When the FormatSelection property has been set to False the text color of the complete text is set or returned.
Syntax: TXTextControl.ForeColor [= value]

Setting | Description
RGB colors | The valid range for a RGB color is 0 to &HFFFFFF. The high byte of a number in this range equals 0; the lower 3 bytes, from least to most significant byte, determine the amount of red, green, and blue, respectively. The red, green, and blue components are each represented by a number between 0 and 255 (&HFF).
System colors | Colors specified by the system color constants. If the high byte isn't 0, Text Control uses the system colors, as defined in the user's Control Panel settings.
Data Types: Long.

See also: FormatSelection Property, BackColor Property.


TXTextControl.FormatSelection Property
Description: Specifies whether character and paragraph formatting properties apply to the whole text or to a particular selection only.
Syntax: TXTextControl.FormatSelection [= boolean]

Setting | Description
True | The formatting properties only apply to selected text. This mode works only at run time, because at design time it is not possible to select text.
False | (Default) The formatting properties apply to the complete text.
Remarks: The properties which are affected are Alignment, BaseLine, FontBold, FontItalic, FontName, FontSize, FontStrikethru, FontUnderline, FontUnderlineStyle, LineSpacing, LineSpacingT, ForeColor, TextBkColor.

Data Types: Boolean.


TXTextControl.FrameDistance Property
Description: Returns or sets the distance between text and paragraph frame for the currently selected paragraph(s).
Syntax: TXTextControl.FrameDistance [= value]
Remarks: The property returns -1 if the user selects two or more paragraphs which have different frame distance settings.
Data Types: Integer.

Limitations: Run time only.


TXTextControl.FrameLineWidth Property
Description: Specifies the line widths of the currently selected paragraphs' frames.
Syntax: TXTextControl.FrameLineWidth [= value]
Remarks: The property returns 0 if the user selects two or more paragraphs which have different line width settings.
Data Types: Integer.

Limitations: Run time only.


TXTextControl.FrameStyle Property
Description: Returns or sets the style of the currently selected paragraphs' frames.
Syntax: TXTextControl.FrameStyle [= value]

Setting | Description
&H1 | Draws a left frame line.
&H2 | Draws a right frame line.
&H4 | Draws a top frame line.
&H8 | Draws a bottom frame line.
&H10 | Draws a vertical line at each tab position.
&H20 | Draws a single line.
&H40 | Draws a doubled line.
&H80 | Connects two sequential boxes to form a single box.
&H100 | Resets an existing left line.
&H200 | Resets an existing right line.
&H400 | Resets an existing top line.
&H800 | Resets an existing bottom line.
&H1000 | Resets existing tabulator lines.
Remarks: The property returns -1 if the user selects two or more paragraphs which have different frame style settings.
Data Types: Integer.

Limitations: Run time only.


TXTextControl.GetBaseLinePos Method
Description: Returns the baseline position of the specified line. The dimensions are given in twips with an origin at the upper left corner of the text. The relationship between the upper left corner of the text and the upper left corner of the control can be obtained with the ScrollPosY property.
Syntax: TXTextControl.GetBaseLinePos Line

Parameter | Description
Line | Specifies the index of the line whose baseline position is returned. The index of the first line is zero.
Return Value: The method returns the requested baseline position in twips. It is zero if an error has occurred or if the specified line does not exist.
Data Types:
Line: | Long
Return value: | Long
See also: ScrollPosY Property, GetLineRect Method.


TXTextControl.GetCharFromLine Method
Description: Returns the position of a line's first character. The first character's position is the number of characters from the beginning of the text to the beginning of the specified line. The first character's position of the first line is zero.
Syntax: TXTextControl.GetCharFromLine Line

Parameter | Description
Line | Specifies the index of the line whose character position is returned. The index of the first line is zero.
Return Value: The method returns the requested character position. It is -1 if an error has occurred or if the specified line does not exist.
Data Types:
Line: | Long
Return value: | Long
See also: GetLineCount Method, GetLineFromChar Method.


TXTextControl.GetLineCount Method
Description: Returns the number of text lines in a Text Control.
Syntax: TXTextControl.GetLineCount
Return Value: The method returns the number of text lines.
Data Types:
Return value: Long

See also: GetLineFromChar Method, GetLineFromPoint Method.


TXTextControl.GetLineFromChar Method
Description: Returns the index of the line which contains the character with the specified character position.
Syntax: TXTextControl.GetLineFromChar Char

Parameter | Description
Char | Specifies the position of the character whose line index is returned. The position of the first character is zero.
Return Value: The method returns a line index, starting with 0 for the first line. The return value is -1 if an error has occurred or if the specified character position does not exist.
Data Types:
Char: | Long
Return value: | Long
See also: GetLineCount Method, GetCharFromLine Method, GetLineFromPoint Method.


TXTextControl.GetLineFromPoint Method
Description: Returns the index of the line which contains a given point. The point must be specified in pixels from the top left corner of the control.
Syntax: TXTextControl.GetLineFromPoint X, Y

Parameter | Description
X, Y | Specifies a geometric position in pixels.
Return Value: The method returns a line index, starting with 0 for the first line. The return value is -1 if an error has occurred.
Data Types:
X, Y: | Long
Return value: | Long
See also: GetLineCount Method, GetLineFromChar Method.


TXTextControl.GetLineRect Method
Description: Returns the rectangular area covered by a line of text. The rectangle does not include the external leading area, additional linespacing or paragraph indents. The dimensions are given in twips with an origin at the upper left corner of the Text Control's complete text. The relationship between the upper left corner of the complete text and the upper left corner of the control can be obtained with the ScrollPosY property.
Syntax: TXTextControl.GetLineRect Line

Parameter | Description
Line | Specifies the index of the line which rectangle is returned. The index of the first line is zero.
Return Value: The method returns an array of 4 long values specifying the left, top, right and bottom border of the requested rectangle in twips.
Data Types:
Line: | Long
Return value: | Array of 4 Long
See also: ScrollPosY Property, GetBaseLinePos Method.


TXTextControl.GetTextExtent Method
Description: Returns the extension of the complete text in twips. The text width is the largest line width of the currently contained text. Both values are in 100 percent independent of the zoom factor currently set. The text height is at least the height of the first line even if there is no text.
Syntax: TXTextControl.GetTextExtent
Return Value: The method returns an array of 2 long values specifying the width and the height of the text.
Data Types:
Return value: Array of 2 Long


TXTextControl.HeaderFooter Property
Description: This property determines which kind of headers and/or footers the document contains. It can only be used if the ViewMode property has been set to Page View or Centered Page View. Using this property, a header or footer is not automatically activated. The HeaderFooterActivate method or the built-in mouse interface can be used to activate a header or footer.
Syntax: TXTextControl.HeaderFooter [= HeadersFooters]

Setting | Description
txHeader (1) | Inserts a header.
txFirstHeader (2) | Inserts a special header for the first page.
txFooter (4) | Inserts a footer.
txFirstFooter (8) | Inserts a special footer for the first page.
Remarks: The property value can be the sum of one or more of the specified settings.
Data Types: Integer.

Limitations: Run time only.

See also: HeaderFooterActivate Method, HeaderFooterStyle Property.


TXTextControl.HeaderFooterActivate Method
Description: Activates or deactivates a header or a footer. During activation the current input focus is set to the header or footer area, so that the user can alter the text and/or the format. During deactivation the input focus is set back to the main text.
Syntax: TXTextControl.HeaderFooterActivate HeaderFooter

Parameter | Description
HeaderFooter | Specifies the header or footer to activate. Valid values are described in Constants.
Return Value: The method returns True, if a header or footer could be activated, otherwise it returns False.
Constants: Valid values for the HeaderFooter parameter are:

Constant | Description
0 | a currently activated header or footer is deactivated.
txHeader (1) | Activates the header.
txFirstHeader (2) | Activates the special header of the first page.
txFooter (4) | Activates the footer.
txFirstFooter (8) | Activates the special footer of the first page.
Data Types:
HeaderFooter: | Integer
Return value: | Boolean


TXTextControl.HeaderFooterActivated Event
Description: Occurs when a header or footer has been activated.
Syntax: HeaderFooterActivated(HeaderFooter)

Parameter | Description
HeaderFooter | Specifies the header or footer that has been activated. Valid values are listed in Constants.
Constants: Valid values for the HeaderFooter parameter are:

Constant | Description
txHeader (1) | A header has been activated.
txFirstHeader (2) | The special header for the first page has been activated.
txFooter (4) | A footer has been activated.
txFirstFooter (8) | The special footer for the first page has been activated.
Data Types:
HeaderFooter: Integer

See also: HeaderFooterDeactivated Event.


TXTextControl.HeaderFooterAtInputPos Property
Description: Returns which header or footer owns the current text input position. To own the current text input position a header or footer must be activated. Even if a header or footer looses the current input focus to another program, it remains activated and owns the current text input positon furthermore.
Syntax: TXTextControl.HeaderFooterAtInputPos

Setting | Description
txHeader (1) | The header owns the text input position.
txFirstHeader (2) | The special header for the first page owns the text input position.
txFooter (4) | The footer owns the text input position.
txFirstFooter (8) | The special footer for the first page owns the text input position.
txMainText (16) | The main text owns the text input position.
Data Types: Integer.
Limitations: Read only, run time only.
Introduced: 12.0
See also: TableAtInputPos Property, FieldAtInputPos Property.


TXTextControl.HeaderFooterDeactivated Event
Description: Occurs when a header or footer has been deactivated.
Syntax: HeaderFooterDeactivated(HeaderFooter)

Parameter | Description
HeaderFooter | Specifies the header or footer that has been deactivated. Valid values are listed in Constants.
Constants: Valid values for the HeaderFooter parameter are:

Constant | Description
txHeader (1) | A header has been deactivated.
txFirstHeader (2) | The special header for the first page has been deactivated.
txFooter (4) | A footer has been deactivated.
txFirstFooter (8) | The special footer for the first page has been deactivated.
Data Types:
HeaderFooter: Integer

See also: HeaderFooterActivated Event.


TXTextControl.HeaderFooterPosition Property
Description: This property specifies the position of a header or footer. For headers the position value is the distance between the top of the header and the top of the page. For footers the position value is the distance between the bottom of the footer and the bottom of the page. All values are in twips. The default value is 567 twips = 1 cm.
Syntax: TXTextControl.HeaderFooterPosition(HeaderFooter) [= position]

Parameter | Description
HeaderFooter | Specifies the header or footer the position of which is to be set. Valid values are listed in Constants.
Constants: Valid values for the HeaderFooter parameter are:

Constant | Description
txHeader (1) | Specifies the header.
txFirstHeader (2) | Specifies the special header for the first page.
txFooter (4) | Specifies the footer.
txFirstFooter (8) | Specifies the special footer for the first page.
Data Types: Long.

Limitations: Run time only.


TXTextControl.HeaderFooterSelect Method
Description: This method determines whether a certain Text Control property or method manipulates a header or a footer or the main text. This method does not activate a header or footer.
Syntax: TXTextControl.HeaderFooterSelect HeaderFooter

Parameter | Description
HeaderFooter | Specifies the part of the text that is to be selected. See the Constants section for valid values.
Return Value: The method returns True, if a header or footer could be selected, otherwise it returns False.
Constants: Valid values for the HeaderFooter parameter are:

Constant | Description
0 | Text Control performs automatic selection, which means that a certain property or method manipulates the text part with the current input position.
txHeader (1) | Selects the header.
txFirstHeader (2) | Selects the special header for the first page.
txFooter (4) | Selects the footer.
txFirstFooter (8) | Selects the special footer for the first page.
txMainText (16) | Selects the main text.
Data Types:
HeaderFooter: | Integer
Return value: | Boolean
Example: This Basic example selects the header, alters the text of the header and returns to the automatic mode:
TXTextControl1.HeaderFooterSelect txHeader
TXTextControl1.Text = "This is the header's text"
TXTextControl1.HeaderFooterSelect 0


TXTextControl.HeaderFooterStyle Property
Description: This property determines how headers and footers can be activated and how activated headers and footers appear on the screen.
Syntax: TXTextControl.HeaderFooterStyle [= style]

Setting | Description
txMouseClick (1) | Headers and footers can be activated through single mouse clicks.
txNoDblClk (2) | Headers and footers cannot be activated through mouse double-clicks.
txSolidFrame (4) | An activated header or footer has a solid border to indicate its size.
txUnframed (8) | An activated header or footer has no border.
Remarks: The property value can be the sum of one or more of the specified settings. The default style setting is a dotted border for an activated header or footer and a mouse interface that activates a header or footer with double-clicks.
Data Types: Integer.

Limitations: Run time only.


TXTextControl.HExpand Event
Description: Occurs when the Text Control has changed its window size horizontally. This event can only occur when the AutoExpand property is set to True.
Syntax: HExpand( )
See also: AutoExpand Property, VExpand Event.


TXTextControl.HideSelection Property
Description: Specifies whether a text selection is hidden when the Text Control looses the input focus.
Syntax: TXTextControl.HideSelection [= boolean]

Setting | Description
True | (Default) The selection is hidden when the Text Control looses the input focus and shown when the Text Control gets the input focus.
False | The selection stays visible, independent of the current input focus.
Data Types: Boolean.


TXTextControl.HScroll Event
Description: Occurs when the horizontal scroll position has been changed. This event cannot occur, if the ViewMode property has been set to Simple Control.
Syntax: HScroll( )
See also: VScroll Event.


TXTextControl.hWnd Property
Description: Returns a handle to a Text Control.
Syntax: TXTextControl.hWnd
Remarks: The hWnd property is used with Windows API calls. Many Windows operating enviroment functions require the hWnd of the active window as an argument.
Data Types: Handle.

Limitations: Read only, run time only.


TXTextControl.ImageDisplayMode Property
Description: Provides several modes to set the way in which images are displayed or refreshed. The ObjectCurrent property determines the image.
Syntax: TXTextControl.ImageDisplayMode [= value]

Setting | Description
0 | (Default) Standard mode.
&H1 | Displays an image as a gray rectangle.
&H2 | Container mode. This mode ensures proper refreshing when the image is used as a background image for transparent controls.
Remarks: The property settings can be combined by adding the desired constant values.
Data Types: Integer.

Limitations: Run time only.
See also: ImageInsert Method, ImageInsertAsChar Method, ImageInsertFixed Method.


TXTextControl.ImageExportCompressionQuality Property
Description: Determines a value between 1 and 100, which is the quality of a lossy data compression used, if the image is saved. It is only used, if the image data is compressed with a lossy compression algorithm. A value of 100 indicates the maximum quality, a value of 1 indicates the minimum quality. If this property is set to zero, which is the default value, TX Text Control uses the quality value set with the LoadSaveAttribute property (txImageCompressionQuality value) or a compression specific default value. The ObjectCurrent property determines the image.
Syntax: TXTextControl.ImageExportCompressionQuality [= value]
Data Types: Integer.

Limitations: Run time only.
Introduced: 11.0
See also: ObjectCurrent Property.


TXTextControl.ImageExportFilename Property
Description: Determines the file name of an image used if a document is saved. The ObjectCurrent property determines the image.
Syntax: TXTextControl.ImageExportFilename [= string]
Data Types: String.

Limitations: Run time only.

See also: ObjectCurrent Property, ImageExportFormat Property.


TXTextControl.ImageExportFilters Property
Description: This property returns a string which specifies the available filters for exporting images. The filter names are read from the tx12_ic.ini file and the names are separated through a '|' sign. It can be used to initialize the Filter property of a Common Dialog Control.
Syntax: TXTextControl.ImageExportFilters
Data Types: String.

Limitations: Read only, run time only.

See also: ImageFilters Property.


TXTextControl.ImageExportFormat Property
Description: Determines the format used if an image is saved. This is the number of the filter in the string returned through the ImageExportFilters property, beginning with number one. If the ImageExportFilters property is used to initialize the Filter property of a Common Dialog Control, the FilterIndex property of the Common Dialog Control can be used to set this property. The ObjectCurrent property determines the image.
Syntax: TXTextControl.ImageExportFormat [= index]
Data Types: Integer.

Limitations: Run time only.

See also: ObjectCurrent Property.


TXTextControl.ImageExportMaxResolution Property
Description: Determines the maximum resolution in dots per inch used, if the image is saved. If the image's resolution is larger than this property's value, it is reduced, otherwise it is not changed. If this property's value is zero, which is the default value, TX Text Control uses the maximum resolution set with the LoadSaveAttribute property (txImageMaxResolution value) or the image's default resolution. The ObjectCurrent property determines the image.
Syntax: TXTextControl.ImageExportMaxResolution [= value]
Data Types: Integer.

Limitations: Run time only.

Introduced: 11.0
See also: ObjectCurrent Property.


TXTextControl.ImageFilename Property
Description: Determines the image file name of an inserted image. The ObjectCurrent property determines the image.
Syntax: TXTextControl.ImageFilename [= string]
Data Types: String.

Limitations: Run time only.

See also: ObjectCurrent Property, ImageInsert Method, ImageInsertAsChar Method, ImageInsertFixed Method.


TXTextControl.ImageFilters Property
Description: This property returns a string which specifies the available image filters. This string can be used to initialize the Filter property of a Common Dialog control.
Syntax: TXTextControl.ImageFilters
Remarks: The filter names are read from the tx12_ic.ini file. Filters for JPEG, PNG, TIFF, Bitmap and Windows Metafiles are supplied.
Data Types: String.

Limitations: Read only, run time only.

Example: This Basic example initializes an OpenFile dialog box with the names of the available image filters and then loads a selected image:
dlgFile.DialogTitle = "Insert Image"
dlgFile.Filename = ""
dlgFile.Filter = TXTextControl1.ImageFilters
dlgFile.FilterIndex = 1
dlgFile.Flags = cdlOFNPathMustExist Or cdlOFNFileMustExist _
   Or cdlOFNHideReadOnly
dlgFile.CancelError = True
dlgFile.ShowOpen
TXTextControl1.ImageInsertAsChar dlgFile.Filename, -1, 100, 100
See also: ImageExportFilters Property.


TXTextControl.ImageInsert Method
Description: This method inserts a new image anchored to a paragraph. The text flows around the image.
Syntax: TXTextControl.ImageInsert FileName, TextPos, Alignment, PosX, PosY, ScaleX, ScaleY, TextFlow, DistanceL, DistanceT, DistanceR, DistanceB
Parameter Description
FileName Specifies the image file with a full path name.
TextPos Specifies a text position in the paragraph where the image should be inserted. If TextPos is -1, the image is anchored to the paragraph at the current input position.
Alignment Specifies the image's horizontal alignment. It can be one of the following values:

Value | Description
0 | The horizontal position is given through the PosX parameter.
1 | The image is left aligned relative to the paragraph to which it is anchored.
2 | The image is right aligned relative to the paragraph to which it is anchored.
3 | The image is centered relative to the paragraph to which it is anchored.
PosX Specifies the image's horizontal position in twips, relative to the left border of the paragraph. This value is used if the Alignment parameter has been set to 0.
PosY Specifies the image's vertical position in twips relative to the top border of the paragraph.
ScaleX Specifies a horizontal scaling factor as a percentage.
ScaleY Specifies a vertical scaling factor as a percentage.
TextFlow Specifies how text flows around the image. It can be one of the following values:

Value | Description
2 | The text stops at the top and continues at the bottom of the image.
3 | The text flows around the image. Empty areas at the left and right side are filled.
DistanceL, DistanceT, DistanceR, DistanceB Specifies distances, in twips, between the image and the document's text.
Return Value: The method returns the image's identifier, if a new image could be inserted. Otherwise, it returns zero. The image's identifier can also be obtained with the ObjectCurrent property.

Data Types:
FileName: | String
TextPos: | Long
Alignment: | Integer
PosX: | Long
PosY: | Long
ScaleX: | Integer
ScaleY: | Integer
TextFlow: | Integer
DistanceL: | Integer
DistanceT: | Integer
DistanceR: | Integer
DistanceB: | Integer
Return value: | Integer
Introduced: 12.0
See also: ImageInsertAsChar Method, ImageInsertFixed Method, Object and image attribute properties.


TXTextControl.ImageInsertAsChar Method
Description: This method inserts a new image which is then handled like a single character in the text.
Syntax: TXTextControl.ImageInsertAsChar FileName, TextPos, ScaleX, ScaleY

Parameter | Description
FileName | Specifies the image file with a full path name.
TextPos | Specifies a text position where the image should be inserted. If TextPos is -1, the image is inserted at the current input position.
ScaleX | Specifies a horizontal scaling factor as a percentage.
ScaleY | Specifies a vertical scaling factor as a percentage.
Return Value: The method returns the image's identifier, if a new image could be inserted. Otherwise, it returns zero. The image's identifier can also be obtained with the ObjectCurrent property.

Data Types:
FileName: | String
TextPos: | Long
ScaleX: | Integer
ScaleY: | Integer
Return value: | Integer
Introduced: 12.0
See also: ImageInsert Method, ImageInsertFixed Method, Object and image attribute properties.


TXTextControl.ImageInsertFixed Method
Description: This method inserts a new image at a fixed geometrical position. The text flows around the image.
Syntax: TXTextControl.ImageInsertFixed FileName, PageNo, PosX, PosY, ScaleX, ScaleY, TextFlow, DistanceL, DistanceT, DistanceR, DistanceB
Parameter Description
FileName Specifies the image file with a full path name.
PageNo Specifies the number of the page where the image is inserted, beginning with number 1. If the ViewMode property has not been set to Page View or Centered Page View, this parameter must be set to zero. In this case the PosY parameter specifies the position relative to the top of the control.
PosX Specifies the image's horizontal position in twips relative to the left border of the page.
PosY Specifies the image's vertical position in twips relative to the top border of the page or control.
ScaleX Specifies a horizontal scaling factor as a percentage.
ScaleY Specifies a vertical scaling factor as a percentage.
TextFlow Specifies how text flows around the image. It can be one of the following values:

Value | Description
2 | The text stops at the top and continues at the bottom of the image.
3 | The text flows around the image. Empty areas at the left and right side are filled.
DistanceL, DistanceT, DistanceR, DistanceB Specifies distances, in twips, between the image and the document's text.
Return Value: The method returns the image's identifier, if a new image could be inserted. Otherwise, it returns zero. The image's identifier can also be obtained with the ObjectCurrent property.

Data Types:
FileName: | String
PageNo: | Long
PosX: | Long
PosY: | Long
ScaleX: | Integer
ScaleY: | Integer
TextFlow: | Integer
DistanceL: | Integer
DistanceT: | Integer
DistanceR: | Integer
DistanceB: | Integer
Return value: | Integer
Introduced: 12.0
See also: ImageInsertAsChar Method, ImageInsert Method, Object and image attribute properties.


TXTextControl.ImageSaveMode Property
Description: When saving a document using the Save method, this property determines whether the image data or the image file name is stored. The ObjectCurrent property determines the image.
Syntax: TXTextControl.ImageSaveMode [= value]

Setting | Description
0 | Saves the image's file name.
1 | (Default) Saves the image's data.
Data Types: Integer.

Limitations: Run time only.

See also: Save Method.


TXTextControl.IndentB Property
Description: Returns or sets an additional bottom distance (in twips) for a paragraph or a selected range of paragraphs.
Syntax: TXTextControl.IndentB [= value]
Remarks: If a number of paragraphs have been selected which have different settings for the bottom distance, the property returns &H8000.
Data Types: Integer.


TXTextControl.IndentFL Property
Description: Returns or sets an additional left indent (in twips) for the first line of a paragraph or a selected range of paragraphs. This value can be negative.
Syntax: TXTextControl.IndentFL [= value]
Remarks: If a number of paragraphs have been selected which have different settings for the first line indent, the property returns &H8000.
Data Types: Integer.


TXTextControl.IndentL Property
Description: Returns or sets the left indent (in twips) for a paragraph or a selected range of paragraphs.
Syntax: TXTextControl.IndentL [= value]
Remarks: If a number of paragraphs have been selected which have different settings for the left indent, the property returns &H8000.
Data Types: Integer.


TXTextControl.IndentR Property
Description: Returns or sets the right indent (in twips) for a paragraph or a selected range of paragraphs.
Syntax: TXTextControl.IndentR [= value]
Remarks: If a number of paragraphs have been selected which have different settings for the right indent, the property returns &H8000.
Data Types: Integer.


TXTextControl.IndentT Property
Description: Returns or sets an additional top distance (in twips) for a paragraph or a selected range of paragraphs.
Syntax: TXTextControl.IndentT [= value]
Remarks: If a number of paragraphs have been selected which have different settings for the top distance, the property returns &H8000.
Data Types: Integer.


TXTextControl.InputPosFromPoint Method
Description: Returns the text input position belonging to a certain geometric position. The text input position is relative to the beginning of the text and the geometric position is a position in the visible part of the text.
Syntax: TXTextControl.InputPosFromPoint X, Y

Parameter | Description
X, Y | Specify the coordinates of the point. These values must be in twips.
Return Value: The method returns the text input position beginning with zero for the position in front of the first character. The method returns -1, if a text position could not be found.
Data Types:
X, Y: | Long
Return value: | Long


TXTextControl.InsertionMode Property
Description: Specifies whether text is inserted or overwrites existing text.
Syntax: TXTextControl.InsertionMode [= boolean]

Setting | Description
True | (Default) New text is inserted.
False | New text overwrites existing text.
Data Types: Boolean.


TXTextControl.KeyDown Event
Description: Occurs when the user presses a key while the Text Control has the input focus. To interpret ANSI characters, use the KeyPress event.
Syntax: KeyDown(KeyCode, Shift)
Parameter Description
KeyCode Is the virtual-key code of the pressed key. When this value is changed, Text Control handles the changed key.
Shift Informs about the state of the SHIFT, CTRL and ALT keys at the time of the event. It is the sum of one or more of the following values:

Value | Description
1 | The SHIFT key was pressed at the time of the event.
2 | The CTRL key was pressed at the time of the event.
4 | The ALT key was pressed at the time of the event.
Data Types:
KeyCode: | Integer
Shift: | Integer
See also: KeyPress Event, KeyUp Event.


TXTextControl.KeyPress Event
Description: Occurs when the user presses and releases an ANSI key while the Text Control has the input focus.
Syntax: KeyPress(KeyAscii)

Parameter | Description
KeyAscii | Is a standard numeric ANSI keycode. Changing it sends a different character to the Text Control.
Data Types:
KeyAscii: Integer

See also: KeyDown Event, KeyUp Event.


TXTextControl.KeyStateChange Event
Description: Occurs when the character insertion mode or when the state of the NUMLOCK or CAPSLOCK key has been changed.
Syntax: KeyStateChange( )


TXTextControl.KeyUp Event
Description: Occurs when the user releases a key while the Text Control has the input focus. To interpret ANSI characters, use the KeyPress event.
Syntax: KeyUp(KeyCode, Shift)
Parameter Description
KeyCode Is the virtual-key code of the released key. When this value is changed, Text Control handles the changed key.
Shift Informs about the state of the SHIFT, CTRL and ALT keys at the time of the event. It is the sum of one or more of the following values:

Value | Description
1 | The SHIFT key was pressed at the time of the event.
2 | The CTRL key was pressed at the time of the event.
4 | The ALT key was pressed at the time of the event.
Data Types:
KeyCode: | Integer
Shift: | Integer
See also: KeyDown Event, KeyPress Event.


TXTextControl.Language Property
Description: Determines the language in which Text Control displays dialog boxes and error messages. Text Control has several built-in languages, additional languages can be added with the ResourceFile property. The default language is the Windows system language. See Technical Articles - Resources for more information.

Syntax: TXTextControl.Language [= value]

Setting | Description
33 | French
34 | Spanish
39 | Italian
41 | German (Switzerland)
43 | German (Austria)
49 | German
else | English
Data Types: Integer.


TXTextControl.LineSpacing Property
Description: Specifies the line spacing for the currently selected paragraphs as a percentage of the font size.
Syntax: TXTextControl.LineSpacing [= value]
Data Types: Integer.

See also: FormatSelection Property.


TXTextControl.LineSpacingT Property
Description: Specifies the line spacing for the currently selected paragraphs in twips.
Syntax: TXTextControl.LineSpacingT [= value]
Data Types: Integer.

See also: FormatSelection Property.


TXTextControl.ListAttrDialog Method
Description: Invokes the Text Control's built-in dialog box for setting attributes of bulleted and numbered lists.
Syntax: TXTextControl.ListAttrDialog
Return Value: The method returns True when the user has changed one or more attributes. The method returns False when nothing has been changed.
Remarks: The changes, made in the dialog box, apply to the currently selected text.
Data Types:
Return value: Boolean


TXTextControl.ListType Property
Description: Returns or sets a list type for a paragraph or a selected range of paragraphs. Possible lists are bulleted and numbered lists. Attributes for bulleted lists can be set with the BulletAttribute property and attributes for numbered lists can be set with the NumberingAttribute property.
Syntax: TXTextControl.ListType [= Type]

Setting | Description
txListNone (1) | Resets paragraphs with bulleted or numbered list attributes to paragraphs without such features.
txListBulleted (2) | Defines a list with bullets.
txListNumbered (4) | Defines a numbered list.
Remarks: If several paragraphs belonging to different lists are selected the property returns a combination of the constants listed above.
Data Types: Integer.

Limitations: Run time only.

See also: BulletAttribute Property, ListAttrDialog Method, NumberingAttribute Property.


TXTextControl.Load Method
Description: Loads text in a certain format from a file and inserts it into the Text Control.
Syntax: TXTextControl.Load FileName[, Offset[, Format[, CurSelection]]]
Parameter Description
FileName Specifies the file to load from.
Offset Optional. Specifies the file position from where the data is read. When not specified or set to zero the data is read from the beginning.
Format Optional. Specifies a format identifier. When not specified Text Control assumes Text Control's internal format (3). Otherwise it can be one of the following values:

Constant | Description
1 - ANSI text | Text in Windows ANSI format (an end of a paragraph is marked with the control characters 13 and 10).
2 - TX text | Text in ANSI format (an end of a paragraph is marked only with the control character 10).
3 - TX | Text including formatting attributes in the internal Text Control format. Text is stored in ANSI.
4 - HTML | HTML format (Hypertext Markup Language).
5 - RTF | RTF format (Rich Text Format).
6 - Unicode text | Text in Windows Unicode format (an end of a paragraph is marked with the control characters 13 and 10).
7 - TX text | Text in Unicode format (an end of a paragraph is marked only with the control character 10).
8 - TX | Text including formatting attributes in the internal Text Control format. Text is stored in Unicode.
9 - Microsoft Word | Microsoft Word format.
10 - XML | XML format (Extensible Markup Language).
11 - CSS | CSS format (Cascading Style Sheet).
CurSelection Optional. When set to true the loaded data replaces the current selection or is inserted at the current input position. The new input position is behind the inserted data. When omitted or set to false the loaded data replaces the complete control contents independent of the current selection. The new input position is at the beginning of the data.
Return Value: The method returns the position in the file after the data has been loaded.
Data Types:
FileName: | String
Offset: | Long
Format: | Integer
CurSelection: | Boolean
Return value: | Long
Example: This Basic example opens a file and loads its contents into TXTextControl1:
Private Sub mnuFile_Load_Click()
   On Error Resume Next
   ' Create an "Open File" dialog box
   CommonDialog1.Filter = "TX Demo (*.tx)|*.tx"
   CommonDialog1.DialogTitle = "Open"
   CommonDialog1.Flags = cdlOFNFileMustExist Or _
      cdlOFNHideReadOnly
   CommonDialog1.CancelError = True
   CommonDialog1.ShowOpen
   If Err Then Exit Sub
   ' Pass the filename to the text control
   TXTextControl1.Load CommonDialog1.filename
End Sub
See also: Save Method.


TXTextControl.LoadFromMemory Method
Description: Loads text in a certain format from a buffer and inserts it into the Text Control.
Syntax: TXTextControl.LoadFromMemory DataArray[, Format[, CurSelection]]

Parameter | Description
DataArray | Specifies the byte array to load from.
Format | Optional. Specifies a format identifier. When not specified Text Control assumes Text Control's internal format (3). See the Format parameter of the Load method for possible format identifiers.
CurSelection | Optional. When set to true the loaded data replaces the current selection or is inserted at the current input position. The new input position is behind the inserted data. When omitted or set to false the loaded data replaces the complete control contents independent of the current selection. The new input position is at the beginning of the data.
Return Value: The method returns True if the data could be loaded, otherwise it returns False.
Data Types:
DataArray: | One-dimensional Byte Array
Format: | Integer
CurSelection: | Boolean
Return value: | Boolean
See also: Load Method, SaveToMemory Method.


TXTextControl.LoadSaveAttribute Property
Description: This property enables an application to specify several attributes that can be used in combination with the Load and Save methods for the following situations: 1. Documents can contain elements, for example a document title, that cannot be converted directly to text properties but may be useful for certain applications. Such an attribute can be set before a document is saved, in order to store it as part of the document, or it can be provided and used after a document has been loaded. 2. In some documents generic information about text properties is left out, for example with HTML documents which define font heights as a percentage of a base height without specifying that base height. Such an attribute can be set before a document is loaded, in order to inform the filter how to calculate such relative values.
Syntax: TXTextControl.LoadSaveAttribute(Attribute) [= value]

Parameter | Description
Attribute | Determines the attribute that is to be changed or returned. Possible values are listed in Constants.
Constants: Valid values for the Attribute parameter are:

Constant Description
txDocWidth (0) Loads or saves a document width in twips. When this property is set before a document is loaded, it is used to calculate width values contained in the document which are relative to the document's width. After a document has been loaded, this property returns the width, contained in the document, or -1 if the document does not contain a width. When a document is saved and this property has not been set, Text Control saves the value of the PageWidth property instead, except this property has been set to -1 previously.
txDocHeight (1) Loads or saves a document height in twips. It is used in the same manner as described for the txDocWidth attribute.
txDocLeftMargin (2) Loads or saves a left document margin in twentieths of a point. After a document has been loaded, this property returns the margin contained in the document, or -1 if the document does not contain the margin. When a document is saved and this property has not been set, Text Control saves the value of the PageMarginL property instead, except this property has been set to -1 previously.
txDocTopMargin (3) Loads or saves a top document margin in twentieths of a point. It is used in the same manner as described for the txDocLeftMargin attribute.
txDocRightMargin (4) Loads or saves a right document margin in twentieths of a point. It is used in the same manner as described for the txDocLeftMargin attribute.
txDocBottomMargin (5) Loads or saves a bottom document margin in twentieths of a point. It is used in the same manner as described for the txDocLeftMargin attribute.
txDocTitle (6) Loads or saves a document title. After a document has been loaded, this property returns the document title contained in the document, or an empty string if the document does not contain a title.
txDocBkColor (7) Loads or saves a document background color as a RGB value. After a document has been loaded, this property returns the background color contained in the document, or -1, if the document does not contain a background color.
txCSSFile (8) HTML only. Specifies a full or relative path and filename for a CSS file. This file is only used if txCSSSaveMode determines that stylesheet data is saved in a file.
txCSSSaveMode (9) HTML only. Determines how to save stylesheets in HTML format. It can be one of the following values:

Code | Meaning
0 - Without Stylesheets | All format information is saved in the body of the HTML document.
1 - Inline | Stylesheets are saved in the head of the HTML document.
2 - Create File | Stylesheets are saved in a newly created CSS file. This file has the same name and location as the corresponding HTML file or is specified through the txCSSFile attribute. The file is only created if it does not exist. If the HTML document is saved in a memory buffer this setting cannot be used.
3 - Overwrite File | Stylesheets are saved in a newly created CSS file. This file has the same name and location as the corresponding HTML file or is specified through the txCSSFile attribute. If the file already exists, it is overridden. If the HTML document is saved in a memory buffer, this setting cannot be used.
txDocAccessPermissions (10) PDF only. Specifies how a document can be accessed after it has been opened. This property has only an effect, if also a password has been specified with the txMasterPassword setting. If no password has been specified, the document can be accessed without any restrictions. The settings value can be a bitwise combination of more than one of the following values.

Code | Meaning
&H1 | Allows authoring comments and fill in interactive form fields (including signature fields).
&H2 | Fill-in existing interactive form fields (including signature fields) is allowed.
&H4 | Allows content access for the visually impaired only.
&H8 | Allows assembly of the the document (insert, rotate or delete pages and create bookmarks or thumbnails).
&H10 | Copying or otherwise extracting text and/or graphics is allowed.
&H20 | Allows modifying the document's contents.
&H40 | Printing the document is fully allowed.
&H80 | Printing the document is allowed (low-level).
txMasterPassword (11) PDF only. Specifies the password for the document's access permissions. If the password is an empty string, accessing the document is not restricted. If a password is specified, the access permissions are given through the txDocAccessPermissions setting.
txUserPassword (12) PDF only. Specifies the password for the user to open the document. If the password is an empty string, the document can be opened by every user.
txImageCompressionQuality (13) Sets a value between 1 and 100, which is the quality of a lossy image compression used when a document is saved. It is used for all images in the document the data of which is compressed with a lossy compression algorithm. A value of 100 indicates the maximum quality, a value of 1 indicates the minimum quality. A value of zero selects a compression specific default value. For a single image the value of this property can be overwritten using the ImageExportCompressionQuality property.
txImageMaxResolution (14) Sets the maximum resolution for all images in the document in dots per inch when the document is saved. If an image's resolution is larger than this property's value, it is reduced, otherwise it is not changed. If this property's value is zero, which is the default value, the default resolution of each image is used. For a single image the value of this property can be overwritten using the ImageExportMaxResolution property
txAbsPath (28) Specifies a character string that is used to search for resources like images or destinations of hypertext links. When a document is loaded, this path is used to locate a resource. It is only used for resources which are specified through an absolute location. In this case the absolute resource location is completely replaced through the path specified through this property. When a document is saved, this attribute is not used.
txBasePath (29) Specifies a character string that is used to search for resources given through a relative location. When a document is loaded, this path is added to the relative location of a resource. When a document is saved the string can only be a file path. All files in the document are saved relative to this path.
txBaseFontSize (30) HTML only. Specifies a base font size in points and is used to convert percentage font sizes to absolute font sizes. When not set, a value of 10 points is used. This attribute is only used when a document is loaded.
txPropFontName (31) HTML only. Defines a proportional font name when not specified in the document. When not set, Text Control uses a default font. This attribute is only used when a document is loaded.
txMonoFontName (32) HTML only. Defines a mono-spaced font name when not specified in the document. When not set, Text Control uses a default mono-spaced font. This attribute is only used when a document is loaded.
txTextColor (33) HTML only. Defines a text color. This attribute is only used when a document is loaded. When the txOverwriteTextColor attribute is set to True, this color is used for text coloring. Otherwise when not set to overwrite, this color is only used when no text color is specified in the document.
txOverwriteTextColor (34) HTML only. Sets the txTextColor attribute to overwrite or not to overwrite.
txTextBkColor (35) HTML only. Defines a text background color. This attribute is only used when a document is loaded. When the txOverwriteTextBkColor attribute is set to True, this color is used for text background coloring. Otherwise, when not set to overwrite, this color is only used when no text background color is specified in the document.
txOverwriteTextBkColor (36) HTML only. Sets the txTextBkColor attribute to overwrite or not to overwrite.
txLoadImages (37) HTML only. Specifies whether or not images are loaded. When not set, images are replaced by its alternate text or a special link text. For all other formats images are always loaded.
txEnableLinks (38) HTML, RTF and Word only. Converts source and target fields of hypertext links to appropriate marked text fields.
txEnableHighlights (39) RTF only. Converts all '\cbN' keywords into marked text fields of the type txFieldHighlight.
txEnableTopics (40) RTF only. Converts all '\sect' keywords into marked text fields of the type txFieldTopic.
txLinkColor (50) HTML only. Defines a text color for pieces of text which function as hypertext links. This attribute is only used when a document is loaded. When the txOverwriteLinkColor attribute is set to True, this color is used to color hypertext links. Otherwise when not set to overwrite, this color is only used when no color for links is specified in the document.
txOverwriteLinkColor (51) HTML only. Sets the txLinkColor attribute to overwrite or not to overwrite.
txUnderlineLinks (52) HTML only. Specifies whether or not hypertext links are underlined. This attribute is only used when a document is loaded. When set to False, hypertext links are only underlined when specified in the document.
Data Types:
txDocWidth | Long
txDocHeight | Long
txDocLeftMargin | Long
txDocTopMargin | Long
txDocRightMargin | Long
txDocBottomMargin | Long
txDocTitle | String
txDocBkColor | Long
txCSSFile | String
txCSSSaveMode | Integer
txDocAccessPermissions | Long
txMasterPassword | String
txUserPassword | String
txImageCompressionQuality | Integer
txImageMaxResolution | Integer
txAbsPath | String
txBasePath | String
txBaseFontSize | Integer
txPropFontName | String
txMonoFontName | String
txTextColor | Long
txOverwriteTextColor | Boolean
txTextBkColor | Long
txOverwriteTextBkColor | Boolean
txLoadImages | Boolean
txEnableLinks | Boolean
txEnableHighlights | Boolean
txEnableTopics | Boolean
txLinkColor | Long
txOverwriteLinkColor | Boolean
txUnderlineLinks | Boolean
Limitations: Run time only.

See also: Load Method, Save Method.


TXTextControl.LockWindowUpdate Property
Description: Disables or reenables redrawing. This property is useful to disable redrawing when setting several properties and reenables redrawing afterwards. This avoids multiple refreshing and flickering.
Syntax: TXTextControl.LockWindowUpdate = boolean

Setting | Description
True | Redrawing is disabled.
False | (Default) Redrawing is enabled.
Data Types: Boolean.

Limitations: Run time only.


TXTextControl.MouseDown Event
Description: Occurs when the user presses a mouse button.
Syntax: TXTextControl.MouseDown(Button, Shift, X, Y)
Parameter Description
Button Informs which button is pressed. Possible values are the following:

Value | Description
1 | The left button is pressed.
2 | The right button is pressed.
4 | The middle button is pressed.
Shift Informs about the state of the SHIFT, CTRL and ALT keys at the time of the event. It is the sum of one or more of the following values:

Value | Description
1 | The SHIFT key was pressed at the time of the event.
2 | The CTRL key was pressed at the time of the event.
4 | The ALT key was pressed at the time of the event.
X,Y Specifies the current location of the mouse pointer. The coordinates are relative to the upper-left corner of the Text Control.
Data Types:
Button: | Integer
Shift: | Integer
X: | Long
Y: | Long
See also: KeyDown Event, KeyUp Event, MouseMove Event, MouseUp Event.


TXTextControl.MouseMove Event
Description: Occurs when the user moves the mouse.
Syntax: TXTextControl.MouseMove(Button, Shift, X, Y)
Parameter Description
Button Informs about the state of the mouse buttons at the time of the event. It is the sum of one or more of the following values:

Value | Description
1 | The left button is pressed.
2 | The right button is pressed.
4 | The middle button is pressed.
Shift Informs about the state of the SHIFT, CTRL and ALT keys at the time of the event. It is the sum of one or more of the following values:

Value | Description
1 | The SHIFT key was pressed at the time of the event.
2 | The CTRL key was pressed at the time of the event.
4 | The ALT key was pressed at the time of the event.
X,Y Specifies the current location of the mouse pointer. The coordinates are relative to the upper-left corner of the Text Control.
Data Types:
Button: | Integer
Shift: | Integer
X: | Long
Y: | Long
See also: KeyDown Event, KeyUp Event, MouseDown Event, MouseUp Event.


TXTextControl.MousePointer Property
Description: Returns or sets a value indicating the type of mouse pointer displayed when the mouse is over a particular part of a Text Control at run time.
Syntax: TXTextControl.MousePointer [= value]

Setting | Description
0 | (Default) The mouse pointer is an I-Beam in edit mode and an arrow in read-only mode. See the EditMode property for more information.
1 | Arrow.
2 | Cross.
3 | I-Beam.
4 | Icon (small square within a square).
5 | Size (four-pointed arrow).
6 | Size NE SW (double arrow pointing northeast and southwest).
7 | Size N S (double arrow pointing north and south).
8 | Size NW SE (double arrow pointing northwest and southeast).
9 | Size W E (double arrow pointing west and east).
10 | Up Arrow.
11 | Hourglass.
12 | Hand.
Data Types: Integer.


TXTextControl.MouseUp Event
Description: Occurs when the user releases a mouse button.
Syntax: TXTextControl.MouseUp(Button, Shift, X, Y)
Parameter Description
Button Informs which button is pressed. Possible values are the following:

Value | Description
1 | The left button is pressed.
2 | The right button is pressed.
4 | The middle button is pressed.
Shift Informs about the state of the SHIFT, CTRL and ALT keys at the time of the event. It is the sum of one or more of the following values:

Value | Description
1 | The SHIFT key was pressed at the time of the event.
2 | The CTRL key was pressed at the time of the event.
4 | The ALT key was pressed at the time of the event.
X,Y Specifies the current location of the mouse pointer. The coordinates are relative to the upper-left corner of the Text Control.
Data Types:
Button: | Integer
Shift: | Integer
X: | Long
Y: | Long
See also: KeyDown Event, KeyUp Event, MouseDown Event, MouseMove Event.


TXTextControl.Move Event
Description: Occurs when a Text Control has been moved with the mouse.
Syntax: Move( )
See also: Size Event, SizeMode Property.


TXTextControl.NumberingAttribute Property
Description: This property returns or sets attributes for numbered lists. A new attribute set with this property has only effect when the ListType Method property is used the next time.
Syntax: TXTextControl.NumberingAttribute(Attribute) [= value]

Parameter | Description
Attribute | Determines the attribute that is to be changed or returned. Possible values are listed in Constants.
Constants: Valid values for the Attribute parameter are:

Constant Description
txNumberingContinue (0) Specifies that the current paragraph continues the numbered list if it is part of a list. To restart a list use txNumberingReStart.
txNumberingFormat (1) Specifies the format of a numbered list. Possible values are:

Code | Meaning
3 | The list is numbered with Arabic numbers (1, 2, 3, ...).
4 | The list is numbered with small letters (a, b, c, ...).
5 | The list is numbered with capital letters (A, B, C, ...).
6 | The list is numbered with Roman numbers (I, II, III, ...).
7 | The list is numbered with small Roman numbers (i, ii, iii, ...).
txNumberingFormatChar (2) Specifies the code of the character that defines the formatting of the gap between the number character and the following text. Possible codes are:

Code | Meaning
0 | The text immediately follows the numbering character.
9 | The text is displayed at the next tabulator position.
32 | The text follows the numbering character seperated with a space character.
txNumberingLevel (3) Specifies the level of the numbered list. The topmost level has the number one, the maximum possible level is 10.
txNumberingPos (4) Defines the position of the number character in twips.
txNumberingPostChar (5) Specifies an additional character that is displayed behind the number character.
txNumberingPreChar (6) Specifies an additional character that is displayed in front of the number character.
txNumberingReStart (7) If the current paragraph is part of a numbered list, this values specifies that a new list begins. The displayed number is given through txNumberingStart. Use txNumberingContinue to continue the list.
txNumberingStart (8) Specifies the starting number of the numbered list. For example, if this attribute is 3 and txNumberingFormat is 4 (small letters), the list starts with 'c'.
txNumberingTextPos (9) Defines, in twips, the position of the text that follows the number character.
Data Types:
txNumberingContinue | Integer
txNumberingFormat | Integer
txNumberingFormatChar | Integer
txNumberingLevel | Integer
txNumberingPos | Integer
txNumberingPostChar | String
txNumberingPreChar | String
txNumberingReStart | Integer
txNumberingStart | Integer
txNumberingTextPos | Integer
Limitations: Run time only.

See also: BulletAttribute Property, ListAttrDialog Method, ListType Property.


TXTextControl.ObjectAttrDialog Method
Description: This method invokes the built-in dialog box for setting attributes of images, text frames and OLE objects. The dialog box offers different options depending on the kind of object, currently selected.
Syntax: TXTextControl.ObjectAttrDialog
Return Value: The method returns True when the user has changed one or more attibutes. The method returns False when the formatting remains unchanged.
Remarks: The changes, made in the dialog box, apply to the currently selected object.

Data Types:
Return value: Boolean

Introduced: 12.0


TXTextControl.ObjectClicked Event
Description: Occurs when an object has been clicked on.
Syntax: ObjectClicked(ObjectId)

Parameter | Description
ObjectId | Is the identifier of the object that has been clicked.
Remarks: The value of the ObjectCurrent property is updated with the identifier given through the ObjectId parameter.
Data Types:
ObjectId: Integer

See also: ObjectDblClicked Event.


TXTextControl.ObjectCreated Event
Description: This event specifies that a new object has been created. This can happen when a document that contains objects, is loaded or when an object is pasted from the clipboard. This event does not occur after inserting a new object with the ObjectInsert, ObjectInsertFixed or ObjectInsertAsChar methods.
Syntax: ObjectCreated(ObjectId)

Parameter | Description
ObjectId | Is the identifier of the object that has been created.
Remarks: The value of the ObjectCurrent property is updated with the identifier given through the ObjectId parameter.
Data Types:
ObjectId: Integer


TXTextControl.ObjectCurrent Property
Description: Returns or sets the current object for setting properties of images, text frames or OLE objects. The ImageInsert, ImageInsertAsChar, ImageInsertFixed, ObjectInsert, ObjectInsertAsChar, ObjectInsertFixed, TextFrameInsert, TextFrameInsertAsChar and TextFrameInsertFixed methods set this property internally to the newly inserted object. This property is also automatically changed when an object is clicked.
Syntax: TXTextControl.ObjectCurrent [= ObjectId]
Data Types: Integer.

Limitations: Run time only.


TXTextControl.ObjectDblClicked Event
Description: Occurs when an object has been double-clicked on.
Syntax: ObjectDblClicked(ObjectId)

Parameter | Description
ObjectId | Is the identifier of the object that has been double-clicked.
Remarks: The value of the ObjectCurrent property is updated with the identifier given through the ObjectId parameter.

Data Types:
ObjectId: Integer

See also: ObjectClicked Event.


TXTextControl.ObjectDelete Method
Description: This method deletes an image, text frame or OLE object.
Syntax: TXTextControl.ObjectDelete ObjectId

Parameter | Description
ObjectId | Is the identifier of the object to delete.
Return Value: The method returns True if the specified object could be deleted, otherwise it returns False.

Remarks: If an object is deleted from code using this method, no ObjectDeleted Event occurs.
Data Types:
ObjectId: | Integer
Return value: | Boolean
See also: ObjectDeleted Event.


TXTextControl.ObjectDeleted Event
Description: Occurs when an object has been deleted.
Syntax: ObjectDeleted(ObjectId)

Parameter | Description
ObjectId | Is the identifier of the object that has been deleted.
Remarks: The value of the ObjectCurrent property is set to zero.
Data Types:
ObjectId: Integer

See also: ObjectDelete Method.


TXTextControl.ObjectDistance Property
Description: Specifies the distance (in twips) between an image, text frame or OLE object and the text that flows around it. This property cannot be used for objects which are inserted as character. The ObjectCurrent property determines the object.
Syntax: TXTextControl.ObjectDistance(index) [= value]

Parameter | Description
index | Specifies one of the four possible distances: left (1), top (2), right (3), bottom (4).
Data Types: Integer.

Limitations: Run time only.


TXTextControl.ObjectGetData Event
Description: Occurs when a document which contains objects, is saved. This event is sent only for objects that have been inserted via its hWnd property. In response to this event, the application can store the object's data by copying it into the ObjectData parameter.
Syntax: ObjectGetData(ObjectId, ObjectData)

Parameter | Description
ObjectId | Is the identifier of the object that is to be saved.
ObjectData | The object's private data can be copied to this parameter.
Remarks: It is recommended to store binary data as a byte array and not as a string.

Data Types:
ObjectId: | Integer
ObjectData: | Variant
See also: ObjectSetData Event, ObjectGethWnd Event.


TXTextControl.ObjectGethWnd Event
Description: Occurs when a document which contains objects, is loaded. This event is sent only for objects that have been inserted via its hWnd property. The application must create the object and copy the object's hWnd property to the hWnd parameter.
Syntax: ObjectGethWnd(ObjectId, KindOfObject, hWnd)

Parameter | Description
ObjectId | Is the identifier of the object that is to be created.
KindOfObject | Is the value that has been specified as KindOfObject parameter for the ObjectInsertAsChar, ObjectInsert or ObjectInsertFixed method.
hWnd | The hWnd property of the new created object must be copied to this variable.
Data Types:
ObjectId: | Integer
KindOfObject: | Integer
hWnd: | Handle
See also: ObjectGetData Event, ObjectSetData Event.


TXTextControl.ObjectGetSelected Method
Description: This method returns the identifier of the currently selected object. An object is selected, if a frame with size handles is drawn around the object. This method can also be used to determine whether a certain kind of object, image, text frame or OLE object, is selected.
Syntax: TXTextControl.ObjectGetSelected ObjectKind

Parameter | Description
ObjectKind | This parameter specifies which kind of objects are searched. It can be a sum of the values, described in Remarks. If this parameter is zero, all objects are searched.
Return Value: The method returns the identifier of an object. It returns zero if no object of the specified kind is selected.
Remarks: The settings for ObjectKind can include:

Value | Description
&H1 | Looks only for objects positioned at a fixed geometrical position.
&H2 | Looks only for objects that act as a single character.
&H4 | Looks only for images.
&H8 | Looks only for objects which are externally created by the application.
&H10 | Looks only for OLE objects.
&H20 | Looks only for text frames.
&H40 | Looks only for objects that are anchored to a paragraph.
Data Types:
ObjectKind: | Integer
Return value: | Integer
Introduced: 12.0


TXTextControl.ObjectGetZoom Event
Description: Occurs when an object's zoom factor is requested. This event is sent only for objects that have been inserted via their hWnd property.
Syntax: ObjectGetZoom(ObjectId, ZoomFactor)

Parameter | Description
ObjectId | Is the identifier of the object, the zoom factor of which is requested.
ZoomFactor | The zoom factor of the object must be copied to this variable.
Data Types:
ObjectId: | Integer
ZoomFactor: | Integer
See also: ObjectSetZoom Event.


TXTextControl.ObjectHeight Property
Description: Returns or sets the natural height, in twips, of an image, text frame or OLE object. For images this property is read only because the image data determine the height. The ObjectCurrent property determines the object.
Syntax: TXTextControl.ObjectHeight
Data Types: Integer.

Limitations: Read only for images, run time only.
Introduced: 12.0


TXTextControl.ObjectInsert Method
Description: This method inserts a new OLE object or other control anchored to a paragraph. The inserted object is then moved with the text.
Syntax: TXTextControl.ObjectInsert ObjectType, FileName, TextPos, Alignment, PosX, PosY, ScaleX, ScaleY, TextFlow, DistanceL, DistanceT, DistanceR, DistanceB[, KindOfObject]
Parameter Description
ObjectType Specifies the type of object. It can be one of the following identifiers:

Value | Description
1 - OLE object | Inserts an OLE object. The type of object can be selected with the system embedded OLE Insert dialog box.
2 - OLE object (programmatic identifier) | Creates a newly created OLE object. In this case, the FileName parameter must specify a string which is the programmatic identifier of the OLE object to insert.The programmatic identifier is stored under the ProgID key in the registration database.
3 - OLE object (embedded) | Inserts a newly created embedded OLE object from a file. In this case, the FileName parameter must specify a valid filename.
4 - OLE object (linked) | Inserts a newly created linked OLE object from a file. In this case, the FileName parameter must specify a valid filename.
Otherwise | Specifies a handle to a control that can be obtained with a control's hWnd property. In this case the FileName parameter must be set to zero.
FileName The meaning of this parameter depends on the object that is to be inserted. See the description of the ObjectType parameter. This parameter can be zero, if the ObjectType parameter specifies a handle to a control.
TextPos Specifies a text position in the paragraph where the object should be inserted. If TextPos is -1, the object is anchored to the paragraph at the current input position.
Alignment Specifies the object's horizontal alignment. It can be one of the following values:

Value | Description
0 | The horizontal position is given through the PosX parameter.
1 | The object is left aligned relative to the paragraph to which it is anchored.
2 | The object is right aligned relative to the paragraph to which it is anchored.
3 | The object is centered relative to the paragraph to which it is anchored.
PosX Specifies the object's horizontal position in twips relative to the left border of the paragraph. This value is used, if the Alignment parameter has been set to 0.
PosY Specifies the object's vertical position in twips relative to the top border of the paragraph.
ScaleX Specifies a horizontal scaling factor as a percentage.
ScaleY Specifies a vertical scaling factor as a percentage.
TextFlow Specifies how text flows around the image or object. It can be one of the following values:

Value | Description
2 | The text stops at the top and continues at the bottom of the object.
3 | The text flows around the object and empty areas at the left and right side are filled.
DistanceL, DistanceT, DistanceR, DistanceB Specifies distances, in twips, between the image or object and the text.
KindOfObject Optional. Specifies an identifier for controls that are not OLE objects. If a document is loaded which contains such controls, an ObjectGethWnd event occurs for each control to give an application the opportunity of recreating these controls. This parameter can be used to handle groups of different control types, like buttons or checkboxes.
Return Value: The method returns the object's identifier when an object could be inserted. Otherwise, it returns zero. The object's identifier can also be obtained with the ObjectCurrent property.

Data Types:
ObjectType: | Handle
FileName: | String
TextPos: | Long
Alignment: | Integer
PosX: | Long
PosY: | Long
ScaleX: | Integer
ScaleY: | Integer
TextFlow: | Integer
DistanceL: | Integer
DistanceT: | Integer
DistanceR: | Integer
DistanceB: | Integer
KindOfObject: | Integer
Return value: | Integer
Introduced: 12.0
See also: ObjectInsertFixed Method, ObjectInsertAsChar Method, Object attribute properties.


TXTextControl.ObjectInsertAsChar Method
Description: This method inserts a new OLE object or other control which is then handled like a single character in the text.
Syntax: TXTextControl.ObjectInsertAsChar ObjectType, FileName, TextPos, ScaleX, ScaleY, ImageDisplayMode, ImageSaveMode [,KindOfObject]
Parameter Description
ObjectType Specifies the type of object. It can be one of the following identifiers:

Value | Description
1 - OLE object | Inserts an OLE object. The type of object can be selected with the system embedded OLE Insert dialog box.
2 - OLE object (programmatic identifier) | Creates a newly created OLE object. In this case, the FileName parameter must specify a string which is the programmatic identifier of the OLE object to insert.The programmatic identifier is stored under the ProgID key in the registration database.
3 - OLE object (embedded) | Inserts a newly created embedded OLE object from a file. In this case, the FileName parameter must specify a valid filename.
4 - OLE object (linked) | Inserts a newly created linked OLE object from a file. In this case, the FileName parameter must specify a valid filename.
Otherwise | Specifies a handle to a control that can be obtained with a control's hWnd property. In this case the FileName parameter must be set to zero.
FileName The meaning of this parameter depends on the object that is to be inserted. See the description of the ObjectType parameter. This parameter must be zero if the ObjectType parameter specifies a handle to a control.
TextPos Specifies the text position where to insert the object. If TextPos is -1, the object is inserted at the current input position.
ScaleX Specifies a horizontal scaling factor as a percentage.
ScaleY Specifies a vertical scaling factor as a percentage.
ImageDisplayMode This parameter is obsolete and must be set to zero.
ImageSaveMode This parameter is obsolete and must be set to zero.
KindOfObject Optional. Specifies an identifier for controls that are not OLE objects. If a document is loaded which contains such controls, an ObjectGethWnd event occurs for each control to give an application the opportunity of recreating these controls. This parameter can be used to handle groups of different control types, like buttons or checkboxes.
Return Value: The method returns the object's identifier when an object could be inserted. Otherwise it returns zero. The object's identifier can also be obtained with the ObjectCurrent property.
Data Types:
ObjectType: | Handle
FileName: | String
TextPos: | Long
ScaleX: | Integer
ScaleY: | Integer
ImageDisplayMode: | Integer
ImageSaveMode: | Integer
KindOfObject: | Integer
Return value: | Integer
See also: ObjectInsert Method, ObjectInsertFixed Method, Object attribute properties.


TXTextControl.ObjectInsertFixed Method
Description: This method inserts a new OLE object or other control at a fixed geometrical position. The text flows around the object.
Syntax: TXTextControl.ObjectInsertFixed ObjectType, FileName, PosX, PosY, ScaleX, ScaleY, ImageDisplayMode, ImageSaveMode, SizeMode, TextFlow, DistanceL, DistanceT, DistanceR, DistanceB[, KindOfObject]
Parameter Description
ObjectType Specifies the type of object. It can be one of the following identifiers:

Value | Description
1 - OLE object | Inserts an OLE object. The type of object can be selected with the system embedded OLE Insert dialog box.
2 - OLE object (programmatic identifier) | Creates a newly created OLE object. In this case, the FileName parameter must specify a string which is the programmatic identifier of the OLE object to insert.The programmatic identifier is stored under the ProgID key in the registration database.
3 - OLE object (embedded) | Inserts a newly created embedded OLE object from a file. In this case, the FileName parameter must specify a valid filename.
4 - OLE object (linked) | Inserts a newly created linked OLE object from a file. In this case, the FileName parameter must specify a valid filename.
Otherwise | Specifies a handle to a control that can be obtained with a control's hWnd property. In this case the FileName parameter must be set to zero.
FileName The meaning of this parameter depends on the object that is to be inserted. See the description of the ObjectType parameter. This parameter must be zero, if the ObjectType parameter specifies a handle to a control.
PosX Specifies the object's horizontal position in twips relative to the left border of the page.
PosY Specifies the object's vertical position in twips relative to the top of the first page.
ScaleX Specifies a horizontal scaling factor as a percentage.
ScaleY Specifies a vertical scaling factor as a percentage.
ImageDisplayMode This parameter is obsolete and must be set to zero.
ImageSaveMode This parameter is obsolete and must be set to zero.
SizeMode Specifies whether the image or object can be moved and/or sized. See the ObjectSizeMode property for possible values.
TextFlow Specifies how text flows around the image or object. It can be one of the following values:

Value | Description
2 | The text stops at the top and continues at the bottom of the object.
3 | The text flows around the object and empty areas at the left and right side are filled.
DistanceL, DistanceT, DistanceR, DistanceB Specifies distances, in twips, between the image or object and the text.
KindOfObject Optional. Specifies an identifier for controls that are not OLE objects. If a document is loaded which contains such controls, an ObjectGethWnd event occurs for each control to give an application the opportunity of recreating these controls. This parameter can be used to handle groups of different control types, like buttons or checkboxes.
Return Value: The method returns the object's identifier when an object could be inserted. Otherwise, it returns zero. The object's identifier can also be obtained with the ObjectCurrent property.

Data Types:
ObjectType: | Handle
FileName: | String
PosX: | Long
PosY: | Long
ScaleX: | Integer
ScaleY: | Integer
ImageDisplayMode: | Integer
ImageSaveMode: | Integer
SizeMode: | Integer
TextFlow: | Integer
DistanceL: | Integer
DistanceT: | Integer
DistanceR: | Integer
DistanceB: | Integer
KindOfObject: | Integer
Return value: | Integer
See also: ObjectInsert Method, ObjectInsertAsChar Method, Object attribute properties.


TXTextControl.ObjectItem Property
Description: Returns a reference to an OLE object. The ObjectCurrent property determines the object.
Syntax: TXTextControl.ObjectItem
Data Types: Object.

Limitations: Read only, run time only.
Example: The following Basic example inserts a Text Control into another Text Control at the current input position and sets the font bold attribute for the inserted Text Control. The ObjectInsertAsChar method implicitely sets the ObjectCurrent property to the just inserted object.
TXTextControl1.ObjectInsertAsChar 2, "TIS.TX.TextControl.12", -1,
100, 100, 0, 0
TXTextControl1.ObjectItem.FontBold = True


TXTextControl.ObjectMoved Event
Description: Occurs if an image, text frame or OLE object has been moved with the built-in mouse interface.
Syntax: ObjectMoved(ObjectId)

Parameter | Description
ObjectId | Is the identifier of the object that has been moved.
Data Types:
ObjectId: Integer

See also: ObjectSized Event.


TXTextControl.ObjectNext Method
Description: This method returns the identifier of the object that follows the specified object in a Text Control's internal list of objects.
Syntax: TXTextControl.ObjectNext ObjectId, ObjectGroup

Parameter | Description
ObjectId | Specifies a valid object identifier. If this parameter is zero, the first object's identifier is returned.
ObjectGroup | This parameter specifies which kinds of objects are to be returned. It can be a sum of the values as described in Remarks. If this parameter is zero, the identifiers of all objects are returned.
Return Value: The method returns the next object's identifier. It returns zero when there is no following object.
Remarks: The settings for ObjectGroup can include:

Value | Description
&H1 | Returns only identifiers of objects positioned at a fixed geometrical position.
&H2 | Returns only identifiers of objects that act as single characters.
&H4 | Returns only identifiers of images.
&H8 | Returns only identifiers of objects which are externally created by the application.
&H10 | Returns only identifiers of OLE objects.
&H20 | Returns only identifiers of text frames.
&H40 | Returns only identifiers of objects that are anchored to a paragraph.
Data Types:
ObjectId: | Integer
ObjectGroup: | Integer
Return value: | Integer


TXTextControl.ObjectPrint Event
Description: Occurs when a document containing objects is printed. This event is sent only for objects that have been inserted via its hWnd property.
Syntax: ObjectPrint(ObjectId, Device, Left, Top, Right, Bottom, Processed)

Parameter | Description
ObjectId | Is the identifier of the object that is to be printed.
Device | Is the printer device context.
Left, Top, Right, Bottom | Is the object's bounding rectangle. This rectangle is given in device pixels with an origin at the upper left corner of the object.
Processed | When the object has been printed, this parameter should be set to True.
Data Types:
ObjectId: | Integer
Device: | Long
Left, Top, Right, Bottom: | Long
Processed: | Boolean
See also: ObjectGetData Event, ObjectSetData Event, ObjectGethWnd Event.


TXTextControl.ObjectRightClicked Event
Description: Occurs when an object has been clicked on with the right mouse button.
Syntax: ObjectRightClicked(ObjectId)

Parameter | Description
ObjectId | Is the identifier of the object that has been clicked.
Remarks: The value of the ObjectCurrent property is updated with the identifier given through the ObjectId parameter.
Data Types:
ObjectId: Integer

Introduced: 12.0
See also: ObjectClicked Event, ObjectDblClicked Event.


TXTextControl.ObjectScaleX Property
Description: Specifies the object's horizontal scaling factor as a percentage. The ObjectCurrent property determines the object. This property cannot be used with text frames.
Syntax: TXTextControl.ObjectScaleX [= value]
Data Types: Integer.

Limitations: Run time only.

See also: ObjectScaleY Property.


TXTextControl.ObjectScaleY Property
Description: Specifies the object's vertical scaling factor as a percentage. The ObjectCurrent property determines the object. This property cannot be used with text frames.
Syntax: TXTextControl.ObjectScaleY [= value]
Data Types: Integer.

Limitations: Run time only.

See also: ObjectScaleX Property.


TXTextControl.ObjectScrollOut Event
Description: Occurs when an object is scrolled out of the visible area.
Syntax: ObjectScrollOut(ObjectId)

Parameter | Description
ObjectId | Is the identifier of the object that has been scrolled.
Data Types:
ObjectId: Integer

See also: ObjectMoved Event, ObjectSized Event.


TXTextControl.ObjectSetData Event
Description: Occurs when a document which contains objects, is loaded. This event is sent only for objects that have been inserted via its hWnd property.
Syntax: ObjectSetData(ObjectId, ObjectData)

Parameter | Description
ObjectId | Is the identifier of the object that is loaded.
ObjectData | The data of the object in the format saved with the ObjectGetData event.
Data Types:
ObjectId: | Integer
ObjectData: | Variant
See also: ObjectGetData Event, ObjectGethWnd Event.


TXTextControl.ObjectSetZoom Event
Description: Occurs when an object's zoom factor is to be changed. This event is sent only for objects that have been inserted via its hWnd property.
Syntax: ObjectSetZoom(ObjectId, ZoomFactor, Processed)

Parameter | Description
ObjectId | Is the identifier of the object, the zoom factor of which is to be changed.
ZoomFactor | Is the object's new zoom factor.
Processed | If the event is being processed this parameter should be set to True.
Data Types:
ObjectId: | Integer
ZoomFactor: | Integer
Processed: | Boolean
See also: ObjectGetZoom Event.


TXTextControl.ObjectSized Event
Description: Occurs if an image, text frame or OLE object has been resized with the built-in mouse interface.
Syntax: ObjectSized(ObjectId)

Parameter | Description
ObjectId | Is the identifier of the object that has been sized.
Data Types:
ObjectId: Integer

See also: ObjectMoved Event.


TXTextControl.ObjectSizeMode Property
Description: Specifies whether an inserted image, text frame or OLE object can be moved or resized at run time. If the Moveable option is selected, the object can be moved on the background. If the Sizeable option is selected, the borders of the object can be dragged. Images and OLE objects can be moved after clicking elsewhere on the image or object, text frames can be moved after clicking on the frame. If an object is clicked resize handles appear to indicate that this object is currently selected. The ObjectCurrent property determines the object.
Syntax: TXTextControl.ObjectSizeMode [= value]

Setting | Description
0 - Fixed | (Default) The object cannot be moved or sized.
1 - Moveable | The object can be moved.
2 - Sizeable | The object can be sized.
3 - Move and Sizeable | The object can be moved and sized.
Data Types: Integer.
Limitations: Run time only.

See also: ObjectMoved Event, ObjectSized Event, SizeMode Property.


TXTextControl.ObjectTextflow Property
Description: Informs about the way in which text flows around an image, text frame or OLE object. The ObjectCurrent property determines the object.
Syntax: TXTextControl.ObjectTextflow

Parameter | Description
0 | The object is inserted 'as character'.
2 | The text stops at the top and continues at the bottom of the object.
3 | The text flows around the object and empty areas at the left and right side are filled.
Data Types: Integer.
Limitations: Read only, run time only.


TXTextControl.ObjectWidth Property
Description: Returns or sets the natural width, in twips, of an image, text frame or OLE object. For images this property is read only because the image data determine the width. The ObjectCurrent property determines the object.
Syntax: TXTextControl.ObjectWidth
Data Types: Integer.

Limitations: Read only for images, run time only.
Introduced: 12.0


TXTextControl.PageFormatChange Event
Description: Occurs when the page format settings have been changed.

Syntax: PageFormatChange( )


TXTextControl.PageHeight Property
Description: Specifies the height of the page for the current document.
Syntax: TXTextControl.PageHeight [= value]
Remarks: The height of the actual printed area is PageHeight minus PageMarginB minus PageMarginT. The maximum value depends on the capabilities of the selected printer and must not exceed 32767 twips.
Data Types: Long.

Example: See PrintPage method example.
See also: PageWidth Property, PageMarginx Properties, PrintDevice Property, PrintPage Method.


TXTextControl.PageMarginB Property
Description: Returns or sets the bottom margin for the pages of the current document.
Syntax: TXTextControl.PageMarginB [= value]
Remarks: The maximum values depend on the setting of the PageWidth and PageHeight properties.
Data Types: Long.

See also: PageHeight Property, PageWidth Property, PrintDevice Property, PrintPage Method.


TXTextControl.PageMarginL Property
Description: Returns or sets the left margin for the pages of the current document.
Syntax: TXTextControl.PageMarginL [= value]
Remarks: The maximum values depend on the setting of the PageWidth and PageHeight properties.
Data Types: Long.

See also: PageHeight Property, PageWidth Property, PrintDevice Property, PrintPage Method.


TXTextControl.PageMarginR Property
Description: Returns or sets the right margin for the pages of the current document.
Syntax: TXTextControl.PageMarginR [= value]
Remarks: The maximum values depend on the setting of the PageWidth and PageHeight properties.
Data Types: Long.

See also: PageHeight Property, PageWidth Property, PrintDevice Property, PrintPage Method.


TXTextControl.PageMarginT Property
Description: Returns or sets the top margin for the pages of the current document.
Syntax: TXTextControl.PageMarginT [= value]
Remarks: The maximum values depend on the setting of the PageWidth and PageHeight properties.
Data Types: Long.

See also: PageHeight Property, PageWidth Property, PrintDevice Property, PrintPage Method.


TXTextControl.PageWidth Property
Description: Specifies the width of the page for the current document.
Syntax: TXTextControl.PageWidth [= value]
Remarks: The width of the actual printed area is PageWidth minus PageMarginL minus PageMarginR. The maximum value depends on the capabilities of the selected printer and must not exceed 32767 twips.
Data Types: Long.

Example: See PrintPage method example.
See also: PageHeight Property, PageMarginx Properties, PrintDevice Property, PrintPage Method.


TXTextControl.ParagraphChange Event
Description: Occurs when the character input position has been moved to another paragraph.
Syntax: ParagraphChange( )


TXTextControl.ParagraphDialog Method
Description: Invokes the Text Control's built-in paragraph attributes dialog box and, after the user has closed the dialog box, specifies whether he has changed something.
Syntax: TXTextControl.ParagraphDialog
Return Value: The method returns True when the user has changed one or more attibutes. The method returns False when the formatting remains unchanged.
Remarks: The changes, made in the dialog box, apply to the currently selected text.
Data Types:
Return value: Boolean


TXTextControl.ParagraphFormatChange Event
Description: Occurs when the paragraph attributes of the selected paragraphs have been changed.
Syntax: ParagraphFormatChange( )


TXTextControl.PosChange Event
Description: Occurs when the current character input position has been changed.
Syntax: PosChange( )


TXTextControl.PrintColors Property
Description: Specifies whether text colors are printed as colors or in black.
Syntax: TXTextControl.PrintColors [= booelan]

Setting | Description
True | (Default) Text colors are printed.
False | All the text is printed in black.
Data Types: Boolean.


TXTextControl.PrintDevice Property
Description: Sets the printer device context for TextContol's built-in printing function. The Windows operating enviroment manages devices like printers and screens with context handles.
Syntax: TXTextControl.PrintDevice [= DeviceContextHandle]
Data Types: Long.
Limitations: Write only, run time only.
See also: PageHeight Property, PageMarginx Properties, PageWidth Property, PrintPage Method. Example: See PrintPage method.


TXTextControl.PrintDoc Method
Description: Prints a Text Control document or a part of a Text Control document on the default printer.
Syntax: TXTextControl.PrintDoc DocName, FirstPage, LastPage, Copies

Parameter | Description
DocName | Specifies the name of the document used for the print job.
FromPage | Specifies the first page to print.
ToPage | Specifies the last page to print.
Copies | Specifies the number of copies to print.
Return Value: This method has no return value.
Remarks: Prior to using this method the Text Control's output device can be selected using the PrintDevice property. If this property is not used Text Control prints to the printer, for which the document is currently formatted.
Data Types:
DocName | String
FromPage | Integer
ToPage | Integer
Copies | Integer
See also: PrintPage Method, PrintDevice Property.


TXTextControl.PrintOffset Property
Description: Determines whether Text Control starts printing exactly at the top left corner of the page, or at the printer's physical printing offset.
Syntax: TXTextControl.PrintOffset [= boolean]

Setting | Description
True | Adds the physical printing offset.
False | (Default) Do not add the physical printing offset.
Data Types: Boolean.


TXTextControl.PrintPage Method
Description: Prints a page of text on the default printer. The number is specified through PageNumber.
Syntax: TXTextControl.PrintPage PageNumber

Parameter | Description
PageNumber | Specifies the number of the page to print. The first page has the number 1.
Return Value: This method has no return value.
Remarks: Prior to using this method the Text Control's output device must be selected using the PrintDevice property.
Data Types:
PageNumber Integer

Example: This Basic example shows how to print the contents of a Text Control on the default printer:
Sub mnuFile_Print_Click ()
   Dim wPages, No
   Printer.Print
   wPages = TXTextControl1.CurrentPages
   For No = 1 To wPages
      TXTextControl1.PrintDevice = Printer.hDC
      TXTextControl1.PrintPage No
      Printer.NewPage
   Next No
   Printer.EndDoc
End Sub
See also: PageHeight Property, PageMarginx Properties, PageWidth Property, PrintDevice Property.


TXTextControl.PrintZoom Property
Description: Specifies a zoom factor for printing. The value is specified as a percentage in the range of 10 to 400%. This property is independent of the current ZoomFactor setting.
Syntax: TXTextControl.PrintZoom [= value]
Data Types: Integer.

See also: ZoomFactor Property.


TXTextControl.Redo Method
Description: This method can be used to redo the last Text Control operation.
Syntax: TXTextControl.Redo
Return Value: The method returns True if the redo operation was successful. Otherwise it returns False.
Data Types:
Return value: Boolean

See also: Undo Method, CanUndo Property, CanRedo Property.


TXTextControl.Refresh Method
Description: This method forces a complete repaint of a Text Control.
Syntax: TXTextControl.Refresh
Return Value: This method has no return value.


TXTextControl.ResetContents Method
Description: Deletes the complete contents of a Text Control including tables, objects, marked text fields and headers and footers.
Syntax: TXTextControl.ResetContents
Return Value: The method returns True, if everything could be deleted, otherwise it returns False.
Data Types:
Return value: Boolean


TXTextControl.ResourceFile Property
Description: Returns or sets the file name of a resource library which Text Control loads to display resources like information strings, error messages and built-in dialog boxes. The file name must include a complete path. When a resource library is set, the value of the Language property is ignored. See the chapter Technical Articles - Resources for more information. To avoid compatibility errors, resource libraries should have a unique file name and should be placed in the same directory as the application's executable file.
Syntax: TXTextControl.ResourceFile [= string]
Data Types: String.

Limitations: Run time only.

See also: Language Property.


TXTextControl.RTFSelText Property
Description: This property works much like the standard SelText property. The SelStart and SelLength properties can be used to specify a text selection which is to be copied to a string or inserted from a string. The difference between SelText and RTFSelText is that with the SelText property, text is stored without formatting information in the ANSI format, whilst RTFSelText uses Rich Text Format to preserve all of the formatting attributes.
Syntax: TXTextControl.RTFSelText [= string]
Remarks: RTF (Rich Text Format) is one of the most common interchange formats for text documents. Most word processors available for Windows are able to read and write RTF files.
Data Types: String.

Limitations: Run time only.


TXTextControl.RulerHandle Property
Description: Specifies the ruler control to be used with a Text Control.
Syntax: TXTextControl.RulerHandle [= Ruler.hWnd]
Data Types: Handle.

Limitations: Run time only.

See also: StatusBarHandle Property, ButtonBarHandle Property.


TXTextControl.Save Method
Description: Saves data in a file with a specified format.
Syntax: TXTextControl.Save FileName[, Offset[, Format[, CurSelection]]]
Parameter Description
FileName Specifies the file to save in.
Offset Optional. Specifies the file position to where the data is to be written when the data of more than one Text Control are to be saved. When not specified or set to -1 the data is appended.
Format Optional. Specifies a format identifier. When this parameter is not specified the data is saved in the internal Text Control format (3). Otherwise it can be one of the following values:

Constant | Description
1 - ANSI text | Text in Windows ANSI format (an end of a paragraph is marked with the control characters 13 and 10).
2 - TX text | Text in ANSI format (an end of a paragraph is marked only with the control character 10).
3 - TX | Text including formatting attributes in the internal Text Control format. Text is stored in ANSI.
4 - HTML | HTML format (Hypertext Markup Language).
5 - RTF | RTF format (Rich Text Format).
6 - Unicode text | Text in Windows Unicode format (an end of a paragraph is marked with the control characters 13 and 10).
7 - TX text | Text in Unicode format (an end of a paragraph is marked only with the control character 10).
8 - TX | Text including formatting attributes in the internal Text Control format. Text is stored in Unicode.
9 - Microsoft Word | Microsoft Word format.
10 - XML | XML format (Extensible Markup Language).
11 - CSS | CSS format (Cascading Style Sheet).
12 - Adobe PDF | Portable Document Format (PDF).
CurSelection Optional. When set to True the current selection is saved. When omitted or set to False or when no selection exists all the control contents are saved. This parameter must be set to False if the saving format is XML (10) or CSS (11).
Return Value: The method returns the position in the file behind the saved data. It is zero if the data could not be saved.
Data Types:
FileName: | String
Offset: | Long
Format: | Integer
CurSelection: | Boolean
Return value: | Long
See also: Load Method.


TXTextControl.SaveToMemory Method
Description: Returns a one-dimensional byte array containing text data in a specified format.
Syntax: TXTextControl.SaveToMemory [Format[, CurSelection]]

Parameter | Description
Format | Optional. Specifies a format identifier. When this parameter is not specified the data is saved in the internal Text Control format (3). See the Format parameter of the Save method for possible format identifiers.
CurSelection | Optional. When set to True the current selection is saved. When omitted or set to False or when no selection exists all the control contents are saved.
Return Value: The method returns a one-dimensional array of bytes, containing the saved data.
Data Types:
Format: | Integer
CurSelection: | Boolean
Return value: | One-dimensional Byte Array
Example: This Basic example copies the currently selected text from the first Text Control and inserts it at the current input position of a second Text Control:
Dim data() As Byte
data = TXTextControl1.SaveToMemory(3, True)
TXTextControl2.LoadFromMemory data, 3, True
See also: Save Method, LoadFromMemory Method.


TXTextControl.SaveToMemoryBuffer Method
Description: Returns a buffer containing text data in a specified format. The buffer can be a string or a one-dimensional byte array. To inform Text Control which kind of buffer is to returned specify the buffer as the first parameter.
Syntax: TXTextControl.SaveToMemoryBuffer DataBuffer[, [Format[, CurSelection]]

Parameter | Description
DataBuffer | Specifies a buffer that can be a string or a byte array. Text Control uses this parameter to get the type of the return buffer.
Format | Optional. Specifies a format identifier. When this parameter is not specified the data is saved in the internal Text Control format (3). See the Format parameter of the Save method for possible format identifiers.
CurSelection | Optional. When set to True the current selection is saved. When omitted or set to False or when no selection exists all the control contents are saved.
Return Value: The method returns a buffer, containing the saved data.
Data Types:
DataBuffer: | String or One-dimensional Byte Array
Format: | Integer
CurSelection: | Boolean
Return value: | Same Type as DataBuffer
Example: This Basic example copies the currently selected text from the first Text Control and inserts it at the current input position of a second Text Control using RTF format:
Dim RTF As String
RTF = TXTextControl1.SaveToMemoryBuffer(RTF, 5, True)
TXTextControl2.LoadFromMemory RTF, 5, True
See also: Save Method, SaveToMemory Method, LoadFromMemory Method.


TXTextControl.ScrollBars Property
Description: Returns or sets a value indicating whether a Text Control has horizontal or vertical scroll bars. Scroll bars are automatically hidden when the formatting area is smaller than the control's visible area and vice versa. Therefore this property has only effect if the PageWidth and/or the PageHeight properties have been set to non-zero. See Technical Articles - Text Formatting and Views for more information.
Syntax: TXTextControl.ScrollBars [= value]

Setting | Description
0 | (Default) The Text Control has no scroll bars.
1 | The Text Control has a horizontal scroll bar when the page width is larger than the control's width.
2 | The Text Control has a vertical scroll bar when the page height is larger than the control's height.
3 | The Text Control has both scroll bars.
Data Types: Integer.

See also: PageWidth Property, PageHeight Property.


TXTextControl.ScrollPosX Property
Description: Specifies the position of the horizontal scroll bar in twips.
Syntax: TXTextControl.ScrollPosX [= value]
Data Types: Long.

Limitations: Run time only.

See also: ScrollPosY Property, HScroll Event, VScroll Event.


TXTextControl.ScrollPosY Property
Description: Specifies the position of the vertical scroll bar in twips.
Syntax: TXTextControl.ScrollPosY [= value]
Data Types: Long.

Limitations: Run time only.

See also: ScrollPosX Property, HScroll Event, VScroll Event.


TXTextControl.SelLength Property
Description: Returns or sets the number of characters selected.
Syntax: TXTextControl.SelLength [= value]
Remarks: The valid range of settings is 0 to text length, the total number of characters a Text Control contains. Setting this property's value to a value larger than the current text size, extents the selection up to the document's end.
Data Types: Long.

Limitations: Run time only.

See also: SelStart Property, SelText Property.


TXTextControl.SelStart Property
Description: Returns or sets the starting point of text selected or indicates the position of the insertion point if no text is selected. The first text position has a value of 0.
Syntax: TXTextControl.SelStart [= value]
Remarks: Setting the property value greater than the text length limits it to the existing text length. Setting this property to -1 will set the starting point for a selection to the documents end.
Data Types: Long.

Limitations: Run time only.

See also: SelLength Property, SelText Property.


TXTextControl.SelText Property
Description: Returns or sets the string containing the currently selected text. It is a zero-length string if no characters are selected. This property can be used in conjunction with the SelStart and SelLength properties for tasks such as selecting substrings or clearing text. In conjunction with the clipboard these properties are useful for copy, cut, and paste operations.
Syntax: TXTextControl.SelText [= value]
Remarks: Setting this property to a new value sets SelLength to 0 and replaces the selected text with the new string.
Data Types: String.

Limitations: Run time only.

See also: SelLength Property, SelStart Property.


TXTextControl.Size Event
Description: Occurs when a Text Control has been resized with the mouse.
Syntax: Size( )
See also: Move Event, SizeMode Property.


TXTextControl.SizeMode Property
Description: Specifies whether the Text Control can be moved or resized at run time. If the Moveable option is selected, the control can be moved by dragging the control's frame with the mouse, after the cross cursor has been shown. If the Sizeable option is selected, the control can be resized after a resize cursor has been shown in one of the frame's corners or midpoints.
Syntax: TXTextControl.SizeMode [= value]

Setting | Description
0 - Fixed | (Default) The Text Control cannot be moved or sized.
1 - Moveable | The Text Control can be moved.
2 - Sizeable | The Text Control can be sized.
3 - Move and Sizeable | The Text Control can be moved and sized.
Data Types: Integer.

See also: Move Event, Size Event.


TXTextControl.StartUndoAction Method
Description: Defines the beginning of an undo action. It can be used, if more than one property or method call is to be defined as a single undo action. All property and/or method calls between StartUndoAction and EndUndoAction define a single undo action.
Syntax: TXTextControl.StartUndoAction
Introduced: 11.0
See also: EndUndoAction Method.


TXTextControl.StatusBarHandle Property
Description: Specifies the status bar control to be used with a Text Control.
Syntax: TXTextControl.StatusBarHandle [= TXStatusBar.hWnd]
Data Types: Handle.
Limitations: Run time only.

See also: ButtonBarHandle Property, RulerHandle Property.


TXTextControl.StyleChanged Event
Description: Occurs after the character input position has been moved to a text part formatted with another style.
Syntax: StyleChanged( )


TXTextControl.StyleCurrent Property
Description: Returns or sets the formatting style at the current input position or, if text is selected, changes all styles of the selected text to the specified style. If text is selected and formatted with several styles the property returns an empty string. A formatting style is given through its unique name.
Syntax: TXTextControl.StyleCurrent [= StyleName]
Data Types: String.

Limitations: Run time only.


TXTextControl.StyleDialog Method
Description: Invokes the Text Control's built-in dialog box for creating, deleting and modifying formatting styles.
Syntax: TXTextControl.StyleDialog
Return Value: The method returns True when the user has changed one or more styles. The method returns False when all styles remain unchanged.
Remarks: A StyleListChanged event occurs if styles have been deleted or if new styles have been created.
Data Types:
Return value: Boolean


TXTextControl.StyleListChanged Event
Description: Occurs after one or more formatting styles have been added or removed.
Syntax: StyleListChanged( )


TXTextControl.Styles Property
Description: Returns a collection of all formatting styles in a document.
Syntax: TXTextControl.Styles
Data Types: Styles Collection object.

Limitations: Read only, run time only.

See also: Styles Collection, Style Object.


TXTextControl.TabCurrent Property
Description: Specifies the current tab number for the properties TabPos and TabType.
Syntax: TXTextControl.TabCurrent [= value]
Remarks: Text Control supports up to 14 tabs for each paragraph. Valid values for this property are 1 to 14.
Text Control sorts the tabs in ascending order whenever you change the position of a tab, so a tab's number can change when it it moved. In this case, the TabCurrent Property is updated to reflect the change. Tabs outside of the paragraph are automatically set to zero.
Data Types: Integer.

Example: The first of the following Basic examples moves the first tab to a new position 1 inch from the left border and changes it to a decimal tab. The second of the following Basic examples changes all the tabs to be right-aligned at 1/2 inch gradations:
TXTextControl1.TabCurrent = 1
TXTextControl1.TabType = 4
TXTextControl1.TabPos = 1440

' Delete all tabs
for n=14 to 1 step -1
   TXTextControl1.TabCurrent = n
   TXTextControl1.TabPos = 0
next n
' Create new tabs
for n=1 to 14
   TXTextControl1.TabCurrent = n
   TXTextControl1.TabPos = n*720
   if (TXTextControl1.TabPos > 0) then _
      TXTextControl1.TabType = 2
next n
See also: TabPos Property, TabType Property.


TXTextControl.TabDialog Method
Description: Invokes the Text Control's built-in dialog box for setting tabs.
Syntax: TXTextControl.TabDialog
Return Value: The method returns True when the user has changed one or more tabs. The method returns False when all tabs remain unchanged.
Data Types:
Return value: Boolean


TXTextControl.TabKey Property
Description: Determines if the keyboard's tab key moves the input focus to the next control or to insert tabulators in the Text Control's text.
Syntax: TXTextControl.TabKey [= boolean]

Setting | Description
True | (Default) Inserts a tabulator in the Text Control's text.
False | Moves the current input focus to the next control.
Data Types: Boolean.


TXTextControl.TableAtInputPos Property
Description: Returns the table identifier of the table containing the input position. Zero is returned when the input position is not inside a table or when more than one table cell is selected.
Syntax: TXTextControl.TableAtInputPos
Data Types: Integer.

Limitations: Read only, run time only.

See also: TableColAtInputPos Property, TableRowAtInputPos Property.


TXTextControl.TableAttrDialog Method
Description: This method invokes the built-in dialog box for setting table attributes and, after the user has closed the dialog box, specifies whether he has changed something.
Syntax: TXTextControl.TableAttrDialog
Return Value: The method returns True when the user has changed one or more attibutes. The method returns False when the formatting remains unchanged.
Remarks: The changes, made in the dialog box, apply to the currently selected text.

Data Types:
Return value: Boolean


TXTextControl.TableCanChangeAttr Property
Description: This property provides information about whether the attributes of all the selected table cells can be altered. It returns False when the selection is not completely within a single table. Otherwise it returns True.
Syntax: TXTextControl.TableCanChangeAttr

Setting | Description
True | Table attributes can be altered.
False | Table attributes cannot be altered.
Data Types: Boolean.

Limitations: Read only, run time only.

See also: TableAttrDialog Method.


TXTextControl.TableCanDeleteColumn Property
Description: This property provides information about whether a table column can be deleted. It returns True if a table column can be deleted. It returns False if text is selected or if the current input position is outside a table.
Syntax: TXTextControl.TableCanDeleteColumn
Data Types: Boolean.

Limitations: Read only, run time only.

See also: TableDeleteColumn Method.


TXTextControl.TableCanDeleteLines Property
Description: This property provides information about whether table lines can be deleted. It returns False when no table line is selected or when the current input position is outside a table. Otherwise it returns True.
Syntax: TXTextControl.TableCanDeleteLines

Setting | Description
True | Table lines can be deleted.
False | Table lines cannot be deleted.
Data Types: Boolean.

Limitations: Read only, run time only.

See also: TableDeleteLines Method.


TXTextControl.TableCanInsert Property
Description: This property provides information about whether a table can be inserted. It returns False when a selection exists or the current input position is inside a table. Otherwise it returns True.
Syntax: TXTextControl.TableCanInsert

Setting | Description
True | A new table can be inserted.
False | A new table cannot be inserted.
Data Types: Boolean.

Limitations: Read only, run time only.

See also: TableInsert Method.


TXTextControl.TableCanInsertColumn Property
Description: This property provides information about whether a table column can be inserted. It returns True if a table column can be inserted. It returns False if text is selected or if the current input position is outside a table.
Syntax: TXTextControl.TableCanInsertColumn
Data Types: Boolean.

Limitations: Read only, run time only.

See also: TableInsertColumn Method.


TXTextControl.TableCanInsertLines Property
Description: This property provides information about whether table lines can be inserted. It returns True if table lines can be inserted. It returns False if text is selected or if the current input position is outside a table.
Syntax: TXTextControl.TableCanInsertLines
Data Types: Boolean.

Limitations: Read only, run time only.

See also: TableInsertLines Method.


TXTextControl.TableCanSplit Property
Description: Checks whether a table can be split. A table can only be split, if it contains the current input position and no further text is selected.
Syntax: TXTextControl.TableCanSplit
Data Types: Boolean.

Limitations: Read only, run time only.

Introduced: 11.0
See also: TableSplit Method.


TXTextControl.TableCellAttribute Property
Description: Returns or sets attributes of a table cell.
Syntax: TXTextControl.TableCellAttribute(TableId, Row, Column, Attribute) [= value]

Parameter | Description
TableId | Specifies a table. It is the same identifier set with the TableInsert method.
Row | Specifies a row number which identifies a certain cell in the table. The first row has the number one. This parameter set to zero means a complete column.
Column | Specifies a column number which identifies a certain cell in the table. The first column has the number one. This parameter set to zero means a complete row.
Attribute | Specifies the type of attribute. It can be anyone of the values listed in Constants.
Constants: Valid values for the Attribute parameter are:

Constant Description
txTableCellHorizontalPos (0) The property value is the horizontal position of a table cell.
txTableCellHorizontalExt (1) The property value is the horizontal extension of a table cell.
txTableCellBorderWidth (2) The property value is the border width of a table cell.
txTableCellTextGap (3) The property value is the width of the gap between a cell's border and its text.
txTableCellBackColor (4) The property value is the table cell's background color.
txTableCellLeftBorderWidth (5) The property value is the left border width of a table cell.
txTableCellTopBorderWidth (6) The property value is the top border width of a table cell.
txTableCellRightBorderWidth (7) The property value is the right border width of a table cell.
txTableCellBottomBorderWidth (8) The property value is the bottom border width of a table cell.
txTableCellLeftTextGap (9) The property value is the width of the gap between a cell's left border and its text.
txTableCellTopTextGap (10) The property value is the width of the gap between a cell's top border and its text.
txTableCellRightTextGap (11) The property value is the width of the gap between a cell's right border and its text.
txTableCellBottomTextGap (12) The property value is the width of the gap between a cell's bottom border and its text.
txTableCellVertAlign (13) The property value defines the vertically alignment of the cell's text. The following values are possible:

Constant | Description
0 | The text is a aligned at the top of the cell.
1 | The text is vertically centered.
2 | The text is a aligned at the bottom of the cell.
txTableCellHeight (14) The property value is the minimum height of a table cell. If zero is set or returned, the cell's height is always determined through the containing text.
txTableCellPageBreakAllowed (15) The property value is True, if the table cell can be formatted across page breaks. The property value is False, if the table cell must not be formatted across page breaks.
Remarks: When the row and column parameters are both set to zero the attributes of a complete table can be manipulated. When more than one table cell is specified this property returns Null (Visual Basic) or is set to empty (C++) if the cells are differently formatted.
Data Types:
TableId: | Integer
Row: | Integer
Column: | Integer
Attribute: | Integer
Property value: | Variant
Limitations: Run time only.

Example: This Basic example sets a red background color for the leftmost column of a table:
TXTextControl1.TableCellAttribute(id, 0, 1, 4) = RGB(255, 0, 0)
See also: TableInsert Method, TableCellText Property.


TXTextControl.TableCellLength Property
Description: Returns the number of characters in a table cell.
Syntax: TXTextControl.TableCellLength(TableId, Row, Column)

Parameter | Description
TableId | Specifies a table. It is the same identifier set with the TableInsert method.
Row, Column | Specify a row and column number which identifies a certain cell in the table. The first has the number 1, 1.
Data Types:
TableId: | Integer
Row: | Integer
Column: | Integer
Property value: | Long
Limitations: Read only, run time only.


TXTextControl.TableCellStart Property
Description: Returns the character index (one-based) of the first character in a table cell.
Syntax: TXTextControl.TableCellStart(TableId, Row, Column)

Parameter | Description
TableId | Specifies a table. It is the same identifier set with the TableInsert method.
Row, Column | Specify a row and column number which identifies a certain cell in the table. The first has the number 1, 1.
Data Types:
TableId: | Integer
Row: | Integer
Column: | Integer
Property value: | Long
Limitations: Read only, run time only.


TXTextControl.TableCellText Property
Description: Returns or sets the text of a table cell.
Syntax: TXTextControl.TableCellText((TableId, Row, Column) [= string]

Parameter | Description
TableId | Specifies a table. It is the same identifier set with the TableInsert method.
Row, Column | Specify a row and column number which identifies a certain cell in the table. The first has the number 1, 1.
Data Types:
TableId: | Integer
Row: | Integer
Column: | Integer
Property value: | String
Limitations: Run time only.

See also: TableInsert Method, TableRows Property, TableColumns Property.


TXTextControl.TableCreated Event
Description: Occurs after a new table has been created as a result of a text insertion via the clipboard. It does not occur when the table is inserted with the TableInsert method or when a previously saved document is reloaded.
Syntax: TableCreated(TableId, NewTableId)

Parameter | Description
TableId | Is the number of the created table. This number can be changed through setting the NewTableId parameter.
NewTableId | Is a new table identifier for the created table. It must be in the range of 10 to 32,767.
Data Types:
TableId: | Integer
NewTableId: | Integer
See also: TableDeleted Event, TableInsert Method.


TXTextControl.TableDeleted Event
Description: Occurs after a table has been deleted.
Syntax: TableDeleted(TableId)

Parameter | Description
TableId | Is the the identifier of the deleted table.
Data Types: Integer.

See also: TableCreated Event.


TXTextControl.TableDeleteColumn Method
Description: This method deletes the table column with the current input position. A table column can only be deleted if the current input position is in a table and if no text is selected. The TableCanDeleteColumn property informs whether a column can be deleted.
Syntax: TXTextControl.TableDeleteColumn
Return Value: The method returns True if the table column could successfully be deleted. The method returns False if an error has occurred or if the current input position is not within a table.
Data Types:
Return value: Boolean.

See also: TableInsertColumn Method, TableCanDeleteColumn Property.


TXTextControl.TableDeleteLines Method
Description: This method deletes the currently selected table lines or the table line at the current input position.
Syntax: TXTextControl.TableDeleteLines
Return Value: The method returns True if table lines have been deleted. Otherwise it returns False.
Data Types:
Return value: Boolean

See also: TableInsertLines Method, TableCanDeleteLines Property.


TXTextControl.TableColAtInputPos Property
Description: Returns the number of the current input column in a table. It is zero when the input position is not inside a table or when more than one table cell is selected.
Syntax: TXTextControl.TableColAtInputPos
Data Types: Integer.
Limitations: Read only, run time only.

See also: TableAtInputPos Property, TableRowAtInputPos Property.


TXTextControl.TableColumns Property
Description: Informs about the number of columns a specified table contains.
Syntax: TXTextControl.TableColumns(TableId)

Parameter | Description
TableId | Specifies a table. It is the same identifier set with the TableInsert method.
Data Types:
TableId: | Integer
Property value: | Integer
Limitations: Read only, run time only.

See also: TableInsert Method, TableRows Property.


TXTextControl.TableFormatChanged Event
Description: Occurs after a table has been formatted with the built-in mouse-interface.
Syntax: TableFormatChanged(&nbsp)


TXTextControl.TableGetOuter Method
Description: This method returns a table's outer table.
Syntax: TXTextControl.TableGetOuter TableId

Parameter | Description
TableId | Specifies a table identifier. It is the same identifier set with the TableInsert method.
Return Value: Specifies the table identifier of the given table's outer table or zero, if the given table is a top-level table. It is also zero, if the specified table is invalid.
Data Types:
TableId: | Integer
Return value: | Integer
Introduced: 11.0


TXTextControl.TableGetOuterMost Method
Description: This method returns a table's outermost table.
Syntax: TXTextControl.TableGetOuterMost TableId

Parameter | Description
TableId | Specifies a table identifier. It is the same identifier set with the TableInsert method.
Return Value: Specifies the table identifier of the given table's outermost table or zero, if the given table is already a top-level table. It is also zero, if the specified table identifier is invalid.
Data Types:
TableId: | Integer
Return value: | Integer
Introduced: 11.0


TXTextControl.TableGridLines Property
Description: This property determines whether or not grid lines in tables are visible.
Syntax: TXTextControl.TableGridLines [= boolean]

Setting | Description
True | (Default) Grid lines in tables are visible.
False | Grid lines in tables are invisible.
Data Types: Boolean.


TXTextControl.TableInsert Method
Description: This method inserts a new table in the text.
Syntax: TXTextControl.TableInsert Rows, Columns, TextPos [, TableId]

Parameter | Description
Rows | Specifies the number of rows.
Columns | Specifies the number of columns.
TextPos | Specifies the text position where the new table is to be inserted. It is inserted at the current input position when this parameter is set to -1.
TableId | Optional. Specifies a table identifier. This identifier can be used to access or to alter the table's text and attributes. It must be in the range of 10 to 32,767.
Return Value:

Parameter | Description
0 | An error has occurred or the table could not be inserted. Tables cannot be inserted inside existing tables or when a section of text has been selected.
-1 | The new table has been inserted at the top or at the bottom of an existing table and has been combined with this table.
otherwise | The table's identifier. This is the same value as specified with the TableId parameter or an internal identifier selected by Text Control when the optional TableId parameter has been omitted.
Data Types:
Rows: | Integer
Columns: | Integer
TextPos: | Long
TableId: | Integer
Return value: | Integer
See also: TableCanInsert Property, TableDeleteLines Method.


TXTextControl.TableInsertColumn Method
Description: This method inserts a table column left or right of the column with the current input position. A table column can only be inserted if the current input position is in a table and if no text is selected. The TableCanInsertColumn property informs whether a column can be inserted.
Syntax: TXTextControl.TableInsertColumn Position
Parameter Description
Position Specifies where to insert the table column. Possible values are the following:

Constant | Description
txTableInsertInFront (1) | The column is inserted left of the column with the current input position.
txTableInsertAfter (2) | The column is inserted right of the column with the current input position.
Return Value: The method returns True if the table column could successfully be inserted. The method returns False if an error has occurred or if the current input position is not within a table.
Data Types:
Return value: Boolean

See also: TableDeleteColumn Method, TableCanInsertColumn Property.


TXTextControl.TableInsertLines Method
Description: This member function inserts table lines above or below the table line with the current input position. Table lines can only be inserted if the current input position is in a table and if no text is selected. The TableCanInsertLines property informs whether table lines can be inserted.
Syntax: TXTextControl.TableInsertLines Position, Lines
Parameter Description
Position Specifies where to insert the table lines. Possible values are the following:

Constant | Description
txTableInsertInFront (1) | Table lines are inserted above the line with the current input position.
txTableInsertAfter (2) | Table lines are inserted below the line with the current input position.
Lines Specifies the number of lines to insert.
Return Value: The method returns True if the table lines could successfully be inserted. The method returns False if an error has occurred or if the current input position is not within a table.
Data Types:
Return value: Boolean

See also: TableDeleteLines Method, TableCanInsertLines Property.


TXTextControl.TableNestedLevel Property
Description: Gets the nested level for the specified table. Top level tables have a level of 1.
Syntax: TXTextControl.TableNestedLevel(TableId)

Parameter | Description
TableId | Specifies a table. It is the same identifier set with the TableInsert method.
Data Types:
TableId: | Integer
Property value: | Integer
Limitations: Run time only.

Introduced: 11.0


TXTextControl.TableNext Method
Description: This method returns a enumaration number of the table that follows the specified table in the Text Control's current text. It can be used to enumerate all tables. In a list of linked Text Controls the search is performed in all controls. The method uses enumeration numbers instead of table identifiers because table identifiers are not unique. The corresponding table identifer is retrieved by the TableId parameter.
Syntax: TXTextControl.TableNext EnumerationNumber, TableId

Parameter | Description
EnumerationNumber | Specifies a enumeration number. The method returns the enumeration number of the table that follows the table with this number. If this parameter is zero the first table's enumeration number is returned.
TableId | Text Control copies the table's identifier to this variable. This is the same value set with the TableInsert method.
Return Value: Specifies the enumeration number of the next table. It can be used for the next TableNext call. The return value is zero when the last table has been reached or when the specified enumeration number was invalid.
Data Types:
EnumerationNumber: | Integer
TableId: | Integer
Return value: | Integer


TXTextControl.TableRowAtInputPos Property
Description: Returns the number of the current input row in a table. It is zero when the input position is not inside a table or when more than one table cell is selected.
Syntax: TXTextControl.TableRowAtInputPos
Data Types: Integer.

Limitations: Read only, run time only.

See also: TableAtInputPos Property, TableColAtInputPos Property.


TXTextControl.TableRows Property
Description: Informs about the number of rows a specified table contains.
Syntax: TXTextControl.TableRows(TableId)

Parameter | Description
TableId | Specifies a table. It is the same identifier set with the TableInsert method.
Data Types:
TableId: | Integer
Property value: | Integer
Limitations: Read only, run time only.

See also: TableInsert Method, TableColumns Property.


TXTextControl.TableSplit Method
Description: Splits a table below or above the current input position. If the table does not contain the current input position, it cannot be split. The TableCanSplit property can be used to determine whether a table can be split or not. If a table is split above the first row, a new line is inserted above the table and if a table is split below the last row, a new line is inserted below the table. This is useful to insert text above or below a nested table that immediately starts and/or ends at the beginning or the end of the cell in which it is nested.
Syntax: TXTextControl.TableSplit Position
Parameter Description
Position Specifies where to split the table. Possible values are the following:

Constant | Description
txTableInsertInFront (1) | The table is split below the current input position.
txTableInsertAfter (2) | The table is split in front of the current input position.
Return Value: The method returns True, if the table can successfully be split. The method returns False, if an error has occurred or if the current input position is not within a table.
Data Types:
Position | Integer
Return value: | Boolean
Introduced: 11.0
See also: TableCanSplit Property.


TXTextControl.TabPos Property
Description: Determines the position, in twips, of a certain tab. The tab number must have previously been determined with the TabCurrent property.
Syntax: TXTextControl.TabPos [= value]
Data Types: Long.

See also: TabCurrent Property, TabType Property.


TXTextControl.TabType Property
Description: Determines the type of a certain tab. The tab number must have previously been determined with the TabCurrent property.
Syntax: TXTextControl.TabType [= value]

Setting | Description
1 | Left tab.
2 | Right tab.
3 | Centered tab.
4 | Decimal tab.
5 | Right tab at the right most text position. For this type any position set with the TabPos property is ignored.
Data Types: Integer.

See also: TabCurrent Property, TabPos Property.


TXTextControl.Text Property
Description: Returns or sets the complete text of a Text Control. This property is a Text Control's default property.
Syntax: TXTextControl.Text [= string]
Data Types: String.


TXTextControl.TextBkColor Property
Description: Returns or sets the background color for selected text. Text Control uses the Microsoft Windows operating enviroment red-green-blue (RGB) color scheme.
Syntax: TXTextControl.TextBkColor [= value]
Remarks: The TextBkColor property applies only to the currently selected text. The BackColor property can be used to set the window background color. The valid range for a RGB color is 0 to &HFFFFFF. The high byte of a number in this range equals 0; the lower 3 bytes, from least to most significant byte, determine the amount of red, green, and blue, respectively. The red, green, and blue components are each represented by a number between 0 and 255 (&HFF).
Data Types: Long.

See also: FormatSelection Property, BackColor Property.


TXTextControl.TextFrameActivated Event
Description: Occurs when a text frame has obtained the input focus.
Syntax: TextFrameActivated(TextFrameId)

Parameter | Description
TextFrameId | Is the identifier of the activated text frame.
Remarks: The value of the ObjectCurrent property is updated with the identifier given through the TextFrameId parameter.
Data Types:
TextFrameId: Integer

Introduced: 12.0
See also: TextFrameDeactivated Event.


TXTextControl.TextFrameBackColor Property
Description: Returns or sets the background color of a text frame. TX Text Control uses the Microsoft Windows operating enviroment red-green-blue (RGB) color scheme. The ObjectCurrent property determines the text frame.
Syntax: TXTextControl.TextFrameBackColor [= value]

Setting | Description
RGB colors | The valid range for a RGB color is 0 to &HFFFFFF. The high byte of a number in this range equals 0; the lower 3 bytes, from least to most significant byte, determine the amount of red, green, and blue, respectively. The red, green, and blue components are each represented by a number between 0 and 255 (&HFF).
System colors | Colors specified by the system color constants. If the high byte is not 0, TX Text Control uses the system colors, as defined in the user's Control Panel settings.
Data Types: Long.

Limitations: Run time only.

Introduced: 12.0


TXTextControl.TextFrameBorderWidth Property
Description: Specifies the width, in twips, of a text frame's border line. To alter the distance between the border line and the text, use the TextFrameInternalMargin property. The ObjectCurrent property determines the text frame. If this property is set to zero, the text frame has no border line.
Syntax: TXTextControl.TextFrameBorderWidth [= value]
Data Types: Integer.

Limitations: Run time only.

Introduced: 12.0


TXTextControl.TextFrameDeactivated Event
Description: Occurs when a text frame has lost the input focus.
Syntax: TextFrameDeactivated(TextFrameId)

Parameter | Description
TextFrameId | Is the identifier of the deactivated text frame.
Remarks: The value of the ObjectCurrent property is updated with the identifier given through the TextFrameId parameter.
Data Types:
TextFrameId: Integer

Introduced: 12.0
See also: TextFrameActivated Event.


TXTextControl.TextFrameInsert Method
Description: This method inserts a new text frame anchored to a paragraph. The text flows around the text frame.
Syntax: TXTextControl.TextFrameInsert TextPos, Alignment, PosX, PosY, Width, Height, TextFlow, DistanceL, DistanceT, DistanceR, DistanceB
Parameter Description
TextPos Specifies a text position in the paragraph where to insert the text frame. If TextPos is -1, the text frame is anchored to the paragraph at the current input position.
Alignment Specifies the text frame's horizontal alignment. It can be one of the following values:

Value | Description
0 | The horizontal position is given through the PosX parameter.
1 | The text frame is left aligned relative to the paragraph to which it is anchored.
2 | The text frame is right aligned relative to the paragraph to which it is anchored.
3 | The text frame is centered relative to the paragraph to which it is anchored.
PosX Specifies the text frame's horizontal position in twips relative to the left border of the paragraph. This value is used if the Alignment parameter has been set to 0.
PosY Specifies the text frame's vertical position in twips relative to the top border of the paragraph.
Width Specifies the width of the text frame in twips.
Height Specifies the height of the text frame in twips.
TextFlow Specifies how text flows around the text frame. It can be one of the following values:

Value | Description
2 | The text stops at the top and continues at the bottom of the text frame.
3 | The text flows around the text frame. Empty areas at the left and right side are filled.
DistanceL, DistanceT, DistanceR, DistanceB Specifies distances, in twips, between the text frame and the document's text.
Return Value: The method returns the text frame's identifier, if a new text frame could be inserted. Otherwise, it returns zero. The text frame's identifier can also be obtained with the ObjectCurrent property.

Data Types:
TextPos: | Long
Alignment: | Integer
PosX: | Long
PosY: | Long
Width: | Integer
Height: | Integer
TextFlow: | Integer
DistanceL: | Integer
DistanceT: | Integer
DistanceR: | Integer
DistanceB: | Integer
Return value: | Integer
Introduced: 12.0
See also: TextFrameInsertAsChar Method, TextFrameInsertFixed Method, Text frame and object attribute properties.


TXTextControl.TextFrameInsertAsChar Method
Description: This method inserts a new text frame, which is then handled as a single character in the text.
Syntax: TXTextControl.TextFrameInsertAsChar TextPos, Width, Height

Parameter | Description
TextPos | Specifies a text position where the text frame should be inserted. If TextPos is -1, the text frame is inserted at the current input position.
Width | Specifies the width of the text frame in twips.
Height | Specifies the height of the text frame in twips.
Return Value: The method returns the text frame's identifier, if a new text frame could be inserted. Otherwise, it returns zero. The text frame's identifier can also be obtained with the ObjectCurrent property.

Data Types:
TextPos: | Long
Width: | Integer
Height: | Integer
Return value: | Integer
Introduced: 12.0
See also: TextFrameInsert Method, TextFrameInsertFixed Method, Text frame and object attribute properties.


TXTextControl.TextFrameInsertFixed Method
Description: This method inserts a new text frame at a fixed geometrical position. The text flows around the text frame.
Syntax: TXTextControl.TextFrameInsertFixed PageNo, PosX, PosY, Width, Height, TextFlow, DistanceL, DistanceT, DistanceR, DistanceB
Parameter Description
PageNo Specifies the number of the page where the text frame is inserted, beginning with number 1. If the ViewMode property has not been set to Page View or Centered Page View, this parameter must be set to zero. In this case, the PosY parameter specifies the position relative to the top of the control.
PosX Specifies the text frame's horizontal position in twips relative to the left border of the page.
PosY Specifies the text frame's vertical position in twips relative to the top border of the page or control.
Width Specifies the width of the text frame in twips.
Height Specifies the height of the text frame in twips.
TextFlow Specifies how text flows around the text frame. It can be one of the following values:

Value | Description
2 | The text stops at the top and continues at the bottom of the text frame.
3 | The text flows around the text frame. Empty areas at the left and right side are filled.
DistanceL, DistanceT, DistanceR, DistanceB Specifies distances, in twips, between the text frame and the document's text.
Return Value: The method returns the text frame's identifier, if a new text frame could be inserted. Otherwise, it returns zero. The text frame's identifier can also be obtained with the ObjectCurrent property.

Data Types:
PageNo: | Long
PosX: | Long
PosY: | Long
Width: | Integer
Height: | Integer
TextFlow: | Integer
DistanceL: | Integer
DistanceT: | Integer
DistanceR: | Integer
DistanceB: | Integer
Return value: | Integer
Introduced: 12.0
See also: TextFrameInsertAsChar Method, TextFrameInsert Method, Text frame and object attribute properties.


TXTextControl.TextFrameInternalMargin Property
Description: Specifies the distance (in twips) between a text frame's border line and the text. The ObjectCurrent property determines the text frame.
Syntax: TXTextControl.TextFrameInternalMargin(index) [= value]

Parameter | Description
index | Specifies one of the four possible margins: left (1), top (2), right (3), bottom (4).
Data Types: Integer.

Limitations: Run time only.

Introduced: 12.0


TXTextControl.TextFrameMarkerLines Property
Description: This property determines whether or not marker lines for text frames are visible. Marker lines show a text frame's border if the text frame has no border line. A text frame's border line can be set with the TextFrameBorderWidth property.
Syntax: TXTextControl.TextFrameMarkerLines [= boolean]

Setting | Description
True | (Default)Marker lines are visible.
False | Marker lines are invisible.
Data Types: Boolean.

Introduced: 12.0


TXTextControl.TextFrameSelect Method
Description: This method determines whether a certain Text Control property or method manipulates a text frame or the main text. This method selects a text frame for programming. It does not set the input focus to a text frame and does not show the selection frame with the resize handles.
Syntax: TXTextControl.TextFrameSelect TextFrameId

Parameter | Description
TextFrameId | Is the identifier of the text frame to select. It must be an identifier returned through the TextFrameInsert, TextFrameInsertAsChar or TextFrameInsertFixed method. If this parameter is zero, which is the default mode, a Text Control performs automatic selection, which means that a certain property or method manipulates the text part with the current input position. If this parameter is -1, the method selects the main text, which means that a property or method manipulates the main text, independent of which text part has the current input focus.
Return Value: The method returns True, if the selection could be performed, otherwise it returns False.
Remarks: The TX Text Control button bar, ruler and status bar need the default automatic mode for correct working. Therefore, when a selection is no longer needed, it should be reset to the default mode.

Data Types:
TextFrameId: | Integer
Return value: | Boolean
Introduced: 12.0


TXTextControl.Undo Method
Description: This method can be used to undo the last Text Control operation.
Syntax: TXTextControl.Undo
Return Value: The method returns True if the undo operation was successful. Otherwise it returns False.
Data Types:
Return value: Boolean

See also: Redo Method, CanUndo Property, CanRedo Property.


TXTextControl.VExpand Event
Description: Occurs when the Text Control has changed its window size vertically. This event can only occur when the AutoExpand property is set to True.
Syntax: VExpand( )
See also: AutoExpand Property, HExpand Event.


TXTextControl.ViewMode Property
Description: Returns or sets the mode in which Text Control displays its text contents. See Technical Articles - Text Formatting and Views for more information.
Syntax: TXTextControl.ViewMode [= value]

Setting | Description
0 - Normal View | Do not display page borders, margins and gaps.
1 - Page View | Display the document's pages with page margins and show the page number in the status bar.
2 - Centered Page View | Shows the document's pages centered and displays three-dimensional borders.
3 - Floating Text | (Default) The text is formatted depending on the control's window width. Invisible text can be displayed using a vertical scrollbar.
4 - Simple Control | The text is formatted depending on the control's window width and height. There is no scroll interface to scroll to invisible text.
Data Types: Integer.

See also: PageWidth Property, PageHeight Property.


TXTextControl.VScroll Event
Description: Occurs when the vertical scroll position has been changed.
Syntax: VScroll( )
See also: HScroll Event.


TXTextControl.WordWrapMode Property
Description: This property returns or sets the mode how Text Control handles word wrapping in lines without space or other word breaking characters. If a single word is too large to fit in a line Text Control either displays the not fitting characters in the following line or hides these characters and displays an overflow mark (a vertical line).
Syntax: TXTextControl.WordWrapMode [= Mode]

Setting | Description
0 - Line overflow | Hides characters that do not fit on a line and displays an overflow mark.
1 - Word wrapping | (Default) Displays the remaining characters of a word that do not fit on a line, on the next line.
Data Types: Integer.


TXTextControl.XMLEditMode Property
Description: Specifies whether Text Control operates in an edit mode that validates the XML document according to the document's DTD.
Syntax: TXTextControl.XMLEditMode [= value]

Setting | Description
1 - Validation | Every operation that manipulates an XML document is validated according to the document's DTD. This mode is read only and is automatically switched on after loading a valid XML document.
2 - No Validation | Text Control operates in its normal editor mode. No validation of an XML document occurs. Because the document can be invalid after every operation the document cannot be saved in XML format.
Data Types: Integer.

Limitations: Run time only.


TXTextControl.XMLElements Property
Description: Returns a collection of all XML elements with the same tag name.

Syntax: TXTextControl.XMLElements ElementName

Parameter | Description
ElementName | Specifies the name of the XML elements. The returned collection object contains all XML elements with this name.
Data Types: XMLElements Collection object.

Limitations: Read only, run time only.

See also: XMLElements Collection, XMElement Object.


TXTextControl.XMLInvalid Event
Description: Occurs when a loaded XML document cannot be validated with the document type definition (DTD) referenced in the document. The document's contents are loaded but the document itself cannot be handled or saved as XML document.
Syntax: XMLInvalid(FilePos, Scode, Description, CancelDisplay)

Parameter | Description
FilePos | Is the absolute file position where the error occurred.
Scode | Is the OLE Status Code.
Description | Explains the reason for the error. This string can be changed.
CancelDisplay | Can be set to True if the application wants to display its own error string. When this parameter is not set to True, the control will display a message box showing an error string.
Data Types:
FilePos: | Long
Scode: | Long
Description: | String
CancelDisplay: | Boolean


TXTextControl.XMLNotWellFormed Event
Description: Occurs when a loaded XML document is not well-formed. Loading the document has been aborted and the document's contents are not displayed.
Syntax: XMLNotWellFormed(FilePos, LineNumber, LinePos, Scode, Description, URL, CancelDisplay)

Parameter | Description
FilePos | Is the absolute file position in the XML document where the error occurred.
LineNumber | Is the line number in the XML document that contains the error.
LinePos | Is the character position within the line where the error occurred.
Scode | Is the OLE Status Code.
Description | Explains the reason for the error. This string can be changed.
URL | Is the URL of the XML document containing the error. If this parameter is an empty string there is no information about the URL.
CancelDisplay | Can be set to True if the application wants to display its own error string. When this parameter is not set to True, the control will display a message box showing an error string.
Data Types:
FilePos: | Long
LineNumber: | Long
LinePos: | Long
Scode: | Long
Description: | String
URL: | String
CancelDisplay: | Boolean


TXTextControl.Zoomed Event
Description: Occurs when the Text Control has been zoomed.

Syntax: Zoomed( )
See also: ZoomFactor Property.


TXTextControl.ZoomFactor Property
Description: Specifies the zoom factor for a Text Control. The value is specified as a percentage in the range of 10..400%.
Syntax: TXTextControl.ZoomFactor [= value]
Data Types: Integer.

See also: PrintZoom Property.


TXButtonBar Control

A TXButtonBar control represents a button bar for a Text Control. It offers several combo boxes and buttons and can be designed by the programmer.
Syntax: TXButtonBar

Properties
Property | Description
Appearance Returns or sets the paint style of a button bar.

BorderStyle Returns or sets the border style for a button bar.

Enabled Returns or sets a value that determines whether a button bar can respond to user-generated events.

hWnd Returns a handle to a button bar.

Language Determines the language in which button bar displays resources.
PosControlChars Returns or sets the position of the control char button.
PosFontBold Returns or sets the position of the bold button.
PosFontItalic Returns or sets the position of the italic button.
PosFontName Returns or sets the position of the font name combo-box.
PosFontSize Returns or sets the position of the font size combo-box.
PosFontUnderline Returns or sets the position of the underline button.
PosListBulleted Returns or sets the position of the button for bulleted lists.
PosListNumbered Returns or sets the position of the button for numbered lists.
PosParaCentered Returns or sets the position of the button for centering paragraphs.
PosParaJustified Returns or sets the position of the button for justifying paragraphs.
PosParaLeft Returns or sets the position of the button for left aligning paragraphs.
PosParaRight Returns or sets the position of the button for right aligning paragraphs.
PosStyle Returns or sets the position of the formatting styles combobox.
PosTabCentered Returns or sets the position of the button for setting centered tabs.
PosTabDecimal Returns or sets the position of the button for setting decimal tabs.
PosTabLeft Returns or sets the position of the button for setting left aligned tabs.
PosTabRight Returns or sets the position of the button for setting right aligned tabs.
PosTabSelect Returns or sets the position of the button for selecting the tab type.
PosXMLAdd Returns or sets the position of a combobox showing all insertable XML elements.
PosXMLRemove Returns or sets the position of a combobox showing all removeable XML elements.
PosZoom Returns or sets the position of the zoom combobox.
ResourceFile Returns or sets the file name of a resource library which button bar loads to display resources like buttons.
Style Returns or sets the paint style of a button bar's buttons.

Events
Event | Description
MouseDown Occurs when the user presses a mouse button.
MouseMove Occurs when the user moves the mouse.
MouseUp Occurs when the user releases a mouse button.


TXButtonBar.Appearance Property
Description: Returns or sets the paint style of a button bar.

Syntax: TXButtonBar.Appearance [= value]

Setting | Description
0 - txFlat | Flat. Paints the button bar without visual effects.
1 - tx3D | (Default). 3D. Paints the button bar with three-dimensional effects.
2 - txXP | Paints the button bar's buttons in Windows XP look.
Data Types: Integer.


TXButtonBar.BorderStyle Property
Description: Returns or sets the border style for a button bar.

Syntax: TXButtonBar.BorderStyle [= value]

Setting | Description
0 - None | The button bar has no border.
1 - Fixed Single | The button bar has a fixed border.
Data Types: Integer.


TXButtonBar.Enabled Property
Description: Returns or sets a value that determines whether a button bar can respond to user-generated events.

Syntax: TXButtonBar.Enabled [= boolean]

Setting | Description
True | (Default) Allows a button bar to respond to events.
False | Prevents a button bar from responding to events.
Data Types: Boolean.


TXButtonBar.hWnd Property
Description: Returns a handle to a button bar.

Syntax: TXButtonBar.hWnd
Remarks: The hWnd property is used with Windows API calls. Many Windows operating enviroment functions require the hWnd of the active window as an argument.

Data Types: Handle.

Limitations: Read only, run time only.


TXButtonBar.Language Property
Description: Determines the language in which button bar displays resources. The button bar has several built-in languages, additional languages can be added with the ResourceFile property. The default language is the Windows system language. See Technical Articles - Resources for more information.

Syntax: TXButtonBar.Language [= value]

Setting | Description
33 | French
34 | Spanish
39 | Italian
41 | German (Switzerland)
43 | German (Austria)
49 | German
81 | Japanese
else | English
Data Types: Integer.


TXButtonBar.MouseDown Event
Description: Occurs when the user presses a mouse button.
Syntax: TXButtonBar.MouseDown(Button, Shift, X, Y)
Parameter Description
Button Informs which button is pressed. Possible values are the following:

Value | Description
1 | The left button is pressed.
2 | The right button is pressed.
4 | The middle button is pressed.
Shift Informs about the state of the SHIFT, CTRL and ALT keys at the time of the event. It is the sum of one or more of the following values:

Value | Description
1 | The SHIFT key was pressed at the time of the event.
2 | The CTRL key was pressed at the time of the event.
4 | The ALT key was pressed at the time of the event.
X,Y Specifies the current location of the mouse pointer. The coordinates are relative to the upper-left corner of the button bar.
Data Types:
Button: | Integer
Shift: | Integer
X: | Long
Y: | Long
See also: MouseMove Event, MouseUp Event.


TXButtonBar.MouseMove Event
Description: Occurs when the user moves the mouse.
Syntax: TXButtonBar.MouseMove(Button, Shift, X, Y)
Parameter Description
Button Informs about the state of the mouse buttons at the time of the event. It is the sum of one or more of the following values:

Value | Description
1 | The left button is pressed.
2 | The right button is pressed.
4 | The middle button is pressed.
Shift Informs about the state of the SHIFT, CTRL and ALT keys at the time of the event. It is the sum of one or more of the following values:

Value | Description
1 | The SHIFT key was pressed at the time of the event.
2 | The CTRL key was pressed at the time of the event.
4 | The ALT key was pressed at the time of the event.
X,Y Specifies the current location of the mouse pointer. The coordinates are relative to the upper-left corner of the button bar.
Data Types:
Button: | Integer
Shift: | Integer
X: | Long
Y: | Long
See also: MouseDown Event, MouseUp Event.


TXButtonBar.MouseUp Event
Description: Occurs when the user releases a mouse button.
Syntax: TXButtonBar.MouseUp(Button, Shift, X, Y)
Parameter Description
Button Informs which button is pressed. Possible values are the following:

Value | Description
1 | The left button is pressed.
2 | The right button is pressed.
4 | The middle button is pressed.
Shift Informs about the state of the SHIFT, CTRL and ALT keys at the time of the event. It is the sum of one or more of the following values:

Value | Description
1 | The SHIFT key was pressed at the time of the event.
2 | The CTRL key was pressed at the time of the event.
4 | The ALT key was pressed at the time of the event.
X,Y Specifies the current location of the mouse pointer. The coordinates are relative to the upper-left corner of the button bar.
Data Types:
Button: | Integer
Shift: | Integer
X: | Long
Y: | Long
See also: MouseDown Event, MouseMove Event.


TXButtonBar.PosControlChars Property
Description: Returns or sets the position of the control char button. All of the Posxxx properties can be used to configure the order and the appearance of all buttons and comboboxes currently available. The position values are position numbers beginning with number 1. A position number of zero indicates that the button or combo box is currently hidden. To group buttons or combo boxes of similar features, a gap between two elements can be created by adding the constant value 1000 to the position number of a certain button. This creates a gap between the specified element and its preceding element. Adding the constant 2000, creates a gap with a vertical group mark. Vertical group marks are only displayed if the button bar's Style property has been set to txFlat.
Syntax: TXButtonBar.PosControlChars [= position number]
Remarks: The following two list describes which property belongs to which button bar element. The order of the first list is the same order the elements appear by default. The elements of the second list are hidden by default (position number 0):

Property | Element
PosStyle | Defines the position of the formatting styles combobox.
PosFontName | Defines the position of the font name combo-box.
PosFontSize | Defines the position of the font size combo-box.
PosFontBold | Defines the position of the bold button.
PosFontItalic | Defines the position of the italic button.
PosFontUnderline | Defines the position of the underline button.
PosParaLeft | Defines the position of the button for left aligning paragraphs.
PosParaRight | Defines the position of the button for right aligning paragraphs.
PosParaCentered | Defines the position of the button for centering paragraphs.
PosParaJustified | Defines the position of the button for justifying paragraphs.
PosListNumbered | Defines the position of the button for numbered lists.
PosListBulleted | Defines the position of the button for bulleted lists.
PosTabSelect | Defines the position of the button for selecting the tab type.
PosControlChars | Defines the position of the control char button.
Property | Element
PosTabLeft | Defines the position of the button for setting left aligned tabs.
PosTabRight | Defines the position of the button for setting right aligned tabs.
PosTabCentered | Defines the position of the button for setting centered tabs.
PosTabDecimal | Defines the position of the button for setting decimal tabs.
PosXMLAdd | Defines the position of a combobox showing all insertable XML elements. Can be used only with XML documents.
PosXMLRemove | Defines the position of a combobox showing all removeable XML elements. Can be used only with XML documents.
PosZoom | Defines the position of the zoom combobox.
Data Types: Integer.


TXButtonBar.PosFontBold Property
Description: Returns or sets the position of the bold button. See the PosControlChars property for more information.
Syntax: TXButtonBar.PosFontBold [= position number]


TXButtonBar.PosFontItalic Property
Description: Returns or sets the position of the italic button. See the PosControlChars property for more information.
Syntax: TXButtonBar.PosFontItalic [= position number]


TXButtonBar.PosFontName Property
Description: Returns or sets the position of the font name combo-box. See the PosControlChars property for more information.
Syntax: TXButtonBar.PosFontName [= position number]


TXButtonBar.PosFontSize Property
Description: Returns or sets the position of the font size combo-box. See the PosControlChars property for more information.
Syntax: TXButtonBar.PosFontSize [= position number]


TXButtonBar.PosFontUnderline Property
Description: Returns or sets the position of the underline button. See the PosControlChars property for more information.
Syntax: TXButtonBar.PosFontUnderline [= position number]


TXButtonBar.PosListBulleted Property
Description: Returns or sets the position of the button for bulleted lists. See the PosControlChars property for more information.
Syntax: TXButtonBar.PosListBulleted [= position number]


TXButtonBar.PosListNumbered Property
Description: Returns or sets the position of the button for numbered lists. See the PosControlChars property for more information.
Syntax: TXButtonBar.PosListNumbered [= position number]


TXButtonBar.PosParaCentered Property
Description: Returns or sets the position of the button for centering paragraphs. See the PosControlChars property for more information.
Syntax: TXButtonBar.PosParaCentered [= position number]


TXButtonBar.PosParaJustified Property
Description: Returns or sets the position of the button for justifying paragraphs. See the PosControlChars property for more information.
Syntax: TXButtonBar.PosParaJustified [= position number]


TXButtonBar.PosParaLeft Property
Description: Returns or sets the position of the button for left aligning paragraphs. See the PosControlChars property for more information.
Syntax: TXButtonBar.PosParaLeft [= position number]


TXButtonBar.PosParaRight Property
Description: Returns or sets the position of the button for right aligning paragraphs. See the PosControlChars property for more information.
Syntax: TXButtonBar.PosParaRight [= position number]


TXButtonBar.PosStyle Property
Description: Returns or sets the position of the formatting styles combobox. See the PosControlChars property for more information.
Syntax: TXButtonBar.PosStyle [= position number]


TXButtonBar.PosTabCentered Property
Description: Returns or sets the position of the button for setting centered tabs. See the PosControlChars property for more information.
Syntax: TXButtonBar.PosTabCentered [= position number]


TXButtonBar.PosTabDecimal Property
Description: Returns or sets the position of the button for setting decimal tabs. See the PosControlChars property for more information.
Syntax: TXButtonBar.PosTabDecimal [= position number]


TXButtonBar.PosTabLeft Property
Description: Returns or sets the position of the button for setting left aligned tabs. See the PosControlChars property for more information.
Syntax: TXButtonBar.PosTabLeft [= position number]


TXButtonBar.PosTabRight Property
Description: Returns or sets the position of the button for setting right aligned tabs. See the PosControlChars property for more information.
Syntax: TXButtonBar.PosTabRight [= position number]


TXButtonBar.PosTabSelect Property
Description: Returns or sets the position of the button for selecting the tab type. See the PosControlChars property for more information.
Syntax: TXButtonBar.PosTabSelect [= position number]


TXButtonBar.PosXMLAdd Property
Description: Returns or sets the position of a combobox showing all insertable XML elements. It can be used only with XML documents. See the PosControlChars property for more information.
Syntax: TXButtonBar.PosXMLAdd [= position number]


TXButtonBar.PosXMLRemove Property
Description: Returns or sets the position of a combobox showing all removeable XML elements. Can be used only with XML documents. See the PosControlChars property for more information.
Syntax: TXButtonBar.PosXMLRemove [= position number]


TXButtonBar.PosZoom Property
Description: Returns or sets the position of the zoom combobox. See the PosControlChars property for more information.
Syntax: TXButtonBar.PosZoom [= position number]


TXButtonBar.ResourceFile Property
Description: Returns or sets the file name of a resource library which button bar loads to display resources like buttons. The file name must include a complete path. When a resource library is set, the value of the Language property is ignored. See the chapter Technical Articles - Resources for more information. To avoid compatibility errors, resource libraries should have a unique file name and should be placed in the same directory as the application's executable file.

Syntax: TXButtonBar.ResourceFile [= string]
Data Types: String.

Limitations: Run time only.

See also: Language Property.


TXButtonBar.Style Property
Description: Returns or sets the paint style of a button bar's buttons.

Syntax: TXButtonBar.Style [= value]

Setting | Description
0 - txFlat | Flat. Paints the button bar's buttons without visual effects.
1 - tx3D | (Default) 3D. Paints the button bar's buttons with three-dimensional effects.
2 - txXP | Paints the button bar's buttons in Windows XP look.
Data Types: Integer.


TXRulerBar Control

A TXRulerBar control represents a ruler bar for a Text Control. It cab be used to set paragraph attributes like indents and tabulators and the horizontal alignment of table cells.
Syntax: TXRulerBar

Properties
Property | Description
Appearance Returns or sets the paint style of a ruler bar.
BorderStyle Returns or sets the border style for a ruler bar.
Enabled Returns or sets a value that determines whether a ruler bar can respond to user-generated events.
hWnd Returns a handle to a ruler bar.
Language Determines the language in which resources are displayed.
ResourceFile Returns or sets the file name of a resource library which are loaded to display resources.
ScaleUnits Returns or sets the scale units for the ruler.

Events
Event | Description
MouseDown Occurs when the user presses a mouse button.
MouseMove Occurs when the user moves the mouse.
MouseUp Occurs when the user releases a mouse button.


TXRulerBar.Appearance Property
Description: Returns or sets the paint style of a ruler bar.
Syntax: TXRulerBar.Appearance [= value]

Setting | Description
0 - txFlat | Flat. Paints the ruler bar in a flat design.
1 - tx3D | (Default). 3D. Paints the ruler bar with three-dimensional effects.
2 - txXP | Paints the ruler bar in Windows XP look.
Data Types: Integer.


TXRulerBar.BorderStyle Property
Description: Returns or sets the border style for a ruler bar.
Syntax: TXRuler.BorderStyle [= value]

Setting | Description
0 - None | The ruler bar has no border.
1 - Fixed Single | The ruler bar has a fixed border.
Data Types: Integer.


TXRulerBar.Enabled Property
Description: Returns or sets a value that determines whether a ruler bar can respond to user-generated events.
Syntax: TXRuler.Enabled [= boolean]

Setting | Description
True | (Default) Allows a ruler bar to respond to events.
False | Prevents a ruler bar from responding to events.
Data Types: Boolean.


TXRulerBar.hWnd Property
Description: Returns a handle to a ruler bar.
Syntax: TXRuler.hWnd
Remarks: The hWnd property is used with Windows API calls. Many Windows operating enviroment functions require the hWnd of the active window as an argument.
Data Types: Handle.

Limitations: Read only, run time only.


TXRulerBar.Language Property
Description: Determines the language in which resources are displayed. There are several built-in languages, additional languages can be added with the ResourceFile property. The default language is the Windows system language. See Technical Articles - Resources for more information.
Syntax: TXRuler.Language [= value]

Setting | Description
33 | French
34 | Spanish
39 | Italian
41 | German (Switzerland)
43 | German (Austria)
49 | German
81 | Japanese
else | English
Data Types: Integer.


TXRulerBar.ResourceFile Property
Description: Returns or sets the file name of a resource library which are loaded to display resources. The file name must include a complete path. When a resource library is set, the value of the Language property is ignored. See the chapter Technical Articles - Resources for more information. To avoid compatibility errors, resource libraries should have a unique file name and should be placed in the same directory as the application's executable file.
Syntax: TXRuler.ResourceFile [= string]
Data Types: String.

Limitations: Run time only.

See also: Language Property.


TXRulerBar.ScaleUnits Property
Description: Returns or sets the scale units for the ruler.
Syntax: TXRulerBar.ScaleUnits [= value]

Setting | Description
0 | mm
1 | cm
2 | inch
Data Types: Integer.


TXRulerBar.MouseDown Event
Description: Occurs when the user presses a mouse button.
Syntax: TXRulerBar.MouseDown(Button, Shift, X, Y)
Parameter Description
Button Informs which button is pressed. Possible values are the following:

Value | Description
1 | The left button is pressed.
2 | The right button is pressed.
4 | The middle button is pressed.
Shift Informs about the state of the SHIFT, CTRL and ALT keys at the time of the event. It is the sum of one or more of the following values:

Value | Description
1 | The SHIFT key was pressed at the time of the event.
2 | The CTRL key was pressed at the time of the event.
4 | The ALT key was pressed at the time of the event.
X,Y Specifies the current location of the mouse pointer. The coordinates are relative to the upper-left corner of the ruler bar.
Data Types:
Button: | Integer
Shift: | Integer
X: | Long
Y: | Long
See also: MouseMove Event, MouseUp Event.


TXRulerBar.MouseMove Event
Description: Occurs when the user moves the mouse.
Syntax: TXRulerBar.MouseMove(Button, Shift, X, Y)
Parameter Description
Button Informs about the state of the mouse buttons at the time of the event. It is the sum of one or more of the following values:

Value | Description
1 | The left button is pressed.
2 | The right button is pressed.
4 | The middle button is pressed.
Shift Informs about the state of the SHIFT, CTRL and ALT keys at the time of the event. It is the sum of one or more of the following values:

Value | Description
1 | The SHIFT key was pressed at the time of the event.
2 | The CTRL key was pressed at the time of the event.
4 | The ALT key was pressed at the time of the event.
X,Y Specifies the current location of the mouse pointer. The coordinates are relative to the upper-left corner of the ruler bar.
Data Types:
Button: | Integer
Shift: | Integer
X: | Long
Y: | Long
See also: MouseDown Event, MouseUp Event.


TXRulerBar.MouseUp Event
Description: Occurs when the user releases a mouse button.
Syntax: TXRulerBar.MouseUp(Button, Shift, X, Y)
Parameter Description
Button Informs which button is pressed. Possible values are the following:

Value | Description
1 | The left button is pressed.
2 | The right button is pressed.
4 | The middle button is pressed.
Shift Informs about the state of the SHIFT, CTRL and ALT keys at the time of the event. It is the sum of one or more of the following values:

Value | Description
1 | The SHIFT key was pressed at the time of the event.
2 | The CTRL key was pressed at the time of the event.
4 | The ALT key was pressed at the time of the event.
X,Y Specifies the current location of the mouse pointer. The coordinates are relative to the upper-left corner of the ruler bar.
Data Types:
Button: | Integer
Shift: | Integer
X: | Long
Y: | Long
See also: MouseDown Event, MouseMove Event.


TXStatusBar Control

A TXStatusBar control represents a status bar for a Text Control. It shows the page, line and column number of the current text input position, the zoom factor and some key states. Furthermore it can display an info text.
Syntax: TXStatusBar

Properties
Property | Description
BorderStyle Returns or sets the border style for a status bar.
Enabled Returns or sets a value that determines whether a status bar can respond to user-generated events.
FontBold Returns or sets the bold font style.
FontItalic Returns or sets the italic font style.
FontName Returns or sets the font used to display text.
FontSize Returns or sets the pointsize, in twips, of the font used to display text.
FontStrikethru Returns or sets the strikethru font style.
FontUnderline Returns or sets the underline font style.
hWnd Returns a handle to a status bar.
Language Determines the language in which a status bar displays resources.
PageMode Returns or sets the status of the StatusBar's 'Page' field.
ResourceFile Returns or sets the file name of a resource library which status bar loads to display resources.
Text Returns or sets the info text of a status bar.
TextColumn Returns or sets the text which appears in the Column field in front of the column number.
TextLine Returns or sets the text which appears in the Line field in front of the line number.
TextPage Returns or sets the text which appears in the Page field in front of the page number.

Events
Event | Description
MouseDown Occurs when the user presses a mouse button.
MouseMove Occurs when the user moves the mouse.
MouseUp Occurs when the user releases a mouse button.


TXStatusBar.BorderStyle Property
Description: Returns or sets the border style for a status bar.
Syntax: TXStatusBar.BorderStyle [= value]

Setting | Description
0 - None | The status bar has no border.
1 - Fixed Single | The status bar has a fixed border.
Data Types: Integer.


TXStatusBar.Enabled Property
Description: Returns or sets a value that determines whether a status bar can respond to user-generated events.
Syntax: TXStatusBar.Enabled [= boolean]

Setting | Description
True | (Default) Allows a status bar to respond to events.
False | Prevents a status bar from responding to events.
Data Types: Boolean.


TXStatusBar.FontBold Property
Description: Returns or sets the bold font style.
Syntax: TXStatusBar.FontBold [= value]

Setting | Description
0 | The characters are not formatted with the bold font style.
1 | The characters are formatted with the bold font style.
Data Types: Integer.

See also: FontName Property, FontSize Property.


TXStatusBar.FontName Property
Description: Returns or sets the font used to display text.
Syntax: TXStatusBar.FontName [= string]
Data Types: String.

See also: FontSize Property.


TXStatusBar.FontSize Property
Description: Returns or sets the pointsize, in twips, of the font used to display text.
Syntax: TXStatusBar.FontSize [= value]
Data Types: Integer.

See also: FontName Property.


TXStatusBar.FontItalic Property
Description: Returns or sets the italic font style.
Syntax: TXStatusBar.FontItalic [= value]

Setting | Description
0 | The characters are not formatted with the italic font style.
1 | The characters are formatted with the italic font style.
Data Types: Integer.

See also: FontName Property, FontSize Property.


TXStatusBar.FontStrikethru Property
Description: Returns or sets the strikethru font style.
Syntax: TXStatusBar.FontStrikethru [= value]

Setting | Description
0 | The characters are not formatted with the strikethru font style.
1 | The characters are formatted with the strikethru font style.
Data Types: Integer.

See also: FontName Property, FontSize Property.


TXStatusBar.FontUnderline Property
Description: Returns or sets the underline font style.
Syntax: TXStatusBar.FontUnderline [= value]

Setting | Description
0 | The characters are not formatted with the underline font style.
1 | The characters are formatted with the underline font style.
Data Types: Integer.

See also: FontName Property, FontSize Property.


TXStatusBar.hWnd Property
Description: Returns a handle to a status bar.
Syntax: TXStatusBar.hWnd
Remarks: The hWnd property is used with Windows API calls. Many Windows operating enviroment functions require the hWnd of the active window as an argument.
Data Types: Handle.

Limitations: Read only, run time only.


TXStatusBar.Language Property
Description: Determines the language in which a status bar displays resources. The status bar has several built-in languages, additional languages can be added with the ResourceFile property. The default language is the Windows system language. See Technical Articles - Resources for more information.
Syntax: TXStatusBar.Language [= value]

Setting | Description
33 | French
34 | Spanish
39 | Italian
41 | German (Switzerland)
43 | German (Austria)
49 | German
81 | Japanese
else | English
Data Types: Integer.


TXStatusBar.MouseDown Event
Description: Occurs when the user presses a mouse button.
Syntax: TXStatusBar.MouseDown(Button, Shift, X, Y)
Parameter Description
Button Informs which button is pressed. Possible values are the following:

Value | Description
1 | The left button is pressed.
2 | The right button is pressed.
4 | The middle button is pressed.
Shift Informs about the state of the SHIFT, CTRL and ALT keys at the time of the event. It is the sum of one or more of the following values:

Value | Description
1 | The SHIFT key was pressed at the time of the event.
2 | The CTRL key was pressed at the time of the event.
4 | The ALT key was pressed at the time of the event.
X,Y Specifies the current location of the mouse pointer. The coordinates are relative to the upper-left corner of the status bar.
Data Types:
Button: | Integer
Shift: | Integer
X: | Long
Y: | Long
See also: MouseMove Event, MouseUp Event.


TXStatusBar.MouseMove Event
Description: Occurs when the user moves the mouse.
Syntax: TXStatusBar.MouseMove(Button, Shift, X, Y)
Parameter Description
Button Informs about the state of the mouse buttons at the time of the event. It is the sum of one or more of the following values:

Value | Description
1 | The left button is pressed.
2 | The right button is pressed.
4 | The middle button is pressed.
Shift Informs about the state of the SHIFT, CTRL and ALT keys at the time of the event. It is the sum of one or more of the following values:

Value | Description
1 | The SHIFT key was pressed at the time of the event.
2 | The CTRL key was pressed at the time of the event.
4 | The ALT key was pressed at the time of the event.
X,Y Specifies the current location of the mouse pointer. The coordinates are relative to the upper-left corner of the status bar.
Data Types:
Button: | Integer
Shift: | Integer
X: | Long
Y: | Long
See also: MouseDown Event, MouseUp Event.


TXStatusBar.MouseUp Event
Description: Occurs when the user releases a mouse button.
Syntax: TXStatusBar.MouseUp(Button, Shift, X, Y)
Parameter Description
Button Informs which button is pressed. Possible values are the following:

Value | Description
1 | The left button is pressed.
2 | The right button is pressed.
4 | The middle button is pressed.
Shift Informs about the state of the SHIFT, CTRL and ALT keys at the time of the event. It is the sum of one or more of the following values:

Value | Description
1 | The SHIFT key was pressed at the time of the event.
2 | The CTRL key was pressed at the time of the event.
4 | The ALT key was pressed at the time of the event.
X,Y Specifies the current location of the mouse pointer. The coordinates are relative to the upper-left corner of the status bar.
Data Types:
Button: | Integer
Shift: | Integer
X: | Long
Y: | Long
See also: MouseDown Event, MouseMove Event.


TXStatusBar.PageMode Property
Description: Returns or sets the status of the StatusBar's 'Page' field.
Syntax: TXStatusBar.PageMode [= value]

Setting | Description
0 | The 'Page' field is hidden.
1 | The 'Page' field is always shown.
2 | The 'Page' field is only shown if the connected Text-Contol's ViewMode property has been set to Page View or Centered Page View.
Data Types: Integer.


TXStatusBar.ResourceFile Property
Description: Returns or sets the file name of a resource library which status bar loads to display resources. The file name must include a complete path. When a resource library is set, the value of the Language property is ignored. See the chapter Technical Articles - Resources for more information. To avoid compatibility errors, resource libraries should have a unique file name and should be placed in the same directory as the application's executable file.
Syntax: TXStatusBar.ResourceFile [= string]
Data Types: String.

Limitations: Run time only.

See also: Language Property.


TXStatusBar.Text Property
Description: Returns or sets the info text of a status bar.
Syntax: TXStatusBar.Text [= string]
Data Types: String.


TXStatusBar.TextColumn Property
Description: Returns or sets the text which appears in the Column field in front of the column number.
Syntax: TXStatusBar.TextColumn [= string]
Data Types: String.


TXStatusBar.TextLine Property
Description: Returns or sets the text which appears in the Line field in front of the line number.
Syntax: TXStatusBar.TextLine [= string]
Data Types: String.


TXStatusBar.TextPage Property
Description: Returns or sets the text which appears in the Page field in front of the page number.
Syntax: TXStatusBar.TextPage [= string]
Data Types: String.


Style Object

A Style object is an OLE Automation object that represents a formatting style. To get a style or to iterate through all existing styles the Styles collection object can be used. A Style object has the following class name that can be used to create a new object with the CreateObject function:

TIS.TX.Style.12

A Style object has properties to set or to get attributes for fonts and paragraphs, frames, tabs and list settings. For paragraph-based styles all settings are possible, for character-based styles paragraph, tab and list settings cannot be used. The style's type can be obtained with the StyleType property.
Syntax: Style

Properties
Property | Description
Alignment Returns or sets the formatting style's text alignment.
Baseline Returns or sets the formatting style's baseline alignment.
BaselineType Returns or sets the formatting style's baseline type.
BulletAttribute This property returns or sets attributes for bulleted lists.
FontBold Returns or sets the formatting style's font bold attribute.
FontItalic Returns or sets the formatting style's font italic attribute.
FontName Returns or sets the formatting style's font.
FontSize Returns or sets the formatting style's font size, in twips.
FontStrikethru Returns or sets the formatting style's font strikethru attribute.
FontUnderline Returns or sets the formatting style's underlining attributes.
ForeColor Returns or sets the formatting style's text color.
FrameDistance Returns or sets the distance between the text and the frame of a paragraph, in twips.
FrameLineWidth Returns or sets the line width of a paragraph's frame, in twips.
FrameStyle Returns or sets the style of a paragraph's frame.
IndentB Returns or sets the formatting style's additional bottom distance for a paragraph, in twips.
IndentFL Returns or sets the formatting style's additional indent for the first line of a paragraph, in twips.
IndentL Returns or sets the formatting style's left paragraph indent, in twips.
IndentR Returns or sets the formatting style's right paragraph indent, in twips.
IndentT Returns or sets the formatting style'additional top distance for a paragraph, in twips.
LineSpacing Returns or sets the formatting style's line spacing in percent.
LineSpacingT Returns or sets the formatting style's line spacing, in twips.
ListType Returns or sets the formatting style's list type.
NextParaStyle Returns or sets the name of the style used after the user has pressed the RETURN key.
NumberingAttribute This property returns or sets attributes for numbered lists.
StyleName Returns or sets the formatting style's name.
StyleType Returns the formatting style's type.

TabPos Returns or sets the formatting style's tabulator position, in twips.
TabType Returns or sets the formatting style's tabulator type.
TextBkColor Returns or sets the formatting style's text background color.

Methods
Method | Description
Apply Applies all style settings on the current document.


Style.Apply Method
Description: Applies all style settings on the current document.
Syntax: Style.Apply
Remarks: This method applies alls settings made since the previous Apply call or since object creation.


Style.Alignment Property
Description: Returns or sets the formatting style's text alignment.
Syntax: Style.Alignment [= value]

Setting | Description
1 | The text is left aligned.
2 | The text is right aligned.
3 | Text is centered.
4 | The text is centered.
Data Types: Integer.

Limitations: Run time only.


Style.Baseline Property
Description: Returns or sets the formatting style's baseline alignment. The BaselineType property determines if this property is interpreted as super- or subscript.
Syntax: Style.Baseline [= value]
Data Types: Integer.

Limitations: Run time only.


Style.BaselineType Property
Description: Returns or sets the formatting style's baseline type. For character-based styles this property can be zero to indicate that the baseline alignment is inherited from the paragraph.
Syntax: Style.BaselineType [= value]

Setting | Description
2 | The baseline alignment is normal, neither super- nor subscript.
4 | The baseline alignment is superscript.
8 | The baseline alignment is subscript.
Data Types: Integer.

Limitations: Run time only.


Style.BulletAttribute Property
Description: This property returns or sets attributes for bulleted lists. A new attribute set with this property has only effect when the ListType property has previously been set to txListBulleted.
Syntax: Style.BulletAttribute(Attribute) [= value]
Remarks: This property's parameter and settings are the same as for TXTextControl.BulletAttribute.


Style.FontBold Property
Description: Returns or sets the formatting style's font bold attribute.
Syntax: Style.FontBold [= value]

Setting | Description
0 | The text is not formatted with the font bold attribute.
1 | The text is formatted with the font bold attribute.
2 | Indicates that the font bold attribute is inherited from the paragraph's style. This value is possible only for character-based styles.
Data Types: Integer.

Limitations: Run time only.


Style.FontItalic Property
Description: Returns or sets the formatting style's font italic attribute.
Syntax: Style.FontItalic [= value]

Setting | Description
0 | The text is not formatted with the font italic attribute.
1 | The text is formatted with the font italic attribute.
2 | Indicates that the font italic attribute is inherited from the paragraph's style. This value is possible only for character-based styles.
Data Types: Integer.

Limitations: Run time only.


Style.FontName Property
Description: Returns or sets the formatting style's font. For character-based styles this can be an empty string to indicate that the font is inherited from the paragraph style.
Syntax: Style.FontName [= FontName]
Data Types: String.

Limitations: Run time only.


Style.FontSize Property
Description: Returns or sets the formatting style's font size, in twips. For characterbased styles it can be zero to indicate that the font is inherited from the paragraph style.
Syntax: Style.FontSize [= value]
Data Types: Integer.

Limitations: Run time only.


Style.FontStrikethru Property
Description: Returns or sets the formatting style's font strikethru attribute.
Syntax: Style.FontStrikethru [= value]

Setting | Description
0 | The text is not formatted with the font strikethru attribute.
1 | The text is formatted with the font strikethru attribute.
2 | Indicates that the font strikethru attribute is inherited from the paragraph's style. This value is possible only for character-based styles.
Data Types: Integer.

Limitations: Run time only.


Style.FontUnderline Property
Description: Returns or sets the formatting style's underlining attributes.
Syntax: Style.FontUnderline [= value]

Setting | Description
0 | The text is not underlined.
&H1 | The text is single underlined.
&H2 | The text is double underlined.
&H4 | Only words are underlined. This value is possible only in combination with single or double underlined.
&H8 | The text is underlined with a red zigzag line.
&H10 | Indicates that the underlining attribute is inherited from the paragraph's style. This value is possible only for character-based styles.
Data Types: Integer.

Limitations: Run time only.


Style.ForeColor Property
Description: Returns or sets the formatting style's text color. Text Control uses the Microsoft Windows operating enviroment red-green-blue (RGB) color scheme.
Syntax: Style.ForeColor [= value]

Setting | Description
0 to &HFFFFFF | These values are interpreted as RGB values.
&H40000000 | The style uses the system color for the window text.
&H80000000 | The text color is inherited from the paragraph. This value is only possible for character-based styles.
Data Types: Long.

Limitations: Run time only.


Style.FrameDistance Property
Description: Returns or sets the distance between the text and the frame of a paragraph, in twips.
Syntax: Style.FrameDistance [= value]
Data Types: Integer.

Limitations: Run time only.


Style.FrameLineWidth Property
Description: Returns or sets the line width of a paragraph's frame, in twips.
Syntax: Style.FrameLineWidth [= value]
Data Types: Integer.

Limitations: Run time only.


Style.FrameStyle Property
Description: Returns or sets the style of a paragraph's frame. Possible values are the same as described for TXTextControl.FrameStyle property.
Syntax: Style.FrameStyle [= value]
Data Types: Long.

Limitations: Run time only.


Style.IndentB Property
Description: Returns or sets the formatting style's additional bottom distance for a paragraph, in twips.
Syntax: Style.IndentB [= value]
Data Types: Integer.

Limitations: Run time only.


Style.IndentFL Property
Description: Returns or sets the formatting style's additional indent for the first line of a paragraph, in twips. This value can be negative.
Syntax: Style.IndentFL [= value]
Data Types: Integer.

Limitations: Run time only.


Style.IndentL Property
Description: Returns or sets the formatting style's left paragraph indent, in twips.
Syntax: Style.IndentL [= value]
Data Types: Integer.

Limitations: Run time only.


Style.IndentR Property
Description: Returns or sets the formatting style's right paragraph indent, in twips.
Syntax: Style.IndentR [= value]
Data Types: Integer.

Limitations: Run time only.


Style.IndentT Property
Description: Returns or sets the formatting style'additional top distance for a paragraph, in twips.
Syntax: Style.IndentT [= value]
Data Types: Integer.

Limitations: Run time only.


Style.LineSpacing Property
Description: Returns or sets the formatting style's line spacing in percent.
Syntax: Style.LineSpacing [= value]
Data Types: Integer.

Limitations: Run time only.


Style.LineSpacingT Property
Description: Returns or sets the formatting style's line spacing, in twips.
Syntax: Style.LineSpacingT [= value]
Data Types: Integer.

Limitations: Run time only.


Style.ListType Property
Description: Returns or sets the formatting style's list type. Attributes for bulleted lists can be set with the BulletAttribute property and attributes for numbered lists can be set with the NumberingAttribute property.
Syntax: Style.ListType [= Type]

Setting | Description
txListNone (1) | Resets paragraphs with bulleted or numbered list attributes to paragraphs without such features.
txListBulleted (2) | Defines a list with bullets.
txListNumbered (4) | Defines a numbered list.
Data Types: Integer.

Limitations: Run time only.


Style.NextParaStyle Property
Description: Returns or sets the name of the style used after the user has pressed the RETURN key.
Syntax: Style.NextParaStyle [= StyleName]
Data Types: String.

Limitations: Run time only.


Style.NumberingAttribute Property
Description: This property returns or sets attributes for numbered lists. A new attribute set with this property has only effect when the ListType property has previously been set to txListNumbered.
Syntax: Style.NumberingAttribute(Attribute) [= value]
Remarks: This property's parameter and settings are the same as for TXTextControl.NumberingAttribute.
Limitations: Run time only.


Style.StyleName Property
Description: Returns or sets the formatting style's name. For XML documents this property is read-only.
Syntax: Style.StyleName [= StyleName]
Data Types: String.

Limitations: Run time only.


Style.StyleType Property
Description: Returns the formatting style's type.

Syntax: Style.StyleType

Setting | Description
1 | The style is paragraph-based.
2 | The style is character-based.
Data Types: Integer.

Limitations: Read only, Run time only.


Style.TabPos Property
Description: Returns or sets the formatting style's tabulator position, in twips.
Syntax: Style.TabPos(Index) [= value]

Parameter | Description
Index | Specifies a tabulator index. It must be between 1 and 14.
Data Types:
Index: | Integer
Property value: | Integer
Limitations: Run time only.


Style.TabType Property
Description: Returns or sets the formatting style's tabulator type.
Syntax: Style.TabType(Index) [= value]

Parameter | Description
Index | Specifies a tabulator index. It must be between 1 and 14.
Constants: Valid constants for the property value are:

Constant | Description
1 | Left tab.
2 | Right tab.
3 | Centered tab.
4 | Decimal tab.
5 | Right tab at the right most text position. For this type any position set with the TabPos property is ignored.
Data Types:
Index: | Integer
Property value: | Integer
Limitations: Run time only.


Style.TextBkColor Property
Description: Returns or sets the formatting style's text background color. Text Control uses the Microsoft Windows operating enviroment red-green-blue (RGB) color scheme.
Syntax: Style.TextBkColor [= value]

Setting | Description
0 to &HFFFFFF | These values are interpreted as RGB values.
&H40000000 | The style uses the system color for the window background.
&H50000000 | The style uses the control's background color.
&H80000000 | The text background color is inherited from the paragraph. This value is only possible for character-based styles.
Data Types: Long.

Limitations: Run time only.


Styles Collection Object

A Styles collection object is an OLE Automation object whose members represent all formatting styles a Text Control document contains. The members of a Styles collection object are OLE Automation objects of the Style class. A Styles collection object can be obtained with the TXTextControl.Styles property.
Syntax: Styles

Properties
Property | Description
Count Returns the number of Style objects in the collection which is the number of formatting styles contained in a Text Control document.

Methods
Method | Description
Item Returns a specific Style object of a Styles collection.


Styles.Count Property
Description: Returns the number of Style objects in the collection which is the number of formatting styles contained in a Text Control document.
Syntax: Styles.Count
Data Types: Long.

Limitations: Run time only.

See also: Styles.Item Method, TextControl.Styles Property.


Styles.Item Method
Description: Returns a specific Style object of a Styles collection.
Syntax: Styles.Item StyleName

Parameter | Description
StyleName | Specifies the name of the style. If this value does not match any existing member of the collection, an error occurs.
Return Value: The method returns a Style object.

Data Types:
StyleName: | String
Return value: | Style Object
Limitations: Run time only.

Example: The first of the following Basic examples displays the name of the font used with the Headline formatting style. The second enumerates the names of all styles and its fonts in a document:
MsgBox TXTextControl1.Styles.Item("Headline").FontName

For Each style In TXTextControl1.Styles
   Debug.Print "Style name: " &amp; style &amp; ", Font name: " &amp; style.FontName
Next
See also: Style Object.


XMLElement Object

An XMLElement object is an OLE Automation object that represents an element in an XML document. To iterate through all existing XML elements the XMLElements collection object can be used. An XMLElement object has the following class name that can be used to create a new object with the CreateObject function:

TIS.TX.XMLElement.12
Syntax: XMLElement

Properties
Property | Description
AutoSelect Determines whether the text of a newly added XML element is automatically selected.
AutoText Determines whether text is automatically created for a newly added XML element that has no text contents.
ElementName Returns or sets the XML element's name.
Text Returns or sets the text belonging to an XML element.

Methods
Method | Description
AddChild Adds a new XMLElement object as a sub-element of this element.
ChildItem Returns an XMLElement object that is a child element of this element.
RemoveChild Removes a sub-element from this element.
Select Selects the text of the XML element.


XMLElement.AddChild Method
Description: Adds a new XMLElement object as a sub-element of this element. The new element is placed at the position specified through the document's DTD. If this element can have more than one child of the specified type the before or after parameters can be used to specify a position.
Syntax: XMLElement.AddChild XMLElement[, before][, after]

Parameter | Description
XMLElement | Specifies an XMLElement object.
before | Optional. Specifies a relative position in the list of child elements of the specified type. The XML element to be added is placed before the child identified by the before parameter. You can specify before or after positions but not both.
after | Optional. Specifies a relative position in the list of child elements of the specified type. The XML element to be added is placed after the child identified by the after parameter. You can specify before or after positions but not both.
Return Value: The method returns one of the following values:

Value | Description
0 | An error has occurred.
1 | The new element could not be added because the document becomes invalid according to the document's DTD. In this case Text Control fires an XMLInvalid event.
2 | The new element has been successfully added.
Example: The following Basic example creates a new "Telephone" element and adds it to the second address in an XML document that contains addresses consisting of the sub-elements Name, Street, City and Telephone:
Dim NewElement As Object
Set NewElement = CreateObject("TIS.TX.XMLElement.12")
NewElement.ElementName = "Telephone"
NewElement.Text = "034568-782346"
TXTextControl1.XMLElements("Address")(2).AddChild NewElement
See also: XMLElement Object, XMLElement.RemoveChild Method.


XMLElement.AutoSelect Property
Description: Determines whether the text of a newly added XML element is automatically selected. The value of this property is True by default.
Syntax: XMLElement.AutoSelect [= boolean]
Data Type:
Boolean.
Limitations: Run time only.


XMLElement.AutoText Property
Description: Determines whether text is automatically created for a newly added XML element that has no text contents. The created text consists of the element's name enclosed in square brackets and is created only if no text has been set with the XML element's Text property. The value of this property is True by default.
Syntax: XMLElement.AutoText [= boolean]
Data Type:
Boolean.
Limitations: Run time only.


XMLElement.ChildItem Method
Description: Returns an XMLElement object that is a child element of this element. If this element has more than one sub-elements of the type with the given name the optional Index parameter can be used to specify the subelement. If Index is omitted Text Control returns the first sub-element with the given name.
Syntax: XMLElement.ChildItem ElementName[, Index]

Parameter | Description
ElementName | Specifies the name of the sub-element.
Index | Optional. Specifies the number of the subelement. If this value does not match any existing sub-element, an error occurs.
Return Value: The method returns an XMLElement object.
Example: The following Basic example gets the Telephone element from the second address in an XML document that contains addresses consisting of the sub-elements Name, Street, City and Telephone:
Dim Telephone As String
Set Addresses = TXTextControl1.XMLElements("Address")
Telephone = Addresses(2).ChildItem("Telephone")


XMLElement.ElementName Property
Description: Returns or sets the XML element's name. An element's name can only be changed for newly created elements. If an element belongs to an XML document its name cannot be changed.
Syntax: XMLElement.ElementName [= name]
Data Type:
String.
Limitations: Run time only.

See also: XMElement Object


XMLElement.RemoveChild Method
Description: Removes a sub-element from this element. If this element has more than one sub-element of the type with the given name, the optional Index parameter can be used to specify the sub-element to remove. If Index is omitted Text Control removes the first sub-element with the given name.
Syntax: XMLElement.RemoveChild ElementName[, Index]

Parameter | Description
ElementName | Specifies the name of the sub-element to remove.
Index | Optional. Specifies the number of the subelement. If this value does not match any existing sub-element, an error occurs.
Return Value: The method returns one of the following values:

Value | Description
0 | An error has occurred.
1 | The element could not be removed because the document becomes invalid according to the document's DTD. In this case Text Control fires an XMLInvalid event.
2 | The sub-element has successfully been removed.
Example: The following Basic example removes the second "Telephone" element of the second address in an XML document that contains addresses consisting of the sub-elements Name, Street, City and Telephone:
TXTextControl1.XMLElements("Address")(2).RemoveChild "Telephone", 2


XMLElement.Select Method
Description: Selects the text of the XML element. The text can only be selected if the element belongs to the document.
Syntax: XMLElement.Select
Remarks: If the element consists of several sub-elements Text Control selects the text of the first sub-element.
See also: XMElement Object.


XMLElement.Text Property
Description: Returns or sets the text belonging to an XML element.
Syntax: XMLElement.Text [= Text]
Remarks: If the element consists of several sub-elements, the text parts must be separated through linefeed characters (Chr(10)).
Data Types: String.
Limitations: Run time only.

Example: The following Basic example sets the text of the second address in an XML document that contains addresses consisting of the sub-elements Name, Street and City. Because the Text property is the default property of the XMLElement object the two lines of code are equivalent:
TXTextControl1.XMLElements("Address")(2).Text = "Jack Miller" & Chr(10) _
& "Baker Street" & Chr(10) & "New York"

TXTextControl1.XMLElements("Address")(2) = "Jack Miller" & Chr(10) _
& "Baker Street" & Chr(10) & "New York"
See also: XMElement Object.


XMLElements Collection Object

A XMLElements collection object is an OLE Automation object whose members represent all XML elements with a certain tag name. The members of an XMLElements collection object are OLE Automation objects of the class XMLElement. An XMLElements collection object can be obtained with the TXTextControl.XMLElements property.
Syntax: XMLElements

Properties
Property | Description
Count Returns the number of XMLElement objects in the collection.
InputItemIndex Returns the index of the element with the current input position in the collection.

Methods
Method | Description
Add Adds a new XMLElement object to the collection.
InputItem Returns the XML element of an XMLElements collection which contains the current input position.
Item Returns a specific XML element of an XMLElements collection.
Remove Removes an XML element from an XMLElements collection.


XMLElements.Add Method
Description: Adds a new XMLElement object to the collection.
Syntax: XMLElements.Add XMLElement[, before][, after]

Parameter | Description
XMLElement | Specifies an XMLElement object.
before | Optional. Specifies a relative position in the collection. The XML element to be added is placed in the collection before the member identified by the before parameter. It must be a number from 1 to the value of the collection's Count property. If this parameter is zero, the new element is inserted before the element at the current input position. You can specify before or after positions but not both.
after | Optional. Specifies a relative position in the collection. The XML element to be added is placed in the collection after the member identified by the after parameter. It must be a number from 1 to the value of the collection's Count property. If this parameter is zero the new element is inserted after the element at the current input position. You can specify before or after positions but not both.
Return Value:

Parameter | Description
0 | An error has occurred.
1 | The new element could not be added because the document becomes invalid according to the document's DTD. In this case Text Control fires an XMLInvalid event.
2 | The new element has successfully been added.
Data Types:
XMLElement: | XMLElement Object
before: | Long
after: | Long
Return value: | Integer
Example: The following Basic example inserts a new Address element in an XML document that contains addresses consisting of the sub-elements Name, Street and City. The new address is inserted after the second address:
Dim NewAddress As Object
Set NewAddress = CreateObject("TIS.TX.XMLElement.12")
NewAddress.Text = "Jack Brown" & Chr(10) _
& "Baker Street" & Chr(10) & "New York"
TXTextControl1.XMLElements("Address").Add NewAddress, , 2
See also: XMElement Object, XMElements Collection.


XMLElements.Count Property
Description: Returns the number of XMLElement objects in the collection.
Syntax: XMLElements.Count
Data Types: Long.

Limitations: Read only, run time only.

See also: XMElements.Add Method, XMElements.Item Method.


XMLElements.InputItem Method
Description: Returns the XML element of an XMLElements collection which contains the current input position.
Syntax: XMLElements.InputItem
Return Value: The method returns an XMLElement object. If the current input position is not in an element of this collection no object is returned.
Data Types:
Return value: XMLElement Object.

See also: XMElement Object, XMLElements Collection.


XMLElements.InputItemIndex Property
Description: Returns the index of the element with the current input position in the collection. The property value is zero if the current input position is in no element of this collection.
Syntax: XMLElements.InputItemIndex
Data Types: Long.

Limitations: Read only, run time only.

See also: XMElements.InputItem Method, XMLElements.Item Method.


XMLElements.Item Method
Description: Returns a specific XML element of an XMLElements collection.
Syntax: XMLElements.Item Index

Parameter | Description
Index | Specifies the position of the XML element in the collection. It must be a number from 1 to the value of the collection's Count property. If this value does not match any existing member of the collection, an error occurs.
Return Value: The method returns an XMLElement object.
Data Types:
Index: | Long
Return value: | XMLElement Object
Example: The following Basic example displays the content of the second Address element in an XML document that contains addresses. Because the Item method is the default method of the XMLElements collection and the Text property is the default property of the XMLElement object the three lines of code are equivalent:
MsgBox TXTextControl1.XMLElements("Address").Item(2).Text

MsgBox TXTextControl1.XMLElements("Address")(2).Text

MsgBox TXTextControl1.XMLElements("Address")(2)
See also: XMLElement Object, XMLElements Collection.


XMLElements.Remove Method
Description: Removes an XML element from an XMLElements collection.
Syntax: XMLElements.Remove Index

Parameter | Description
Index | Specifies the position of the XML element in the collection. It must be a number from 1 to the value of the collection's Count property. If this value does not match any existing member of the collection, an error occurs.
Return Value:

Parameter | Description
0 | An error has occurred.
1 | The element could not be removed because the document becomes invalid according to the document's DTD. In this case Text Control fires an XMLInvalid event.
2 | The new element has been successfully removed.
Data Types:
Index: | Long
Return value: | Integer
Example: The following Basic example removes the second Address element of an XML document that contains addresses:
TXTextControl1.XMLElements("Address").Remove(2)
See also: XMElement Object, XMElement Collection.


Obsolete Properties, Methods and Events

EnableHyperlinks Property (Obsolete)
RTFExport Method (Obsolete)
RTFImport Method (Obsolete)
TextExport Method (Obsolete)
TextImport Method (Obsolete)
ViewClicked Event (Obsolete)
ViewImagePath Property (Obsolete)
ViewNextHighlight Method (Obsolete)
ViewSection Property (Obsolete)
ViewWordDblClicked Event (Obsolete)
VTSpellCheck Method (Obsolete)
VTSpellDictionary Property (Obsolete)


EnableHyperlinks Property (Obsolete)
Description: This property must be set to True to enable special actions for pieces of text that function as hyperlinks. After loading a document that contains hyperlinks the user receives ViewClicked and ViewWordDblClicked events and can use the ViewSection and ViewNextHighlight properties and methods. With enabled hyperlinks a Text Control cannot be edited.
Syntax: TXTextControl.EnableHyperlinks [= boolean]

Setting | Description
True | Hyperlinks are enabled. The Viewxx events and methods are available.
False | (Default) Hyperlinks are disabled. The Viewxx events and methods are not available.
Data Types: Boolean.

See also: LoadSaveAttribute Property.


RTFExport Method (Obsolete)
Description: Writes the contents of a Text Control to a file with the specified name using the Rich Text Format.
Syntax: TXTextControl.RTFExport Filename
Return Value: The method returns True when the data has been written to the file. Otherwise it returns False.

Remarks: RTF (Rich Text Format) is one of the most common interchange formats for text documents. Most word processors available for Windows are able to read and write RTF files.

Data Types:
FileName: | String
Return value: | Boolean
See also: RTFImport Method.


RTFImport Method (Obsolete)
Description: Loads the contents of an RTF file with the specified name into a Text Control.
Syntax: TXTextControl.RTFImport Filename[, Extended]

Parameter | Description
Filename | Is the name of the RTF file that is to be loaded.
Extended | Optional. If this parameter is missing or zero then the text is inserted at the current caret position. If this parameter has a value of 1 then Text Control supports a special Viewer mode. In this mode, additional hypertext information is imported from the RTF file. See TX Info Artist manual for details.
Return Value: The method returns True when the data could be imported. Otherwise it returns False.

Remarks: RTF (Rich Text Format) is one of the most common interchange formats for text documents. Most word processors available for Windows are able to read and write RTF files.

Data Types:
FileName: | String
Extended: | Long
Return value: | Boolean
See also: RTFExport Method, ViewImagePath Property.


TextExport Method (Obsolete)
Description: Writes the selected text to a file in ANSI format.
Syntax: TXTextControl.TextExport FileName

Parameter | Description
FileName | Is the name of the file, Text Control uses for saving. When the file does not exist, a new file with this name is created. When the file exists, Text Control overwrites its current contents.
Return Value: The method returns True when the text has been written to the file. Otherwise it returns False.

Data Types:
FileName: | String
Return value: | Boolean
See also: TextImport Method, RTFImport Method, Save Method.


TextImport Method (Obsolete)
Description: Loads text in ANSI format and inserts it at the current caret position.
Syntax: TXTextControl.TextImport FileName

Parameter | Description
FileName | Is the name of the file, Text Control uses for loading.
Return Value: The method returns True when the text could be imported. Otherwise it returns False.

Data Types:
FileName: | String
Return value&:nbsp; | Boolean
See also: TextExport Method, RTFExport Method, Load Method.


ViewClicked Event (Obsolete)
Description: Occurs when a marked text field for which hyperlink data has been stored, is clicked on. It occurs only if the EnableHyperlinks property is set to True.

Syntax: ViewClicked(FieldType, FieldContents)
Parameter Description
FieldType Specifies the type of a field as an identifier. It can be one of the following values:

Code | Meaning
0 - 19 | Specifies fields that represent links to text positions within the same document (RTF only).
20 - 39 | Specifies buttons that represent link positions (RTF only).
100 | Specifies a field that is a link to a position in the same document (HTML only).
101 | Specifies a field that is a link to an external position (HTML only).
FieldContents Is a string that represents the contents of the field. The specification depends on the field's type and on the type of the document.
Remarks: This event is sent before a FieldClicked event is sent.
Data Types:
FieldType: | Integer
FieldContents: | String
See also: EnableHyperlinks Property.


ViewImagePath Property (Obsolete)
Description: When importing text data files which contain references to image files, the ViewImagePath property can be used to specify a different path for the images.
Syntax: TXTextControl.ViewImagePath [= string]
Data Types: String.

Limitations: Run time only.

See also: RTFImport Method.


ViewNextHighlight Method (Obsolete)
Description: Scrolls to the next highlight.
Syntax: TXTextControl.ViewNextHighlight
Return Value: The method returns False if the last highlight has been reached. Otherwise it returns True.

Remarks: The use of this method is only valid if the RTFImport method was previously used with the Extended parameter set to 1. See TX Info Artist description for details.

Data Types:
Return value: Boolean

See also: RTFImport Method.


ViewSection Property (Obsolete)
Description: Jumps to a specified text position. See TX Info Artist description for details.
Syntax: TXTextControl.ViewSection [= SectionNumber]
Remarks: The use of this property is only valid if the RTFImport method was used before with the Extended parameter set to 1.

Data Types: Integer.

Limitations: Write only, run time only.

See also: RTFImport Method.


ViewWordDblClicked Event (Obsolete)
Description: Occurs when a word is double-clicked with the mouse. It occurs only if the EnableHyperlinks property is set to True.
Syntax: ViewWordDblClicked(SelectedText)

Parameter | Description
SelectedText | Is the word that has been double-clicked.
Remarks: This event is sent before a DblClick event is sent.

Data Types:
SelectedText String

See also: RTFImport Method, DblClick Event.


VTSpellCheck Method (Obsolete)
Description: Starts the spellchecker. This method is only available if the VT Speller tool from VisualTools has been installed. VT Speller is not part of the Text Control package. Note that VT Speller is no longer available.
Syntax: TXTextControl.VTSpellCheck
Return Value: The method returns True if the spellchecker could be started, otherwise it returns False.

Data Types: Return value: Boolean

See also: VTSpellDictionary Property.


VTSpellDictionary Property (Obsolete)
Description: Determines the file name of the dictionary which is used by VT-Speller. Text Control uses this property only if the VT-Speller tool from VisualTools has been installed. VT Speller is not part of the Text Control package. Note that VT Speller is no longer available.
Syntax: TXTextControl.VTSpellDictionary [= string]
Data Types: String.

See also: VTSpellCheck Method.