Solved

undo function

Posted on 1999-01-12
13
263 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

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…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

786 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