Thread View: borland.public.cppbuilder.nativeapi
7 messages
7 total messages
Started by Jos�
Wed, 01 Mar 2006 22:16
User clicks on Memo
Author: Jos�
Date: Wed, 01 Mar 2006 22:16
Date: Wed, 01 Mar 2006 22:16
4 lines
909 bytes
909 bytes
There are several lines in a Memo. User clicks on a line. How can I know which line it was? -- Jos�
Re: User clicks on Memo
Author: JD
Date: Wed, 01 Mar 2006 22:27
Date: Wed, 01 Mar 2006 22:27
21 lines
1404 bytes
1404 bytes
Jos� <jose@127.0.0.1> wrote: > > There are several lines in a Memo. This question would have best been asked in the vcl.using group. > User clicks on a line. How can I know which line it was? TMemo has a Text property which returns an AnsiString with line breaks according to where the hard returns are. TMemo also has a Lines property but it's based on where the line wrap is on the screen. Increase or decrease the Width enough and you'll also change Lines::Count. Exactly which 'line' do you want? What are you trying to accomplish? ~ JD
Re: User clicks on Memo
Author: JD
Date: Wed, 01 Mar 2006 22:36
Date: Wed, 01 Mar 2006 22:36
24 lines
1647 bytes
1647 bytes
"HF" <(min_charATyahooPUTADOTgr)(HellenicFire)> wrote:
>
> I think this works ok
I think that you may have misunderstood the question. I
believe that the OP wants a line index of some king into
the memo's text.
>//------------------------------------------------------------
>void __fastcall TForm1::Memo1Click(TObject *Sender)
>{
> TPoint pp = Memo1->CaretPos;
> ShowMessage("Current Line : "+ IntToStr(pp.y+1));
>}
>//------------------------------------------------------------
If all you want is the click point relative to the TMemo's
ClientArea, then the OnMouseDown event is better suited
because it's parameter list includes ClientArea-relative
X and Y. You also won't have to code around an OnClickEvent
if it's ever implemented.
~ JD
Re: User clicks on Memo
Author: HF
Date: Wed, 01 Mar 2006 23:26
Date: Wed, 01 Mar 2006 23:26
16 lines
1467 bytes
1467 bytes
I think this works ok
//---------------------------------------------------------------------------
void __fastcall TForm1::Memo1Click(TObject *Sender)
{
TPoint pp = Memo1->CaretPos;
ShowMessage("Current Line : "+ IntToStr(pp.y+1));
}
//---------------------------------------------------------------------------
-minas
? "Jose" <jose@127.0.0.1> ?????? ??? ??????
news:997c029a5t0qjqsm19sajsj7mn1ob6jh1s@4ax.com...
> There are several lines in a Memo. User clicks on a line. How can I
> know which line it was?
> --
> Jos�
Re: User clicks on Memo
Author: Remy Lebeau (TeamB)
Date: Thu, 02 Mar 2006 01:52
Date: Thu, 02 Mar 2006 01:52
41 lines
1931 bytes
1931 bytes
"Jos�" <jose@127.0.0.1> wrote in message
news:997c029a5t0qjqsm19sajsj7mn1ob6jh1s@4ax.com...
> There are several lines in a Memo. User clicks on a line.
> How can I know which line it was?
Use the EM_CHARFROMPOS message:
void __fastcall TForm1::Memo1Click(TObject *Sender)
{
TPoint p = Memo1->ScreenToClient(Mouse->CursorPos);
int LineIndex = Memo1->Perform(EM_CHARFROMPOS, 0, MAKELPARAM(p.x,
p.y));
if( LineIndex > -1 )
{
LineIndex = HIWORD(LineIndex);
//...
}
}
Alternatively, use the EM_LINEFROMCHAR or EM_EXLINEFROMCHAR message:
void __fastcall TForm1::Memo1Click(TObject *Sender)
{
int LineIndex = Memo1->Perform(EM_LINEFROMCHAR, Memo1->SelStart, 0);
if( LineIndex > -1 )
// ...
}
void __fastcall TForm1::Memo1Click(TObject *Sender)
{
int LineIndex = Memo1->Perform(EM_EXLINEFROMCHAR, 0,
Memo1->SelStart);
if( LineIndex > -1 )
// ...
}
Gambit
Re: User clicks on Memo
Author: Jos�
Date: Thu, 02 Mar 2006 08:34
Date: Thu, 02 Mar 2006 08:34
16 lines
1364 bytes
1364 bytes
On Thu, 2 Mar 2006 01:26:20 +0200, "HF"
<(min_charATyahooPUTADOTgr)(HellenicFire)> wrote in
borland.public.cppbuilder.nativeapi:
>void __fastcall TForm1::Memo1Click(TObject *Sender)
>{
> TPoint pp = Memo1->CaretPos;
> ShowMessage("Current Line : "+ IntToStr(pp.y+1));
>}
This is exactly what I needed. I also find that CaretPos is not in the
help file as a property of TMemo, so I do not blame myself for being
unable to find it.
Thanks.
--
Jos�
Re: User clicks on Memo
Author: Boba
Date: Thu, 02 Mar 2006 18:34
Date: Thu, 02 Mar 2006 18:34
11 lines
1486 bytes
1486 bytes
"Jos�" <jose@127.0.0.1> wrote in message news:uebd02h8q30nh0j7f24mumu7ngv8i50i3u@4ax.com... > ... > I also find that CaretPos is not in the > help file as a property of TMemo, so I do not blame myself for being > unable to find it. > ... First of all, never blame yourself: let others do it for you. Secondly, my version of Builder also has a lot of bugs in almost every file shipped with it, that's why I think the best help manual is the collection of header files, code source and libraries supplied with the product.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads