| Skype: | TextControlSupport | |
| Orders: | 877-462-4772 |

| 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 |
| Download code: | network.zip |
Using TX Text Control in Microsoft Internet Explorer only makes sense if you can actually load documents that lie on other computers - for example on a file server. Microsoft provides a control that makes this task very easy.
It's called MSInet.ocx and is available for download from http://www.microsoft.com if it's not already installed on your machine.
The following sample is written in plain HTML using VBScript.
Here is how it works:
<OBJECT ID="Inet1" CLASSID="CLSID:48E59293-9880-11CF-9754-00AA00C00908" > </OBJECT> <OBJECT id=objTX classid="clsid:3D6D5D2F-B9F2-101C-AED5-00608CF525A5" width="100%" height="90%" > <PARAM NAME="ViewMode" VALUE="2"> <PARAM NAME="ScrollBars" VALUE="3"> <PARAM NAME="PageWidth" VALUE="12000"> <PARAM NAME="PageHeight" VALUE="16000"> <PARAM NAME="Text" VALUE="TX Text Control ActiveX in Internet Explorer"> </OBJECT>
In addition to the TX Text Control control, an Inet control is placed in the HTML code. It will not be visible later on, but we can use it to perform a variety of tasks. This example will only show how to download documents using HTTP, but FTP is possible as well.
Three buttons are also placed in the HTML file. Here are their event handlers:
Sub GetTXT_onClick() Dim strData strData = Inet1.OpenURL("http://www.example.com/path/to/msie_demo.txt", icString) objTX.LoadFromMemory strData, 1, False End Sub Sub GetHTM_onClick() Dim strData strData = Inet1.OpenURL("http://www.example.com/path/to/msie_demo.htm", icString) objTX.LoadFromMemory strData, 4, False End Sub Sub GetRTF_onClick() Response = Inet1.Execute("http://www.example.com/path/to/msie_demo.rtf", "GET") If Inet1.ResponseCode <> 0 Then MsgBox ("ErrorCode: " & Inet1.ResponseCode) MsgBox ("Error: " & Inet1.ResponseInfo) End If End Sub
In the first two handlers the Inet control's OpenURL method is used to download a file into a variable. This variable is then loaded into the TX Text Control using TX's LoadFromMemory method.
The third handler shows another way of loading a file. It uses the Inet Control's Execute method. The difference between the two methods is that the OpenURL method does not return until the file is downloaded. So, the application seems to hang.
The execute method lets the Inet control send a message when data arrives. Here is the handler for this message:
Sub Inet1_StateChanged(State) Select Case State ' ... Other cases not shown. Case 12 ' icResponseCompleted Dim strData: StrData = "" Dim vtData ' Get first chunk. vtData = Inet1.GetChunk(10240, icString) Do While Len(vtData) <> 0 strData = strData & vtData ' Get next chunk. vtData = Inet1.GetChunk(10240, icString) Loop objTX.LoadFromMemory strData, 5, False End Select End Sub
The Inet control has 12 states. In this example only state no. 12 is of interest. When the control has reached this state, all data is downloaded. Using the GetChunk method, the data is stored in a variable and then loaded into TX Text Control with the LoadFromMemory method.