Solved

Color Sintax in Richedit

Posted on 1998-10-04
6
202 Views
Last Modified: 2013-11-22
Like to the Word, I need to create a function that underlines some words, when typed, but I don't know to make this.I would like to know if somebody  could help me.
0
Comment
Question by:sabadao
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 4

Expert Comment

by:BoRiS
ID: 1341719
sabadao

You mean if there is an error in spelling or if they choose to underline a word.

Later
BoRiS
0
 
LVL 10

Accepted Solution

by:
viktornet earned 100 total points
ID: 1341720
Here is an example of what you want.... Hope it helps... ;->

procedure UnderLine(RichEdit : TRichEdit; sWord : string);
var
  nPos : Integer;
  OldStart;
begin
  nPos := Pos(sWord, RichEdit.Text);
  OldStart := RichEdit.SelStart;
  if nPos > 0 then begin
    RichEdit.SetFocus;
    RichEdit.SelStart := nPos - 1;
    RichEdit.SelLength := Length(sWord);
    RichEdit.SelAttributes.Style := RichEdit.SelAttributes.Style + [fsUnderline];
  end;
  RichEdit.SelStart := OldStart;
end;

//Example call...

procedure TForm1.FormClick(Sender: TObject);
begin
  UnderLine(RichEdit1, 'Hello');
end;

Regards,
Viktor Ivanov
0
 

Author Comment

by:sabadao
ID: 1341721
Ok, but I need, to Test all time when the user keypress, and if was correct I need to take out the underline.....Like the delphi too. It underline the reserved word.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:sabadao
ID: 1341722
And these procedure pick the first word only. I need a procedure , that could test all the words.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1341723
Ok, I'll test for w while and give you the finaly procedure that works.... Is that OK???

//Viktor
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1341724
Here is something.....

procedure UnderLine(RichEdit : TRichEdit; sWord : string);
var
  nPos, OldStart, Len : Integer;
begin
  nPos := Pos(sWord, RichEdit.Text);
  OldStart := RichEdit.SelStart;
  RichEdit.SetFocus;
  while nPos > 0 do begin
    RichEdit.SelStart := nPos - 1;
    RichEdit.SelLength := Length(sWord);
    RichEdit.SelAttributes.Style := RichEdit.SelAttributes.Style + [fsUnderline];
    RichEdit.SelLength := 0;
    RichEdit.SelAttributes.Style := RichEdit.SelAttributes.Style - [fsUnderline];
    Len := Pos(sWord, Copy(RichEdit.Text, (nPos-1) + Length(sWord), Length(RichEdit.Text)));
    if Len <> 0 then
        nPos := nPos + (Len+1)
    else
        break;
  end;
  RichEdit.SelStart := OldStart;
end;

Example Call:

Underline(RichEdit1, 'Hello');

Regards,
Viktor Ivanov
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question