Board index » cppbuilder » TMemo/TRichEdit finding the line which is clicked on

TMemo/TRichEdit finding the line which is clicked on


2003-07-22 11:29:20 PM
cppbuilder63
Hi,
I have a TMemo or a TRichEdit, which displays some (readonly) lines.
I want to do some processing of the lines when the user clicks on them.
For instance, clicking on a line which contains an adress (I have a way of
identifying them) would display some details, clicking on an email line
would allow to send an email etc...
To do so, I need to know the line which is clicked on... Now it seems that
CaretPos will only yield a coordinate, and SelStart will only yield a
character nr in the Text property.
Is it possible, either in TMemo or TRichEdit to know the line number which
is currently selected/clicked on?
Thanks in advance,
Francois
 
 

Re:TMemo/TRichEdit finding the line which is clicked on

Francois Charton wrote:
Quote
Is it possible, either in TMemo or TRichEdit to know the line number which
is currently selected/clicked on?
Using the SelStart property to get the linenumber;
int Index = RichEdit1->Perform(EM_LINEFROMCHAR, RichEdit1->SetStart, 0);
Using the position where you clicked with the mouse:
long xy = MAKELPARAM ( x, y );
long lastcharpos = SendMessage ( RichEdit1->Handle, EM_CHARFROMPOS, 0, xy );
Hans.
 

Re:TMemo/TRichEdit finding the line which is clicked on

"Francois Charton" < XXXX@XXXXX.COM >wrote in message
Quote
Is it possible, either in TMemo or TRichEdit to
know the line number which is currently
selected/clicked on?
Use the EM_LINEFROMCHAR message to translate a character index, such as
SelStart, into a line index, ie:
int line = Memo1->Perform(EM_LINEFROMCHAR, Memo1->SelStart, 0);
Gambit
 

{smallsort}