Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8364241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:23:09+00:00 2026-06-09T12:23:09+00:00

I would like to send a BackSpace control char to a TMemo like the

  • 0

I would like to send a BackSpace control char to a TMemo like the user would actually press the BackSpace button.

My Memo is readonly and if I click a button it should delete the last char in the memo.
I would like to do that without using Memo.Text := … (so no redraw or beginupdate, etc.)
Is that possible, if yes, how?

Thank you for your help.

EDIT: I tried to add #8 but no luck…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T12:23:10+00:00Added an answer on June 9, 2026 at 12:23 pm

    Sending a key press to a read only memo won’t work. The key press will be ignored because the memo is read only. To delete the final character of a memo in an efficient way, that is without replacing the entire contents, you can use EM_SETSEL and EM_REPLACESEL.

    var
      Len: Integer;
    begin
      Len := Memo1.GetTextLen;
      SendMessage(Memo1.Handle, EM_SETSEL, Len-1, Len);
      SendMessage(Memo1.Handle, EM_REPLACESEL, 0, LPARAM(PChar('')));
    end;
    

    Or if you prefer a pure VCL version which wraps up these Windows messages:

    begin
      Memo1.SelStart := Memo1.GetTextLen-1;
      Memo1.SelLength := 1;
      Memo1.SelText := '';
    end;
    

    The latter probably sends a few more Windows messages, but is much easier to read. I would prefer the latter option.

    One possible problem I can see with this is that it may not do what you want with line breaks. Since a Windows line break is two characters (CR+LF), you would need to delete two characters if the last character in the memo was LF. To handle that you can probably do it like this:

    begin
      Memo1.SelStart := Memo1.GetTextLen-1;
      Memo1.SelLength := 1;
      if Memo1.SelText=#10 then
      begin
        Memo1.SelStart := Memo1.SelStart-1;
        Memo1.SelLength := 2;
      end;
      Memo1.SelText := '';
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to send email from an address I control, but currently this
I would like to send keys to a c# web browser control element directly,
I would like to send POST message using bash script.In body there should be
I would like to send and receive bytes over serial. My receiver should get
I would like to customize the look&feel of the facebook send button. Instead of
I would like to send a push notification to the user but I want
I would like to send the message from HelloWorldLayer, and receive it in ScoreLayer,
I would like to send a javascript array to be processed by a method
I would like to send a html string with a GET request like this
I would like to send and receive OpenSoundControl in an AIR application, on the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.