Board index » cppbuilder » How to get a fuction working ONLY for a specific selection, NOT entire RichEdit->Text

How to get a fuction working ONLY for a specific selection, NOT entire RichEdit->Text


2003-08-14 05:41:43 AM
cppbuilder31
hi dear builders,
one more question..
how can I change some functions that are doing some textmanipulation
work on a entire RichEdit1->Text ONLY to work for a specific selection ???
So NOT for the whole Text in the RichEdit, only for a certain selection...
For doing that I want to place a CheckBox, so the user can choose
if he wants the function to work for the whole text or only the selection..
if(CheckBox1->Cheked == true)
{
// Only selection !!!
}
else
{
// Whole text...
}
I know I have to use the SelStart, SelLength...but HOW ??
This is not realy easy because I don't know where the selection starts, how
long it is and where the selection ends...
Thanks for any help...
Oren
/*****************************************************/
void __fastcall TfrmStringDetails::cmdSeperate_LettersClick(TObject *Sender)
{
// buggy function , not work very well :-) !!!!!
RichEdit1->Lines->BeginUpdate();
try
{
int iCount = RichEdit1->Lines->Count;
for(int i = 0; i < iCount; ++i)
{
AnsiString str = RichEdit1->Lines->Strings[i];
AnsiString temp;
for(int x = 1; x <= str.Length(); ++x)
temp += str[x] + " ";
RichEdit1->Lines->Strings[i] = temp;
}
}
__finally {RichEdit1->Lines->EndUpdate();}
}
 
 

Re:How to get a fuction working ONLY for a specific selection, NOT entire RichEdit->Text

"Oren \(Halvani.de\)" < XXXX@XXXXX.COM >wrote:
Quote
[...] I know I have to use the SelStart, SelLength...but HOW ??
Maybe - maybe not. It depends on what you want to do.
Quote
This is not realy easy because I don't know where the selection starts, how
long it is and where the selection ends...
Then you're out of luck. You must have a way of knowing where
the sub string starts and ends if you're going to manipulate
it.
Perhaps if you provided some sample data and a description of
what you want to accomplish ...
~ JD
 

Re:How to get a fuction working ONLY for a specific selection, NOT entire RichEdit->Text

"Oren (Halvani.de)" < XXXX@XXXXX.COM >wrote in message
Quote
how can I change some functions that are doing some
textmanipulation work on a entire RichEdit1->Text
ONLY to work for a specific selection ???
Use the SelText property instead.
Quote
This is not realy easy because I don't know where the selection starts,
how
long it is and where the selection ends...
You don't need to know, either. The SelText property handles that for you.
Gambit
 

{smallsort}

Re:How to get a fuction working ONLY for a specific selection, NOT entire RichEdit->Text

"JD" < XXXX@XXXXX.COM >wrote in message
Quote
Then you're out of luck. You must have a way of knowing
where the sub string starts and ends if you're going to
manipulate it.
No, you don't. See my other reply.
Gambit
 

Re:How to get a fuction working ONLY for a specific selection, NOT entire RichEdit->Text

Thanks Remy...I realy can't remember how OFTEN I say that :-)
Oren