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

| Author: | TX Text Control Support Department |
| Language: | Visual Basic |
| Version: | 1.0 |
| Released: | September 21, 2004 |
| Last modified: | January 11, 2008 |
| Requirements: | TX Text Control ActiveX with Visual Studio 6.0 |
| Download code: | InsertFixed At Caret.zip |
In this sample, we are going to show you 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)