Skype:TextControlSupport
Orders:877-462-4772
TX Text Control - word processing components.
What is this?Syndicate this content

How to use TX Text Control in Internet Explorer

This source code snippet requires TX Text Control ActiveX
Author:TX Text Control Support Department
Language:Visual Basic
Version:1.1
Released:April 04, 2001
Last modified:January 11, 2008
Requirements:TX Text Control ActiveX with Visual Basic 6.0

As many users encounter problems when trying to use the TX Text Control in Internet Explorer, we will cover this topic in this weeks TNT.

First of all, you need the main TX object. This is inserted by using the HTML OBJECT:

  1. <OBJECT
  2. CLASSID="clsid:3D6D5D2F-B9F2-101C-AED5-00608CF525A5"
  3. ID=objTX WIDTH=600 HEIGHT=400>
  4. <PARAM NAME="ViewMode" VALUE="2">
  5. <PARAM NAME="ScrollBars" VALUE="3">
  6. <PARAM NAME="PageWidth" VALUE="12240">
  7. <PARAM NAME="PageHeight" VALUE="15840">
  8. </OBJECT>

The CLASSID parameter is very important. There must not be a typo in that! Through the ID parameter, you can specify a name with which you reference the TX in VB Script.

Between the two OBJECT tags you place some initial property settings like the page dimensions or the ViewMode to be used.

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 event, this is called before the two objects have been created.

But fortunately TX 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, TX fires an event called ConnectTools, when it's ready to receive the handles. The code to do that looks like the following:

  1. <HTML>
  2. <HEAD>
  3. <TITLE>A Simple First Page</TITLE>
  4. <SCRIPT LANGUAGE="VBScript">
  5. <!--
  6. Sub Load()
  7. objTX.ButtonBarHandle = 1
  8. End Sub
  9. Sub objTX_ConnectTools()
  10. objTX.ButtonBarHandle = objBB.hWnd
  11. End Sub
  12. -->
  13. </SCRIPT>
  14. </HEAD>
  15. <BODY onLoad="Load()">

Where objBB is the ButtonBar object. Here are the class ids for the other TX controls:

  1. ButtonBar: clsid:B6A084E0-BF8F-101C-AED5-00608CF525A5
  2. StatusBar: clsid:B6A084EA-BF8F-101C-AED5-00608CF525A5
  3. Ruler: clsid:B6A084E5-BF8F-101C-AED5-00608CF525A5

Another way to solve the problem is to build a custom OCX control that wraps the TextControl and/or a ButtonBar/StatusBar/Ruler.

I think it's not too hard to create such an OCX with VB. Create a new "ActiveX Control" project and place the controls you want on the form. Now you have to create properties that should be accessible from outside. For instance, you want to make the TextControls .Text property available from outside. Then you have to define your own property like the following:

  1. Public Property Get Text() As String
  2. Text = TXTextControl1.Text
  3. End Property
  4.  
  5. Public Property Let Text(ByVal t As String)
  6. TXTextControl1.Text = t
  7. End Property

And, getting back to our intention why we built the custom OCX, you should place the following code in the Initialize event:

  1. Private Sub UserControl_Initialize()
  2. TXTextControl1.ButtonBarHandle = TXButtonBar1.hWnd
  3. TXTextControl1.StatusBarHandle = TXStatusBar1.hWnd
  4. End Sub

It's a little work to built the entire OCX, but when done you have a custom control, that exactly fits your needs.

There are a few points you have to pay attention to, when you want to distribute your OCX along with TX.

All of the controls, also the one you created yourself have to be included in the LPK file. Please read the chapter in the OCX programmer's guide called "Using TX Text Control with HTML and VBScript", if you don't know what an LPK file is.

You should place your OCX in a CAB file. You can either use the same CAB file as the TX's one or generate a new one. This is necessary to register the OCX on the target machine. The CAB file has to be referenced in each OBJECT tag. Further information you can find in the chapter mentioned above in the OCX programmer's guide.

top

Top 10 Bestselling Product Award 2007Top 25 Publisher Product Award 2007Top 10 Bestselling Product Award 2007 in JapanTop 25 Bestselling Product Award 2006Top 25 Bestselling Publisher Award 2006Reader's Choice Award, dot.net magazin, 3rd place