Solved

undo function

Posted on 1999-01-12
13
269 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
[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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

729 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