473,320 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

undo function - programming methods

Does anyone have information regarding programming methods
used to include 'UNDO' functionality into a simple editor?
Nov 15 '05 #1
6 1864
Both the textbox and richtextbox have an "Undo" method which can be called
directly. Do you need something really advanced or will this do it for you?

I've written something that can go back to a specific point back instead of
just undoing it, but it's a lot of code and not very elegant. However, if
you need somethign like that let me know and I'll send you what I have.

Bill
"Steve" <ho******@cmmts.com> wrote in message
news:07****************************@phx.gbl...
Does anyone have information regarding programming methods
used to include 'UNDO' functionality into a simple editor?

Nov 15 '05 #2
Bill,

that will do the job - I hadn't realised undo was
available as a function of the control. I appreciate the
tip.
-----Original Message-----
Both the textbox and richtextbox have an "Undo" method which can be calleddirectly. Do you need something really advanced or will this do it for you?
I've written something that can go back to a specific point back instead ofjust undoing it, but it's a lot of code and not very elegant. However, ifyou need somethign like that let me know and I'll send you what I have.
Bill
"Steve" <ho******@cmmts.com> wrote in message
news:07****************************@phx.gbl...
Does anyone have information regarding programming methods used to include 'UNDO' functionality into a simple
editor?

.

Nov 15 '05 #3
If you aren't looking for multiple levels of undo, you can take
advantage of the built-in undo handling that many controls already catch,
with the WM_UNDO message. I wrote this in VB.NET but I'll convert a couple
of lines to C# for you (untested!):

First, import sendmessage:

[DllImport("user32.dll", EntryPoint = "SendMessageA")]
public static extern uint SendMessage(IntPtr hWnd, uint wMsg,
uint wParam, uint lParam);

Also, declare:
public const int WM_UNDO = 0x304;

Then, test this anywhere in your windows forms code:

SendMessage(this.ActiveControl.Handle, WM_UNDO, 0, 0)

A bit of a hack, but it gets the job done if you want something
simple!

Erik

"Steve" <ho******@cmmts.com> wrote in message
news:07****************************@phx.gbl...
Does anyone have information regarding programming methods
used to include 'UNDO' functionality into a simple editor?

Nov 15 '05 #4
Steve,
"Design Patterns - Elements of Reusable Object-Oriented Software" by the GOF
(Gang of Four) Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides from
Addison Wesley Professional Computing Series has a discussion on Undo & Redo
based on the Command Pattern.

Hope this helps
Jay

"Steve" <ho******@cmmts.com> wrote in message
news:07****************************@phx.gbl...
Does anyone have information regarding programming methods
used to include 'UNDO' functionality into a simple editor?

Nov 15 '05 #5
Erik:

Thanks for the tip. I've built something on the fly using a stack, but was
yucky. I've been looking for something a bit more elegant and this is it.

Thanks,

Bill
"Erik Frey" <er*******@hotmail.com> wrote in message
news:Ov**************@TK2MSFTNGP11.phx.gbl...
If you aren't looking for multiple levels of undo, you can take
advantage of the built-in undo handling that many controls already catch,
with the WM_UNDO message. I wrote this in VB.NET but I'll convert a couple of lines to C# for you (untested!):

First, import sendmessage:

[DllImport("user32.dll", EntryPoint = "SendMessageA")]
public static extern uint SendMessage(IntPtr hWnd, uint wMsg,
uint wParam, uint lParam);

Also, declare:
public const int WM_UNDO = 0x304;

Then, test this anywhere in your windows forms code:

SendMessage(this.ActiveControl.Handle, WM_UNDO, 0, 0)

A bit of a hack, but it gets the job done if you want something
simple!

Erik

"Steve" <ho******@cmmts.com> wrote in message
news:07****************************@phx.gbl...
Does anyone have information regarding programming methods
used to include 'UNDO' functionality into a simple editor?


Nov 15 '05 #6
Well, I have asked enough questions on this NG that it's nice to have an
answer, for once :)

Glad it helped.

"William Ryan" <do********@comcast.nospam.net> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Erik:

Thanks for the tip. I've built something on the fly using a stack, but was yucky. I've been looking for something a bit more elegant and this is it.

Thanks,

Bill

Nov 15 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Mickel Grönroos | last post by:
Hello everybody I'm developing a tool in Tkinter and would like to add Undo and Redo commands to my Edit menu. Does somebody know if anybody has implemented standard Undo/Redo as a Python...
6
by: lkrubner | last post by:
I'm offering users the ability to type weblog posts into a form and post them. They type the text into a TEXTAREA which is on a form. The form, when submitted, hits a PHP script. Before it is...
0
by: Wiktor Zychla | last post by:
I am still trying to get the Undo function work on Internet Explorer editor hosted as activex in my c# application. Some time ago I've found a note at msdn that says "undo is not supported". I...
3
by: babylon | last post by:
any facilities in csharp that can help me implmenting undo/redo in my application? thx
1
by: Alan | last post by:
Hi all, I'm programming one VBScript Editor with syntax hilighting. I use the RichTextBox control. Although the syntaxhilighting function comes true, i found the undo/redo function didn't work. I...
4
by: =?Utf-8?B?UmljaA==?= | last post by:
Hello, Does vb2005 have a built-in UnDo feature / object for applications so that I can undo actions like other windows apps? Or do I have to write my own UnDo routine? If vb2005 does have a...
7
by: call_me_anything | last post by:
Hi, I am looking for a good algorithm (in C/C++) for implementing undo/ redo on a data structure. The data structure is basically a n-children tree somewhat of the form : class /* or...
1
by: Jeremy | last post by:
I'm working on an application that does some DOM manipulation. I want to add a mechanism for "Undo" so that the user can revert to the previous state after performing a mistaken action. Simple...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.