_EdUndo( ) API Library Routine

Visual Studio .NET 2003

Undoes the single most recent change made to the file in the specified window.

void _EdUndo(WHANDLE wh)
WHANDLE wh;            /* Handle of editing window. */


When the user makes changes to a file, these changes are recorded in the undo buffer. _EdUndo( ) can be issued multiple times to undo multiple changes. You can't undo a change made prior to issuing _EdSave( ).

For more information on how to create an API library and integrate it with Visual FoxPro, see Accessing the Visual FoxPro API.


The following example opens a file specified by a parameter for editing. After inserting a new line, it uses _EdUndo( ) to delete the line, and then calls _EdRedo( ) to restore the inserted line.

Visual FoxPro Code

= EDREDO("x")

C Code

#include <pro_ext.h>

FAR Example(ParamBlk FAR *parm)
#define pFILENAME ((char FAR *) _HandToPtr(parm->p[0].val.ev_handle))

   WHANDLE wh;

   if (!_SetHandSize(parm->p[0].val.ev_handle,
      _Error(182); // "Insufficient memory"
   pFILENAME[parm->p[0].val.ev_length] = '\0';

   wh = _EdOpenFile(pFILENAME, FO_READWRITE);

   _EdSetPos(wh, _EdGetLinePos(wh, 13));
   _EdInsert(wh, "Hello, world\n", _StrLen("Hello, world\n"));

   _Execute("WAIT WINDOW 'New line inserted.\
      Press any key to undo.'");

   _Execute("WAIT WINDOW 'Insertion undone.  Press any key to redo.'");

FoxInfo myFoxInfo[] = {
   {"EDREDO", (FPFI) Example, 1, "C"},
FoxTable _FoxTable = {
   (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo

See Also

_EdRedo( ) API Library Routine | _EdUndoOn( ) API Library Routine | _EdSave( ) API Library Routine | Accessing the Visual FoxPro API