I have a Tmemo component that can display 10 rows with the current font. There are currently 5 rows assigned, i,e Memo.lines.count -1 = 4. Is there a way to detect when a row is clicked that is greater than the last assigned/displayed row. Example: If I click it the area of row 7, the function returns the last row assigned or row 4. I am looking for feedback that tells me that I am clicking a non-assigned area.

The code below identifies existing rows clicked. Could there be info in it I am missing?

Thank you for reading.


from About.com
function SelectMemoLine(Memo : TCustomMemo):integer ;
Line : integer;
with Memo do
Line := Perform(EM_LINEFROMCHAR, SelStart, 0) ;
SelStart := Perform(EM_LINEINDEX, Line, 0) ;
SelLength := Length(Lines[Line]) ;
result := Line;

This might help:
The property CaretPos will tell you which line the cursor has selected. (CaretPos.y) I have not tested it to see if it will point to a line beyond the end of the text or not. The number of lines in the Tmemo should be in the "lines" property index. This might help: