This message contains graphics. If you do not see the graphics: Graphic Version.
 
Calling TX Text Control properties from a UserControl

Many programmers who deploy TX Text Control as an OCX in the Internet Explorer want to encapsulate all the controls that make up TX Text Control (ButtonBar, StatusBar, RulerBar and TX Text Control itself) into one UserControl. There are basically two reasons to do this:

  • You only have to include one object in your HTML page.
  • You can implement your own methods and properties.

In doing this, however, there is typically one problem: If you include your UserControl (that contains TX Text Control) you have no access to the TX Text Control properties and methods.

In this newsletter, we are going to show you how to access all of TX Text Control's properties from your UserControl in Internet Explorer.

The trick lies in setting a public handle to TX Text Control that enables access to the properties and methods. Consider the following code:

Public Handle As TXTextControl

In the UserControl_Initialize event you set this handle to the TX Text Control.

Private Sub UserControl_Initialize() ' set handle, so that TX properties can be called from the UserControl Set Handle = UserControl.TXTextControl1 TXTextControl1.ButtonBarHandle = TXButtonBar1.hWnd TXTextControl1.RulerHandle = TXRuler1.hWnd TXTextControl1.StatusBarHandle = TXStatusBar1.hWnd End Sub

Now, using VBScript you can access the Text property of TX Text Control like this, for example:

Sub Button1_OnClick myTX.Handle.Text = "This is a TX Text Control property!" End Sub

Additionally, we can define a customized method to insert tables in our UserControl.

Sub InsertTable(TableId As Variant, Row As Integer, Col As Integer, TableLineWidth As Integer) ' this customized method can be called directly from the UserControl UserControl.TXTextControl1.TableInsert Row, Col, -1, TableId UserControl.TXTextControl1.TableCellAttribute(TableId, 0, 0, txTableCellBorderWidth) = TableLineWidth UserControl.TXTextControl1.TableCellAttribute(TableId, 1, 0, txTableCellBackColor) = vbRed End Sub

This method inserts a table and automatically sets the border width and the background color of the first row. This shows the advantage of using a UserControl in the Internet Explorer. This method can be called directly from the UserControl without the handle:

Sub Button2_OnClick myTX.InsertTable 13,3,6,40 End Sub

To test the sample HTML page, it is necessary to register the myTX.OCX manually using the small utility regsvr32.exe on your machine (use the directory where the sample is installed):

regsvr32.exe c:\myTX.OCX

Naturally, TX Text Control should also be installed on your machine, as TX Text Control is used in the UserControl. You will also find the sources of the UserControl in the zip file, so that you can add your own methods and properties.

If you are new to TX Text Control, please view these videos: They will give you a great overview of what you can achieve.


Best regards

The Newsletter Team

Text Control GmbH respects your online time and privacy. We only send this newsletter to TX Text Control customers and people who have signed up to receive it. However, if you would prefer not to receive future issues of the newsletter, you may unsubscribe at any time. If you received this newsletter forwarded from a colleague or friend, you may wish to subscribe directly.

Sent to: N/A.

Imprint | Unsubscribe | Subscribe

© 2019 Text Control GmbH. All Rights Reserved.