TE Edit Control Win32 / Win64 Help
Product page

TerGetTextSel

Retrieve the selected text.

HANDLE TerGetTextSel(hWnd, size)
HANDLE TerGetTextSelNR(hWnd)
HANDLE TerGetTextSelU(hWnd, size)
HANDLE TerGetTextSelUNR(hWnd)
HWND hWnd;The handle of the window to be accessed
long far *size;The size of the output global buffer.

Return Value: This function returns the global handle to the buffer containing the selected data as plain text (excluding any hidden text). The size of the global buffer is returned using the second argument. Lock (GlobalLock) the returned handle to access the text. Your application owns this memory handle. When the data is no longer required, use the GlobalFree function to free the global handle.

A NULL value of the handle indicates an error.

The TerGetTextSelU function should be use when the text contains unicode characters. This function returns the text in the unicode format. Each character is two bytes long. Therefore the pointer dereference from the global handle (return value) should be treated as a pointer to the WORD array.

A VB application can use the HandleToIntArray function read the contents of the output of the TerGetTextSelU function into an integer array

Dim size As Long
Dim hMem As Long
Dim UniText(MAX_WIDTH) as Integer
Dim count As Long

hMem = TOC1.TerGetTextSelU(size)
count = TOC1.HandleToIntArray(UniText(0), size, hMem)
The UniText array now contains unicode character values.

The TerGetTextSelNR method is similar to the TerGetTextSel method, but it does not use the size parameter to return the size of the memory block. This function is useful within a script which does not allow for a 'pass-by-reference' parameter. The size of the returned memory block can be retrieved by immediately calling the TerGetRefParam method. Similarly, the TerGetTextSelUNR function is a replacement for the TerGetTextSelU unicode function within a script.