Board index » cppbuilder » Finding the select start in TRichEdit

Finding the select start in TRichEdit


2005-09-03 11:54:47 AM
cppbuilder24
I'm using TRichEdit for the first time. I want to change the font (at
least the color) of certain words if they start a line. My plan is to
go through the TRichEdit a line at a time and test to see if the words
start the line and if they do change the font. I think I see how to do
this by selecting the text etc. but how do I get the start of the
selected text?
That is I know that one of the words starts this line
RichEdit->Lines->Strings[i]
so how do I get RichEdit->SelStart?
TIA
NATE
 
 

Re:Finding the select start in TRichEdit

Maybe something like this:
UNTESTED !!!
int total_bytes = 0;
for ( int i=0; i<RichEdit->Lines->Count; i++ )
{
//if ( YOU DETECTED THAT Strings[i] MATCHES YOUR CRITERIA )
// USE SelStart = total_bytes WHICH NOW POINTS TO THE BEGINNING
// OF THE Strings[i]
int row_len = RichEdit->Lines->Strings[i].Length() + 2; // 2 is CR+LF
total_bytes += row_len;
}
--
Best regards,
Vladimir Stefanovic
"Nate Lockwood" < XXXX@XXXXX.COM >wrote in message
Quote
I'm using TRichEdit for the first time. I want to change the font (at
least the color) of certain words if they start a line. My plan is to go
through the TRichEdit a line at a time and test to see if the words start
the line and if they do change the font. I think I see how to do this by
selecting the text etc. but how do I get the start of the selected text?

That is I know that one of the words starts this line
RichEdit->Lines->Strings[i]
so how do I get RichEdit->SelStart?

TIA

NATE
 

Re:Finding the select start in TRichEdit

Vladimir Stefanovic wrote:
Quote
Maybe something like this:
UNTESTED !!!

int total_bytes = 0;
for ( int i=0; i<RichEdit->Lines->Count; i++ )
{
//if ( YOU DETECTED THAT Strings[i] MATCHES YOUR CRITERIA )
// USE SelStart = total_bytes WHICH NOW POINTS TO THE BEGINNING
// OF THE Strings[i]

int row_len = RichEdit->Lines->Strings[i].Length() + 2; // 2 is CR+LF
total_bytes += row_len;
}

Thanks, Vladimir, works just fine.
Nate
 

{smallsort}