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:
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">
The CLASSID parameter is very important. There mustn't 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:
<TITLE>A Simple First Page</TITLE>
objTX.ButtonBarHandle = 1
objTX.ButtonBarHandle = objBB.hWnd
Where objBB is the ButtonBar object. Here are the class ids for the other TX controls:
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:
Public Property Get Text() As String
Text = TXTextControl1.Text
Public Property Let Text(ByVal t As String)
TXTextControl1.Text = t
And, getting back to our intention why we built the custom OCX, you should place the following code in the Initialize event:
Private Sub UserControl_Initialize()
TXTextControl1.ButtonBarHandle = TXButtonBar1.hWnd
TXTextControl1.StatusBarHandle = TXStatusBar1.hWnd
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.<&p>
The Newsletter Team