Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 286
  • Last Modified:

undo function

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
elbaid
Asked:
elbaid
  • 4
  • 3
  • 3
  • +2
1 Solution
 
elbaidAuthor Commented:
Edited text of question
0
 
mjustinCommented:
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
 
MadshiCommented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
MadshiCommented:
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
 
MadshiCommented:
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
 
bruintjeCommented:
Well I saw a example of this done in a API call to a normal TMemo in one of the Inprise faqs

:O)
0
 
elbaidAuthor Commented:
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
 
philipleighsCommented:
Do you need to be spoon fed?
0
 
bruintjeCommented:
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
 
elbaidAuthor Commented:
philipleighs: yes!

bruintje: answer the question, i'll give you the points, thx!
0
 
bruintjeCommented:
Hi elbaid,

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

Anyway Good Luck.
:O)
brUINTje.
0
 
philipleighsCommented:
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
 
elbaidAuthor Commented:
Thanks Phil!  I'm just a beginner, and i'm studying in that... so sometimes i need help
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 4
  • 3
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now