How To Insert A Fixed Object At The Current Input Position
This week, we are going to learn how to insert a fixed object at the current input position.
At first glance, this does not seem that complicated, but can be somewhat tricky, as we need to determine the input position in twips. Only once we have done this, can we insert the object or image.
To determine the Y offset, we simply use the built in methods GetLineFromChar and GetLineRect. The first one retrieves the line from a position in the document. We pass TX.SelStart and we are returned with the current line number. Then, we pass the return value to GetLineRect and we have got the Y offset.
lLine = TXTextControl1.GetLineFromChar(nCurPos)
rect = TXTextControl1.GetLineRect(lLine)
The X offset is not that simple to retrieve. In the current ActiveX version of TX Text Control, it is not at all possible, so we have to use a Windows message.
The message we need to use is called TX_GETCHARRECT. It returns the rectangle of a certain character. The left coordinate of this rectangle is exactly the value we need.
cr.lLineIndex = nCurPos
lResult = SendMessage(TXTextControl1.hwnd, TX_GETCHARRECT, 0, cr)
This message is currently undocumented, but will be supported in all future versions. It will also be available as a property in the next update of TX Text Control.
You can download a brief sample application that illustrates this technique.
As usual we would be delighted to talk with you and discuss any particulars of this example.
How To Create Clickable Hyperlinks In The Forum
You have probably noticed that when members of the TX Text Control support team answer questions in the Support Forum, they often illustrate their answer with a clickable hyperlink.
How do they do that?
The support forum allows basic HTML tags to be used, amongst others the '' tag. It is exactly this HTML tag that should be used to create a hyperlink.
For example, instead of writing:
See this example: http://www.server.com/example.htm.
you could write:
See this example.
If you look carefully at the example, you will see that we have wrapped the words 'this example' in '' tags. To learn more about creating hyperlinks in HTML, please take a look at this excellent primer.
Best regards
The Newsletter Team