[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

insert/overwrite in Tmemo

Posted on 2000-05-08
5
Medium Priority
?
658 Views
Last Modified: 2010-04-04
I need to know how to set up a TMemo, so that i can either insert or overwrite the text, depending on what the user chooses. And if someone knows, how come borland haven't made that option available, considering that they use it in the IDE ?? ;-)
0
Comment
Question by:hatecapletters
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 1

Expert Comment

by:ronvp
ID: 2791404
Allthough not difficult There is no buildin way to do this with a standard memo control. So if you do want to use it, you would need to write a onkeydown event handler, and when a key is pressed, check if the user wants to overwrite and then delete the character immediately after the cursor. To do this proparly, you would also need to have a method to correctly handle a paste 0peration of multiple characters. i.e.: Delete from cursor position the number of characters that is on the clipboard before the paste operation is executed.

I do have a much easier method and that is to use a TRichEdit control which has all the functionality you want build in. You would not have to do anything else then to replace the Tmemo with a TRichEdit..
0
 

Author Comment

by:hatecapletters
ID: 2791663
i was thinking about that, but i'm using a colormemo, with elaborate colorcoding, and i'm not really reasy to re-write a trichedit to do that yet.
0
 
LVL 1

Accepted Solution

by:
ronvp earned 400 total points
ID: 2792048
Below is the code you need to add in your memo OnKeyPress handler
It will check if the overwrite mode is active and then checks if the esc or backspace keys are pressed if. It then call the windows sendmessage function to simulate a key press of the delete key.

   procedure TForm1.Memo1KeyPress(Sender: TObject; var Key: Char);
begin
   //Do not process Escape and Backspace keys
   If (Lo(GetKeystate(VK_INSERT)) = 1) and  Not(Ord(Key) in [8, 27]) then
         SendMessage(Memo1.Handle, WM_KEYDOWN, VK_DELETE, 1);
end;

You may want to check if there are more keys besides the esc and backspace keys that should not activate the call to sendmessage.. Also, if you do have onkeydown handler allready, you may need to provide some extra code to stop the above routine calling it..
0
 

Author Comment

by:hatecapletters
ID: 2803460
look s interessting, as soon as i get a bit of time, i'll look into it.

 
0
 

Author Comment

by:hatecapletters
ID: 2818735
sorry for the delay :-)

i had to work a bit on it, but you sent me in the right direction, thanks :-)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

656 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