RichEdit从像素位置获取线条

时间:2014-01-14 14:34:24

标签: c++builder vcl trichedit c++builder-xe5

如果我在TRichEdit控件内部单击,如何从鼠标客户端坐标获取Line索引(我点击)?

换句话说,如何将客户端坐标转换为线索?

*** EDIT 我实际上没有点击TRichEdit控件内部,我点击另一个控件并需要与TRichEdit控件的行号同步。

1 个答案:

答案 0 :(得分:1)

向RichEdit发送EM_CHARFROMPOSEM_LINEFROMCHAR条消息,例如:

POINTL pt = ...; // client coordinates
int pos = RichEdit1->Perform(EM_CHARFROMPOS, 0, (LPARAM)&pt);
int idx = RichEdit1->Perform(EM_LINEFROMCHAR, pos, 0);