0

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.

Max Kielland
  • 5,627
  • 9
  • 60
  • 95

1 Answers1

1

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);
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770