TE Edit Control Win32 / Win64 Help
Product page

TerPixToTextPos

Retrieve the text position at a given pixel position.

BOOL TerPixToTextPos(hWnd, RelativeTo, x, y, pLine, pCol)
HWND hWnd;Handle of the window to be accessed
int RelativeTo;This parameter should be set to one of the following constants:
REL_SCREEN:When specifying the x/y values relative to the top of the screen.
REL_WINDOW:When specifying the x/y values relative to the client area of the edit control.
REL_TEXT_BOX:When specifying the x/y values relative to the top of the text box.
int x;The x position of the pixel.
int y;The y position of the pixel.
DWORD far *pLine;The pointer to the location to receive the text line number.
int far *pCol;The pointer to the location to receive the text column number. To retrieve the absolute text position in the pLine parameter, set the pCol parameter to NULL or set the column number to -1.

Return Value: This function returns TRUE when successful.

Example: The example below retrieves the text position at a pixel position x=100, y=100.

long line;

int col=0; // set to 0 to retrieve the position in line/column format.

TerPixToTextPos(hWnd, REL_TEXT_BOX, 100, 100, &line, &col);