I have a Winforms app containing a RichTextBox.
How can I determine how many lines of text are displayed, currently visible?
Reason: I want to scroll the caret to the middle of the RichTextBox. I can use RichTextBox.ScrollToCaret(), but that puts the caret at the top of the RichTextBox. I figure, If I know how many lines are displayed, I could move the caret "back" n/2 lines, then call ScrollToCaret(), then restore the original caret position.
EDIT:
I found EM_GETLINECOUNT, which I thought was the answer, except the doc says: *The EM_GETLINECOUNT message retrieves the total number of text lines, not just the number of lines that are currently visible.*
Tantalizingly, there is also EM_GETFIRSTVISIBLELINE, which gets the first visible line, but I couldn't find a GETLASTVISIBLELINE. ??
Related:
How can I scroll the caret to the middle of the RichTextBox?