Enables you to group a series of actions as a single action for use with _EdUndo(В ) and _EdRedo(В ).
void _EdUndoOn(WHANDLE wh, int Grouped) WHANDLE wh; /* Window handle. */ int Grouped; /* Toggle grouping off. */ |
Remarks
Actions that occur after you pass the Grouped parameter as FALSE with _EdUndoOn(В ), or after you issue _EdUndo(В ), are no longer grouped as a single action.
For more information on how to create an API library and integrate it with Visual FoxPro, see Accessing the Visual FoxPro API.
Example
The following example shows how to use _EdUndoOn(В ) to group edit operations that you can undo as a group using _EdUndo(В ).
Visual FoxPro Code
В | Copy Code |
---|---|
SET LIBRARY TO EDUNDOON = EDUNDOON("x") && edit file "x" |
C Code
В | Copy Code |
---|---|
#include <pro_ext.h> #define TRUE 1 #define FALSE 0 FAR Example(ParamBlk FAR *parm) { char FAR *pFileName; WHANDLE wh; if (!_SetHandSize(parm->p[0].val.ev_handle, parm->p[0].val.ev_length+1)) { _Error(182); // "Insufficient memory" } _HLock(parm->p[0].val.ev_handle); pFileName = (char FAR *) _HandToPtr(parm->p[0].val.ev_handle); pFileName[parm->p[0].val.ev_length] = '\0'; wh = _EdOpenFile(pFileName, FO_READWRITE); _HUnLock(parm->p[0].val.ev_handle); _EdUndoOn(wh, TRUE); // start undo group _EdSetPos(wh, _EdGetLinePos(wh, 13)); _EdInsert(wh, "Hello, world\n", _StrLen("Hello, world\n")); _EdSelect(wh, _EdGetLinePos(wh, 14), _EdGetLinePos(wh, 16)); _EdIndent(wh, 1); _EdUndoOn(wh, FALSE); // end undo group _EdUndoOn(wh, TRUE); // start another undo group _EdSelect(wh, _EdGetLinePos(wh, 9), _EdGetLinePos(wh, 12)); _EdDelete(wh); _EdSetPos(wh, _EdGetLinePos(wh, 13)); _EdInsert(wh, "Hello, world\n", _StrLen("Hello, world\n")); _Execute("WAIT WINDOW 'Press any key to undo changes.'"); _EdUndoOn(wh, TRUE); // undoes to start of undo group } FoxInfo myFoxInfo[] = { {"EDUNDOON", (FPFI) Example, 1, "C"}, }; FoxTable _FoxTable = { (FoxTable FAR *) 0, sizeof(myFoxInfo)/sizeof(FoxInfo), myFoxInfo }; |