raunol
asked on
Is it possible to change a line color of a RichEdit without selection?
Is it possible to change a line color of a RichEdit without selection?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Yep Rauno, it's nicer with perform. regards, ZiF.
ASKER
Hi, Zif
Thanks for Your comment. Dont be sorry, but
in fact, I was glad too early. The selection
still flashes when to colour a line which is
longer. So Your answer wasn't perfect for my problem:
How to colour line without selection.
Anyway You gave a good advice using of api
functions.
- Rauno
Thanks for Your comment. Dont be sorry, but
in fact, I was glad too early. The selection
still flashes when to colour a line which is
longer. So Your answer wasn't perfect for my problem:
How to colour line without selection.
Anyway You gave a good advice using of api
functions.
- Rauno
Sorry, it doesn't works. I'll look for a solution.
ASKER
Hi, Zif
Now, I found a one solution my self.
First we must add "RichEdit" -unit to USES section
Then it's possible to use Sendmessage or
perform function:
RichEdit1.Perform(EM_HIDES ELECTION,1 ,0)
And voila! No selection flashes during colouring.
- Rauno
Now, I found a one solution my self.
First we must add "RichEdit" -unit to USES section
Then it's possible to use Sendmessage or
perform function:
RichEdit1.Perform(EM_HIDES
And voila! No selection flashes during colouring.
- Rauno
Hi Rauno,
Great solution! Thanks for letting me know of this!
Regards Zif.
Great solution! Thanks for letting me know of this!
Regards Zif.
ASKER
Good idea! Thank You very much, Zif.
It works just like I want, a selection not
flashes during colouring. I feel that Perform
function is rather nicer code to use than Sendmessage,
like this:
//colouring of the current line
Procedure TForm1.Button1Click(Sender
var
iStart, iEnd: longint;
iSelStart, iSelEnd: longint;
CurrentLine:Longint;
Begin
Whit RichEdit1 do
Begin
Lines.BeginUpdate;
Perform(EM_GETSEL, LongInt( @iStart ), LongInt( @iEnd ));
//Get the current line
CurrentLine:=Perform(EM_LI
//Starpos in the begin of the line
iSelStart:= Perform(EM_LINEINDEX,Curre
iSelEnd := iSelStart+Length(Lines[Cur
Perform(EM_SETSEL, iSelStart, iSelEnd );
// change the color of the text
SelAttributes.Color := clRed;
// return to saved position
Perform(EM_SETSEL, iStart, iEnd );
Lines.EndUpdate;
Setfocus;
End;
- Rauno