Solved

undo function

Posted on 1999-01-12
13
259 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
 
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now