Pergunta

If I click inside a TRichEdit control, how can I get the Line index (I clicked on) from the mouse client coordinates?

In other words, how do I convert a client coordinate to a Line Index?

***EDIT I'm actually not clicking inside the TRichEdit control, I'm clicking in another control and need to synch with the TRichEdit control's line number.

Foi útil?

Solução

Send EM_CHARFROMPOS and EM_LINEFROMCHAR messages to the RichEdit, eg:

POINTL pt = ...; // client coordinates
int pos = RichEdit1->Perform(EM_CHARFROMPOS, 0, (LPARAM)&pt);
int idx = RichEdit1->Perform(EM_LINEFROMCHAR, pos, 0);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top