This message contains graphics. If you do not see the graphics: Graphic Version.
How To Read A Document Row By Row, The TX Newsletter Archive

Important Change To The Top TX Tip Section

It has been reported that the TX Text Control newsletter is often deleted or bounced when it enters the network of certain large companies. The reason for this is simply that the newsletter usually contains a piece of VB code that is INCORRECTLY interpreted by the firewall (or e-mail virus checking system) of many co-operations as an e-mail borne virus and is therefore dealt with in an appropriate manner - it is DELETED.

Please note that the TX Text Control newsletter DOES NOT and WILL NEVER contain any malicious code. The problem lies in the ill-configured security measures in place at the gateway of many companies.

However, as we do not wish that our newsletter is deleted before you even get a chance to see it, as of this issue, we will NOT publish any more source code in the newsletter itself. Please download the .ZIP file that is part of the article to get the entire VB / Delphi / MS C++ project, which naturally contains the source code.

How To Read A Document Row By Row

In some cases it might be useful if you can read a document row by row and not in one big gulp. This source code snippet show you exactly how to do this.

The example uses 2 separate TX Text Controls. The first one shows a normal page layout of a document and the other one shows, upon a button click, the unformatted rows of the first TX Text Control with their line numbers.

The sample is straightforward. However, the only part that has to be explained a little is what happens when the buttons are pressed.

First of all, here is the Visual Basic code:

Private Sub Command1_Click() Dim index, line As Long line = 1 ' Clear 2nd TX TXTextControl2.ResetContents ' User shall not see what we do TXTextControl1.LockWindowUpdate = True ' Find index of 2nd line TXTextControl1.SelStart = 0 index = SendMessage(TXTextControl1.hwnd, TX_LINEINDEX, 0, line) While (index <> 0) ' Select the line and append it to the pother TX TXTextControl1.SelLength = index - TXTextControl1.SelStart TXTextControl2.SelText = CStr(line) + ": " + TXTextControl1.SelText + vbCrLf TXTextControl1.SelStart = index ' Now increment line and get index of next line line = line + 1 index = SendMessage(TXTextControl1.hwnd, TX_LINEINDEX, 0, line) Wend ' Now use a really large value for SelLength to select the ' entire last row TXTextControl1.SelLength = 1000 TXTextControl2.SelText = CStr(line) + ": " + TXTextControl1.SelText ' Clean up TXTextControl1.SelStart = 0 TXTextControl1.SelLength = 0 TXTextControl1.LockWindowUpdate = False TXTextControl1.SetFocus End Sub

This is what happens: The second control is cleared and LockWindowUpdate is used once again to prevent the user from seeing that we are selecting text.

Then the TX_LINEINDEX message is used to retrieve the input position of the first character in the second row.

Once we know this position, we can select the entire first row, which goes from 0 to index.

The selected text is appended to the second TX Text Control and we continue to do the same procedure for the next line and so on.

Once we are in the last line of document, TX_LINEINDEX returns 0!

So we leave the loop and finish by selecting the entire last line and appending it as well.

Finally, we clean up and we are done.

It's not that hard, is it?

For those of you who are not familiar with the SendMessage API, the TX_LINEINDEX message will be also accessible via a property in the next version of TX Text Control.

The Newsletter Archive

As a loyal reader of this newsletter, you will no doubt treasure the valuable content that you receive every week, directly in your Inbox.

On the new web site, we have spent considerable time structuring the past editions so that you can quickly locate the information that you are looking for.

Just below the sub-heading 'Past editions' you will see a rather long table with the name of the newsletter and date of publication. By clicking on the newsletter title, you can link to the archived edition. Using this method, you can get a really good overview of the newsletters that we have published.

However, to extract the really interesting information from the newsletter archive, you should use the powerful full text search engine. As we mentioned a couple of weeks ago, the search box is at the top right of every page. As you are in the newsletter archive section, the scope-selection combo box has already been set to 'newsletter'. So, simply enter a search term and hit the button labeled 'GO'. Within a second you will be returned with a list of matching pages. Clicking on the title of the returned results will take you to the archived newsletter edition.

As we have been urging you for the last few weeks, so that we can continue to improve on your experience of our web site, please comment on the new layout.

Thank you! Next week, we will continue with part four of our six part series and discuss how to get the most out of the links section of the new TX Text Control web site.

Notable Link Of The Week:

Thousands of VB Code downloads, VB Chat room (Java), VB Forums, Experts Site, Daily VB News ,Custom Programming and much more... Stop by and take advantage of our Free Banner Advertisement offer today... While you are there, check out the "programmer's jokes" and "100 Download" page for VB Beginners... VBOnly now a member of "Diamond Group". Team up with us and get your FREE server space, FREE Domain and many FREE applications...

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

© 2020 Text Control GmbH. All Rights Reserved.