help replacing a character
Posted: Fri Apr 21, 2006 7:36 am
Hi there,
I am writing a copybook-like editor with richview
// First of all, I build two text style: one for background text in gray and
// one for normal text (typing) in green
// then, I add the background text which apply the textstyle(0)
CopyBook.InsertText('This is a test text', true);
// then, I rewrite the keypress function where I fill each character
// with a specific color
procedure TTestForm.CopyBookKeyPress(Sender: TObject; var Key: Char);
var
ss :Integer;
ch :String;
begin
if (key<>#13) and (key>#30) then
begin
CopyBook.ApplyTextStyle(1); // textstyle(1) for typing character
CopyBook.InsertText(key, False);
key := #0;
end;
end;
Now, everything is all right expect that the charater where I type will be inserted to the current caret position rather than replace the character at current position. Any approach for that problem.
BTW, how can I capture when the Enter is pressed?
Thanks in advance.
I am writing a copybook-like editor with richview
// First of all, I build two text style: one for background text in gray and
// one for normal text (typing) in green
// then, I add the background text which apply the textstyle(0)
CopyBook.InsertText('This is a test text', true);
// then, I rewrite the keypress function where I fill each character
// with a specific color
procedure TTestForm.CopyBookKeyPress(Sender: TObject; var Key: Char);
var
ss :Integer;
ch :String;
begin
if (key<>#13) and (key>#30) then
begin
CopyBook.ApplyTextStyle(1); // textstyle(1) for typing character
CopyBook.InsertText(key, False);
key := #0;
end;
end;
Now, everything is all right expect that the charater where I type will be inserted to the current caret position rather than replace the character at current position. Any approach for that problem.
BTW, how can I capture when the Enter is pressed?
Thanks in advance.