TE Edit Control Win32 / Win64 Help
Product page

TerGetLine

Retrieve a text line.

int TerGetLine(hWnd, LineNo, text, font)
int TerGetLineEx(hWnd, LineNo, text, lead, font)
int TerGetLineU(hWnd, LineNo, UnicodeText, font)
HWND hWnd;The handle of the window to be accessed
long LineNo;line number (0 to TotalLines - 1) to retrieve.
LPBYTE text;pointer of the location to retrieve the text for the line.
LPWORD UnicodeText;pointer of the location to retrieve the Unicode text for the line.
LPBYTE lead;pointer to the lead bytes
LPWORD font;pointer of the location to retrieve the font ids for each character in the line. Each font is is a two bytes long.

Description: This routine is used to retrieve the text and the font ids for a specified line. The text line is NULL terminated. The 'font' pointer receives an array of font ids. You can get further information about each font id by calling the 'GetFontInfo' function.

The 'text', 'lead' or the 'font' pointer can be set to NULL, if you do not wish for that information.

The TerGetLineEx function support an additional 'lead' pointer. This argument can be used to retrieve the lead bytes for the text in an MBCS (Multibyte Character Set) system. In this case, the 'text' argument will return the tail bytes and the 'lead' argument will return the lead bytes. You can use the TerMakeMbcs function to build an MBCS string using the lead and the tail bytes.

Return Value: This function returns the length of the retrieved line. This function return -1 if an error is encountered or when the 'LineNo' exceeds the total lines in the windows.

Comment: The VB users might find the following variation of this function easier to use:

int TerGetLineU2(LineNo, UnicodeText, font)

In the above method, the UnicodeText and font parameters are passed as simple VB strings.

C Example:

BYTE text[MAX_WIDTH];
WORD font[MAX_WIDTH];
int len;
' Get the text and font ids
TerGetLine(hWnd,LineNo,text,font);
' Get only the text
TerGetLine(hWnd,LineNo,text,NULL);

VB Example:

(1)

Dim text As String
Dim font As String
Dim result As Long
result = Toc1.TerGetLineU2(0, text, font)
The font id for a particular column position can be retrieved as following
FontId=AscW(Mid(font, col, 1)) ' font id for a column


(2)

dim text as string*MAX_WIDTH
dim font(MAX_WIDTH) as Integer ' array to receive the fontids
dim len as integer
text=space$(MAX_WIDTH) ' allocate space for up to 300 character

' Get the text and font
len = TerGetLine(Ter1.hWnd, LineNo, ByVal text, font(0))

' Please note that the font array is passed as the
reference to the first element of the font
'Get only text - pass NULL for the font parameter
len = TerGetLine(Ter1.hWnd,LineNo,ByVal text, ByVal 0&)
('ByVal' is prefixed because 'text' is defined as
'As Any' in the VB declaration)
Pascal Example:
var
text: array [0..MAX_WIDTH] of char
font: array [0..MAX_WIDTH] of Word
LineLen: Integer
begin
LineLen:=TerGetLine(ter1.Handle,LineNo,text,font[0]);
{Please note that the font array is passed as
the reference to the first element of the array.}
end