Your current line would beMemo1.Lines[Memo1.CaretPos.y]
I have tried it and it always returns 0. On checking the source it appears to a virtual method which hasn't been defined
class function TWin32WSCustomMemo.GetCaretPos(const ACustomEdit: TCustomEdit): TPoint;var BufferX: Longword;begin { X position calculation } { EM_GETSEL returns the char index of the caret, but this index doesn't go back to zero in new lines, so we need to subtract the char index from the line EM_GETSEL expects a pointer to 32-bits buffer in lParam } Windows.SendMessageW(ACustomEdit.Handle, EM_GETSEL, 0, PtrInt(@BufferX)); { EM_LINEINDEX returns the char index of a given line wParam = -1 indicates the line of the caret } Result.X := BufferX - Windows.SendMessageW(ACustomEdit.Handle, EM_LINEINDEX, -1, 0); { Y position calculation } { EM_LINEFROMCHAR returns the number of the line of a given char index. } Result.Y := Windows.SendMessageW(ACustomEdit.Handle, EM_LINEFROMCHAR, BufferX, 0);end;
Quote from: vfclists on May 10, 2015, 09:46:13 pmI have tried it and it always returns 0. On checking the source it appears to a virtual method which hasn't been definedYou can't track to that procedure via Lazarus (and find the definition). If you really track the source you get to this point (for Windows):in lcl/interfaces/win32/win32wsstdctrls.pp...
I am using Qt on Linux.
I've implemented Caret.Y for Qt. Test with r48988