Dear Master
GetMem, thank you very much for the reply.
My goal is to detect the current word in the row where the mouse is located.
An obvious situation;
The mouse position can sometimes be in the middle of the word. For this, I need to determine the beginning and end of the word separately.
For this, I transferred the space and other characters used to separate words into a character type array.
I'm trying to find the beginning by going backwards from the mouse position, and the end by going forward. During this process, I had to compare the characters of the word with the array elements I defined.
Dear brother
Avinash, thank you very much for your reply.
Thanks to you, my problem has been solved and I have learned a very important lesson.
I'm done at this stop in my project, now I can move on to the next stop.
Let's put the code here, maybe someone will need it someday.
procedure TForm1.Memo1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: integer);
const
separ = [' ', '''', '<', '>', '/', '\', '=', '.', ',', '(', ')', '[', ']', '{', '}', ':', ';'];
var
Lines, search: string;
LineRow, LineCol: longint;
sst, stp: integer;
begin
if Button = mbleft then
begin
LineRow := Memo1.CaretPos.y;
LineCol := Memo1.CaretPos.x;
Lines := memo1.Lines.Strings[LineRow];
if Lines <> '' then
begin
for sst := LineCol downto 0 do
begin
if (Lines[sst] in separ) then
break;
end;
for stp := LineCol to high(Lines) do
begin
if (Lines[stp] in separ) then
break;
end;
search := copy(Lines, sst + 1, stp - sst - 1);
Caption := search;
end;
end;
end;