Beispiel #1
0
//---------------------------------------------------------------------------
void TMain::ColorLog(UnicodeString token)
{
	int pos = 0;
	int foundAt = m_log->FindText(token,pos,m_log->Text.Length(),TSearchTypes());

	while(foundAt!=-1)
	{
		m_log->SelStart = foundAt;
		m_log->SelLength = token.Length();
		m_log->SelAttributes->Color = (TColor)0x00FF0080;

		pos = foundAt + token.Length();
		foundAt = m_log->FindText(token,pos,m_log->Text.Length(),TSearchTypes());
	}
	m_log->SelStart = m_log->Text.Length();
}
//---------------------------------------------------------------------------
void __fastcall TSourceCodeForm1::ReplaceDialog1Find(TObject *Sender)
{
    int FoundAt, StartPos, ToEnd;
    if(RichEdit1->SelLength) StartPos = RichEdit1->SelStart + RichEdit1->SelLength;
    else                     StartPos = 0;
    ToEnd = RichEdit1->Text.Length() - StartPos;
    FoundAt = RichEdit1->FindText(ReplaceDialog1->FindText, StartPos, ToEnd, TSearchTypes()<< stMatchCase);
    if(FoundAt != -1) {
        RichEdit1->SetFocus();
        RichEdit1->SelStart = FoundAt;
        RichEdit1->SelLength = ReplaceDialog1->FindText.Length();
    }
}
//---------------------------------------------------------------------------
void __fastcall TSourceCodeForm1::FindDialog1Find(TObject *Sender)
{
    // begin the search after the current selection if there is one
    // otherwise, begin at the start of the text
    int FoundAt, StartPos, ToEnd;
    if(RichEdit1->SelLength) StartPos = RichEdit1->SelStart + RichEdit1->SelLength;
    else                     StartPos = 0;

    // ToEnd is the length from StartPos to the end of the text in the rich edit control
    ToEnd = RichEdit1->Text.Length() - StartPos;
    FoundAt = RichEdit1->FindText(FindDialog1->FindText, StartPos, ToEnd, TSearchTypes()<< stMatchCase);
    if(FoundAt != -1) {
        RichEdit1->SetFocus();
        RichEdit1->SelStart = FoundAt;
        RichEdit1->SelLength = FindDialog1->FindText.Length();
    }
}