ImageEn, unit ImageEnProc

TImageEnProc.Undo

TImageEnProc.Undo

Declaration

procedure Undo(AutoUndoRedo: Boolean = False);

Description

Replaces the current image with the last image in the Undo stack.
Parameter Description
AutoUndoRedo Set to True for automatic undo/redo support. Saves the current state (before undo) to the redo stack (i.e. calls SaveRedo is called) and removes this entry from the Undo stack (i.e. using ClearUndo)

Note: AutoUndoRedo should always be set to True if you support multiple undo (i.e. UndoLimit > 1 )

Demo

Demo  Demos\ImageEditing\UndoRedo\UndoRedo.dpr

Example

// Multiple Undo/Redo Example

procedure TForm1.FormCreate(Sender: TObject);
begin
  ImageEnView1.Proc.UndoLimit := 20; // 20 levels of undo
end;

procedure TForm1.ImageEnView1ImageChange(Sender: TObject);
begin
  // When image changes update our menu items
  UpdateMenu();
end;

procedure TForm1.Undo1Click(Sender: TObject);
begin
  // Undo (with automatic saving of redo)
  ImageEnView1.Proc.Undo( True );
  UpdateMenu();
end;

procedure TForm1.Redo1Click(Sender: TObject);
begin
  // Redo (with automatic saving of undo)
  ImageEnView1.Proc.Redo( True );
  UpdateMenu();
end;

procedure TForm1.UpdateMenu();
begin
  // Undo menu
  Undo1.Enabled := ImageEnView1.Proc.CanUndo;
  if ImageEnView1.Proc.CanUndo then
    Undo1.Caption := 'Undo ' + ImageEnView1.Proc.UndoCaptions[0]
  else
    Undo1.Caption := 'Undo';

  // Redo menu
  Redo1.Enabled := ImageEnView1.Proc.CanRedo;
  if ImageEnView1.Proc.CanRedo then
    Redo1.Caption := 'Redo ' + ImageEnView1.Proc.RedoCaptions[0]
  else
    Redo1.Caption := 'Redo';
end;

See Also

◼AutoUndo
◼CanUndo
◼ClearAllUndo
◼ClearUndoAt
◼ClearUndo
◼GetUndoInfo
◼SaveUndo
◼UndoAt
◼UndoCaptions
◼UndoCount
◼UndoLimit
◼UndoLocation
◼UndoRect
◼OnSaveUndo
◼Redo

Compatibility Information

Prior to v6.2.1, AutoUndoRedo did not remove the undone item from the Undo List. From v6.3.0, AutoUndoRedo clears the entries.