This message contains graphics. If you do not see the graphics: Graphic Version.
 
How To Save Image Paths, Index Of Sample Applications

What Would You Like To Read In The 'Top TX Tips' Section?

If you have any ideas or if you would like to have any topic covered in the Top TX Tip section, then write us! Currently, we look at the support questions that we get and try to amalgamate the most frequently recurring topics and present a structured description of these topics.

However - as we hope that you have notice - we believe that listening to our customers is one of the most important aspects of our work. We are here to help you. And if you would like us to present a Top TX Tip for your problem, then let us know. Likewise, if you would like to offer some code to use in this newsletter, just sent it to us. Please do not forget that we produce this newsletter for you - our users - and therefore you should defiantly get a say in what we publish.

Indeed, one of the ideas we had when we thought up the concept of the 'Top TX Tip' section was to provide a valuable information source for our TX Text Control users. To enable you to extract the information that you require from this knowledge base, all past editions of the TX Text Control newsletter, including all the previously published Tips and Tricks, can be now searched.

Index Of Sample Applications

In line with the comments above, I would like to remind you that we have our new Index of Sample Applications on the web site at the moment. Judging by the increase in visitors to this page last week, it would look like you have been waiting for such an index for quite a long time. We shall endeavour to expand this list in the up and coming weeks - adding one Top TX Tip with sample code per week.

If you missed out on the newsletter from last week, you can access the source code library.

Go on! Check it out! It can save you a lot of work - especially if you are just getting started with TX Text Control. You can take the code just like it is in our example and use it in your application. All the code is completely free.

Top TX Tip: How To Save Image Paths

This weeks' Top TX Tip we are looking at images and what we can do with them in TX Text Control.

Here in the support department, we get a lot of e-mail asking how it is possible to determine the position or the path name of an image when it has been inserted as a character.

Using TX Text Control as it is, this is not possible. However, there is a very simple work around: The secret is to insert the image into a field.

Images - and all other objects for that matter - can be counted using a loop. However, it is not possible to determine the exact input position in the text of the object. Likewise other data, which for example describes the inserted object, cannot be saved. However, if we use fields both of these problems are solved.

This is what we have to do:

  1. Insert the image

  2. Select the image and insert a field.
    To prevent the field from being enlarged and to prevent the image from being deleted, we need to set the field property Changeable to false.

  3. Save the ID of the image.
    We need to then save the ID of the image that is currently in the field in the FieldData property. Doing this enables us to later find the image more easily.

As only one FieldData property is available - and we have just filled that with the image ID - we have to save the image path somewhere else.

What we need here is a hash table or something very similar, which is referenced with the ID of the field. In the following example we use a simple string array to save the path.

Here is the Visual Basic code:

Sub InsertImage(name As String) Dim sel_start As Integer Dim sel_end As Integer Dim image_id As Long Dim field_id As Long sel_start = Form1.TXTextControl1.selstart image_id = Form1.TXTextControl1.ObjectInsertAsChar(0, name, -1, 100, 100, 0, 0) If image_id = 0 Then Exit Sub sel_end = Form1.TXTextControl1.selstart ' Select the image Form1.TXTextControl1.selstart = sel_start Form1.TXTextControl1.SelLength = sel_end - sel_start ' Put the image into a field and store the image's ID in the field If Form1.TXTextControl1.FieldInsert("") Then field_id = Form1.TXTextControl1.FieldCurrent Form1.TXTextControl1.FieldData(field_id) = image_id Form1.TXTextControl1.FieldChangeable = False ' Finally store the path name in a global variable ImagePaths(field_id) = name Else ' Something's wrong, delete the inserted image Form1.TXTextControl1.ObjectDelete (image_id) End If End Sub

Use this function to insert an image as we discussed above.

If you run the example and mouse over the image, the path of the image appears in the title bar. A dialog box appears in which the path and position of the image in the text is shown if you click on the image.

We shall leave it up to you to decide how you can best use this code in your application. One thing that we have noticed over the years that we have been doing TX Text Control support, is that our users are very creative! Have fun with the code!

Worthwhile Site Of The Week: iDevResource.com

iDevResource.com covers all of these and more for professional developers with cutting edge articles, breaking news, forums, discussion groups, developer catalogue, and even humour and competitions!

Get the IUnknown at http://www.idevresource.com


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.