Solved

undo function

Posted on 1999-01-12
13
264 Views
Last Modified: 2010-04-06
I want the code to do an "undo" with a TMemo component.
If possible, extra points for a "redo" function. (like 500 more points)

Please, the code must works! :)
Thanks
0
Comment
Question by:elbaid
  • 4
  • 3
  • 3
  • +2
13 Comments
 

Author Comment

by:elbaid
ID: 1356217
Edited text of question
0
 

Expert Comment

by:mjustin
ID: 1356218
Replace TMemo by TRichEdit, UNDO is built-in there. You just need to send a Windows-API message (uses windos unit).
To check if UNDO is possible:
miUndo.enabled  := (Richedit.Perform(EM_CANUNDO, 0, 0)>0);
To perform UNDO:
Richedit.Perform(WM_UNDO, 0, 0);
I think redo is built-in too (its just the next call of UNDO).

0
 
LVL 20

Expert Comment

by:Madshi
ID: 1356219
If you want even a better control, download RichEdit98 from one of these sites (I think you will find a TMemo component with Undo/Redo, too):

Delphi Super Page:   http://nswt.tuwien.ac.at/delphi/index.htm
Torry's Delphi Pages:   http://www.torry.ru/

Regards, Madshi.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 20

Expert Comment

by:Madshi
ID: 1356220
I've looked again at Torry's Pages and this is what I found out:

You can download the freeware component TRichEdit98 from this location: "http://www.torry.ru/vcl/edits/richedit98.zip" and the RichEd20.dll (is needed for this component; is a new version of Microsoft) from this location: "http://www.torry.ru/vcl/edits/richedll.zip".

Regards, Madshi.

P.S.: If you use my download tips, I would (of course) like to have the points...  :-)))
0
 
LVL 20

Expert Comment

by:Madshi
ID: 1356221
P.P.S.: If you don't like RichEdit, you can download an extended memo component from this: "http://www.torry.ru/vcl/edits/ammemo1.zip" with undo functionality.
0
 
LVL 44

Expert Comment

by:bruintje
ID: 1356222
Well I saw a example of this done in a API call to a normal TMemo in one of the Inprise faqs

:O)
0
 

Author Comment

by:elbaid
ID: 1356223
so nobody can give me an code exemple of an undo?

I don't want a component, I want a simple code for an undo/redo on a TMemo component included with Delphi, nothing else.

800 points that's not enough?

PS: thanks for the links, but that's not what I asked...
If the answer (or code) is too complicated, tell me.
0
 
LVL 3

Expert Comment

by:philipleighs
ID: 1356224
Do you need to be spoon fed?
0
 
LVL 44

Expert Comment

by:bruintje
ID: 1356225
Well, I will in a split second this morning answered this question at almost the same time as mjustin, but was a bit late and my answer was nowhere.

But as I spoke of the Faq at

http://www.inprise.com/devsupport/delphi/qanda/FAQ2526D.html

here is an simple example

unit Unit1;
interface

uses
  Windows,
  Messages,
  SysUtils,
  Classes,
  Graphics,
  Controls,
  Forms,
  Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
  if Memo1.Perform(EM_CANUNDO, 0, 0) <> 0 then begin
    Memo1.Perform(EM_UNDO, 0, 0);
  end;
end;

end.

It uses a memo and a button on a form. To redo the undo just click the button another time and the undo is redone again :O)))

Hope this helps
brUINTje.

0
 

Author Comment

by:elbaid
ID: 1356226
philipleighs: yes!

bruintje: answer the question, i'll give you the points, thx!
0
 
LVL 44

Accepted Solution

by:
bruintje earned 800 total points
ID: 1356227
Hi elbaid,

Seeing the questions you asked, are you making some TMemo component yourself?

Anyway Good Luck.
:O)
brUINTje.
0
 
LVL 3

Expert Comment

by:philipleighs
ID: 1356228
You might like to know that there is a TMemo property called

TMemo.CanUndo: Boolean;

and a method called:

TMemo.Undo;

which doubles as Redo (call it twice).

They are both wrappers for EM_CANUNDO and EM_UNDO.

Incidentally, CanUndo and Undo are available for TEdits too.

Cheers,
Phil.

PS: Glad you didn't take offense  :)
0
 

Author Comment

by:elbaid
ID: 1356229
Thanks Phil!  I'm just a beginner, and i'm studying in that... so sometimes i need help
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

809 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