Lazarus: Get current Line Index from Memo
Question by Guest | Last update on 2022-05-02 | Created on 2014-01-22
I would like to retrieve the index of the line in which the user is currently writing from a TMemo.
Unfortunately, my previous searches only brought a solutions for Delphi to light with which it should be possible to determine the current line and column within a Memo like this:
Line := Memo1.Perform(EM_LINEFROMCHAR, Memo1.SelStart, 0) ; Column := Memo1.SelStart - Memo1.Perform(EM_LINEINDEX, Line, 0) ;
In Lazarus this is not working (Error Message: "Identifier not found EM_LINEFROMCHAR"). Does someone have a solution?
Related Topics
SQLite: Creating an Index on one or more Columns
Info | 0 Comments
How to Replace multiple Texts at the same Time
Tutorial | 0 Comments
Rewrite Text Files with a fixed Line Length
Tutorial | 0 Comments
HTACCESS: Simplify URL
Tutorial | 0 Comments
Delphi/Lazarus: Catch CTRL+C in Memo or Edit and Change Clipboard Content
Tutorial | 0 Comments
Repair Text Files with mixed Line Breaks
Tutorial | 0 Comments
JavaScript: Get current Date and Time
Tutorial | 1 Comment
Important Note
Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.
Participate
Ask your own question or write your own article on askingbox.com. That’s how it’s done.
It is much more easier.
Just try this:
CaretPos is the position of the cursor. It has a X and a Y variable in which the values you are searching for are stored.
As far as I know, "Perform" and "EM_LINEFROMCHAR" are typical for the Windows world and we cannot use them in the platform independent Lazarus.
Last update on 2022-05-02 | Created on 2014-01-22
The answer given by the other guest is the best solution.
Additionally, if you did want to go with your original route, you need to specify "windows" in the uses section.
2014-07-04 at 19:48