Board index » delphi » Adding characters to a TMemo

Adding characters to a TMemo

Hello All!

I need to be able to add single chars to a TMemo control, FAST! I think this
requires going through WM_KEYDOWN messages, but can't seem to get it to work.
Any suggestions welcome!

Best regards,
   Christian // ctib...@silver.ct.se
             // CServe 100777,2775

... A father is a banker provided by nature.

 

Re:Adding characters to a TMemo


Quote
christian.tib...@silver.ct.se (Christian Tiberg) wrote:
>Hello All!
>I need to be able to add single chars to a TMemo control, FAST! I think this
>requires going through WM_KEYDOWN messages, but can't seem to get it to work.
>Any suggestions welcome!
>Best regards,
>   Christian // ctib...@silver.ct.se
>             // CServe 100777,2775
>... A father is a banker provided by nature.

I use:

with Memo1 do
begin
  SelStart := GetTextLen;
  SelText := 'a';
end;

You may not need to set SelStart every time. This method also forces the cursor
to be in view, as opposed to
Memo1.Text := Memo1.Text + 'a';

-Tony Lownds

Re:Adding characters to a TMemo


How about:

if TheChar <> #10 then
   SendMessage(MyMemo.Handle, WM_CHAR, Word(TheChar),0);

John.

Other Threads