BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

retrieving word at caret position?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
Rory Walsh
Guest





PostPosted: Sat Apr 29, 2006 1:03 am    Post subject: retrieving word at caret position? Reply with quote



Hi everyone. I would like to retrieve the string which the text caret is
currently positioned at. The string is contained within double quotes on
each side? I know I can load the current line into a TStringList and the
use the Delimiter method to parse through the words but I only want the
word that the caret is at. Any ideas? Cheers, and thanks for the help!

Rory.
Back to top
Rory Walsh
Guest





PostPosted: Sat Apr 29, 2006 1:03 am    Post subject: Re: retrieving word at caret position? Reply with quote



Btw the string will most likely contain a '.' as it is a file name. Cheers,
Rory.

Rory Walsh wrote:
Quote:
Hi everyone. I would like to retrieve the string which the text caret is
currently positioned at. The string is contained within double quotes on
each side? I know I can load the current line into a TStringList and the
use the Delimiter method to parse through the words but I only want the
word that the caret is at. Any ideas? Cheers, and thanks for the help!

Rory.
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sat Apr 29, 2006 2:03 am    Post subject: Re: retrieving word at caret position? Reply with quote



"Rory Walsh" <rorywalsh (AT) ear (DOT) ie> wrote in message
news:4452aba5 (AT) newsgroups (DOT) borland.com...
Quote:
Hi everyone. I would like to retrieve the string which the text caret is
currently positioned at. The string is contained within double quotes on
each side? I know I can load the current line into a TStringList and the
use the Delimiter method to parse through the words but I only want the
word that the caret is at. Any ideas? Cheers, and thanks for the help!

If you are using a TRichEdit, then have a look at the EM_FINDWORDBREAK and
EM_FINDTEXT messages.


Gambit
Back to top
Rory Walsh
Guest





PostPosted: Sat Apr 29, 2006 9:03 am    Post subject: Re: retrieving word at caret position? Reply with quote

Thanks Remy. I tried the following but with no joy, can you see any
obvious mistakes?

int currpos = RichEdit1->SelStart;
int start = endMessage(RichEdit1->Handle,EM_FINDWORDBREAK,WB_LEFT,currpos);
int end =
SendMessage(RichEdit1->Handle,EM_FINDWORDBREAK,WB_RIGHTBREAK,start);
ShowMessage(RichEdit1->Text.SubString(start, end-start));

Thanks for the help.

Rory.

Remy Lebeau (TeamB) wrote:
Quote:
"Rory Walsh" <rorywalsh (AT) ear (DOT) ie> wrote in message
news:4452aba5 (AT) newsgroups (DOT) borland.com...
Hi everyone. I would like to retrieve the string which the text caret is
currently positioned at. The string is contained within double quotes on
each side? I know I can load the current line into a TStringList and the
use the Delimiter method to parse through the words but I only want the
word that the caret is at. Any ideas? Cheers, and thanks for the help!

If you are using a TRichEdit, then have a look at the EM_FINDWORDBREAK and
EM_FINDTEXT messages.


Gambit

Back to top
Rudy Velthuis [TeamB]
Guest





PostPosted: Sat Apr 29, 2006 9:03 am    Post subject: Re: retrieving word at caret position? Reply with quote

At 01:56:10, 29.04.2006, Rory Walsh wrote:

Quote:
Hi everyone. I would like to retrieve the string which the text caret
is currently positioned at. The string is contained within double
quotes on each side? I know I can load the current line into a
TStringList and the use the Delimiter method to parse through the words
but I only want the word that the caret is at. Any ideas? Cheers, and
thanks for the help!

The text caret in a TMemo, a TRichEdit, or what?

--
Rudy Velthuis [TeamB] http://rvelthuis.de/

"The truth is more important than the facts."
- Frank Lloyd Wright (1868-1959)
Back to top
Rory Walsh
Guest





PostPosted: Sat Apr 29, 2006 9:03 am    Post subject: Re: retrieving word at caret position? Reply with quote

A TRichEdit.....

Rudy Velthuis [TeamB] wrote:
Quote:
At 01:56:10, 29.04.2006, Rory Walsh wrote:

Hi everyone. I would like to retrieve the string which the text caret
is currently positioned at. The string is contained within double
quotes on each side? I know I can load the current line into a
TStringList and the use the Delimiter method to parse through the words
but I only want the word that the caret is at. Any ideas? Cheers, and
thanks for the help!

The text caret in a TMemo, a TRichEdit, or what?
Back to top
Rory Walsh
Guest





PostPosted: Sat Apr 29, 2006 11:03 am    Post subject: Re: retrieving word at caret position? Reply with quote

It works if I use Perform() rather than SendMessage, e.g.,

RichEdit1->Perform(EM_FINDWORDBREAK,WB_RIGHTBREAK,currpos);

I don't know why though? Thanks for the help,

Rory.

Rory Walsh wrote:
Quote:
Thanks Remy. I tried the following but with no joy, can you see any
obvious mistakes?

int currpos = RichEdit1->SelStart;
int start = endMessage(RichEdit1->Handle,EM_FINDWORDBREAK,WB_LEFT,currpos);
int end =
SendMessage(RichEdit1->Handle,EM_FINDWORDBREAK,WB_RIGHTBREAK,start);
ShowMessage(RichEdit1->Text.SubString(start, end-start));

Thanks for the help.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.