 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Rory Walsh Guest
|
Posted: Sat Apr 29, 2006 1:03 am Post subject: retrieving word at caret position? |
|
|
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
|
Posted: Sat Apr 29, 2006 1:03 am Post subject: Re: retrieving word at caret position? |
|
|
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
|
Posted: Sat Apr 29, 2006 2:03 am Post subject: Re: retrieving word at caret position? |
|
|
"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
|
Posted: Sat Apr 29, 2006 9:03 am Post subject: Re: retrieving word at caret position? |
|
|
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
|
Posted: Sat Apr 29, 2006 9:03 am Post subject: Re: retrieving word at caret position? |
|
|
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
|
Posted: Sat Apr 29, 2006 9:03 am Post subject: Re: retrieving word at caret position? |
|
|
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
|
Posted: Sat Apr 29, 2006 11:03 am Post subject: Re: retrieving word at caret position? |
|
|
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 |
|
 |
|
|
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
|
|