trichview.support
Re: custom undo items? |
Author |
Message |
Sergey Tkachenko |
Posted: 10/24/2004 17:56:53 type TRVUndoBackColor = class(TRVUndoInfo) private FColor: TColor; public procedure Undo(RVData: TRichViewRVData); override; function RequiresFormat: Boolean; override; end; function TRVUndoBackColor.RequiresFormat: Boolean; begin Result := False; end; procedure ChangeRichViewEditColor(RVData: TRichViewRVData; Color: TColor); var ui: TRVUndoBackColor; list: TRVUndoList; rve: TCustomRichViewEdit; begin list := TRVEditRVData(RVData).GetUndoList; if list<>nil then begin ui := TRVUndoBackColor.Create; ui.FColor := TRichViewEdit(RVData.GetRootData.GetParentControl).Color; list.AddInfo(ui) end; rve := TCustomRichViewEdit(RVData.GetRootData.GetParentControl); rve.Color := Color; while rve<>nil do begin rve.Invalidate; rve := TCustomRichViewEdit(rve.InplaceEditor); end; end; procedure TRVUndoBackColor.Undo(RVData: TRichViewRVData); begin ChangeRichViewEditColor(RVData, FColor); end; How to test: procedure TForm3.Button1Click(Sender: TObject); begin RichViewEdit1.BeginUndoGroup(rvutModifyItem); { Note: rvutModifyItem may be not appropriate, but there are no appropriat standard constant for this undo action. You can use BeginUndoCustomGroup, though. } ChangeRichViewEditColor(RichViewEdit1.RVData, clRed); end; > > Hi, > > If offer the option to change the entire background of the RVE in my application > by changing rve.color (e.g. rve.color:=clred). However when I change the > rve to a new color this action is not undo-able. Changing rve text or paragraph > color can be undone fine. > > Can you suggest a way to make it undo-able, or should I be changing the entire > background color some other way? > > Thanks |
Powered by ABC Amber Outlook Express Converter