Board index » delphi » Memo.lines to string???

Memo.lines to string???

Hi to all and thank for any replay.

How to copy a line of a memo to a string,
 when I click with the mouse on a line?

Thanks for any replays

Gery

www.zipworld.com.au/~gprdata

Have a great day

 

Re:Memo.lines to string???


memo1.Lines.Strings[i], where i is the line number you want. Remember you
start with line 0.

Darius Blaszijk

Quote
"Gery Rohrig" <gprdataNoS...@zipworld.com.au> wrote in message

news:3ba361d9.2995953@news.zipworld.com.au...
Quote
> Hi to all and thank for any replay.

> How to copy a line of a memo to a string,
>  when I click with the mouse on a line?

> Thanks for any replays

> Gery

> www.zipworld.com.au/~gprdata

> Have a great day

Re:Memo.lines to string???


MyString := memo1.Lines[memo1.CaretPos.Y]

Quote
"Gery Rohrig" <gprdataNoS...@zipworld.com.au> wrote in message

news:3ba361d9.2995953@news.zipworld.com.au...
Quote
> Hi to all and thank for any replay.

> How to copy a line of a memo to a string,
>  when I click with the mouse on a line?

> Thanks for any replays

> Gery

> www.zipworld.com.au/~gprdata

> Have a great day

Re:Memo.lines to string???


Quote
"Vladimir Perkic" <vper...@yahoo.com> wrote in message news:9o262e$89n$1@neptun.beotel.net...
> MyString := memo1.Lines[memo1.CaretPos.Y]

> "Gery Rohrig" <gprdataNoS...@zipworld.com.au> wrote in message
> news:3ba361d9.2995953@news.zipworld.com.au...
> > Hi to all and thank for any replay.

> > How to copy a line of a memo to a string,
> >  when I click with the mouse on a line?

Hmm , I thought you were wrong, I was wrong, lucky I checked the code first ;-)
my help says
Use CaretPos to determine the coordinates of the cursor. CaretPos indicates the X and Y position (in pixels) relative to the client
origin of the memo.
To determine the position of the caret in terms of characters of text rather than physical location, use the SelStart property.

but caretpos.y   does indeed return the zero based line
     caretpos.x the zero based char in the  line

I  used the following

procedure TForm1.Memo1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
//var s:string;
begin
   if button = mbleft then
   begin
     //s := memo1.Lines[memo1.CaretPos.Y];
     s:=memo1.lines[memo1.perform(em_linefromchar,selstart,0)];
   end;
end;

Other Threads