2) thanks! now I can get position of some symbol in first and last visible line. But how can I get line number from position?
That depends on what you'd call "a line".
The line could be considered:
* either a paragraph (all text until line-break character is met - is a line)
* a text, that stays on the same vertical position from left side to the right side of the document.
The difference between these two, is obvious when word-wrap is enabled.
I.e. a very long paragraph can be broken among multiple lines on the screen.
...of course I can put cursor to this position and get line number with RichMemo1.CaretPos.y and then put cursor position back to old position... but... it is not good!
You don't have to move the cursor around.
Just do
RichMemo1.CharAtPos(0,0) - this is the top (left-most) character.
then do
RichMemo1.CharAtPos(RichMemo1.ClientHeight,0) - this is the bottom character.
(in old program in Delphi I did it with WinApi in one command/function without "blink")
so what WinApi command did you use?
EM_GETFIRSTVISIBLELINE ? you could still use it with RichMemo
ln:=SendMessage(RichMemo1.Handle, EM_GETFIRSTVISIBLELINE,0,0);