Skype:TextControlSupport
Orders:877-462-4772
TX Text Control - word processing components.
What is this?Syndicate this content

Fixed images in TX Text Control ActiveX

This source code snippet requires TX Text Control ActiveX
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 Download [10.93 KB, ZIP]

How To Insert A Fixed Object At The Current Input Position

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.

  1. lLine = TXTextControl1.GetLineFromChar(nCurPos)
  2. 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.

  1. cr.lLineIndex = nCurPos
  2. lResult = SendMessage(TXTextControl1.hwnd, TX_GETCHARRECT, 0, cr)

top

Top 10 Bestselling Product Award 2007Top 25 Publisher Product Award 2007Top 10 Bestselling Product Award 2007 in JapanTop 25 Bestselling Product Award 2006Top 25 Bestselling Publisher Award 2006Reader's Choice Award, dot.net magazin, 3rd place