[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Color Sintax in Richedit

Posted on 1998-10-04
6
Medium Priority
?
209 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
  • 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 400 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
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!

 

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month18 days, 8 hours left to enroll

825 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