// Der Code zeigt
eine Möglichkeit für Undo und Redo bei einem type TForm1 = class(TForm) RichEdit1: TRichEdit; Undo: TButton; Redo: TButton; procedure FormCreate(Sender: TObject); procedure RichEdit1Change(Sender: TObject); procedure UndoClick(Sender: TObject); procedure RedoClick(Sender: TObject); private { Private-Deklarationen } public { Public-Deklarationen } end; var Form1: TForm1; implementation {$R *.dfm} uses Richedit; const EM_REDO = WM_USER + $54; wieoft = 10; procedure TForm1.FormCreate(Sender: TObject); begin RichEdit1.Text := ''; Undo.Enabled := FALSE; Redo.Enabled := FALSE; sendmessage(RichEdit1.handle, EM_REDO, 0, 0); sendmessage(RichEdit1.handle, EM_SETUNDOLIMIT, wieoft, 0); RichEdit1.Perform(EM_EMPTYUNDOBUFFER, 0, 0); end; procedure TForm1.RichEdit1Change(Sender: TObject); begin Redo.Enabled := RichEdit1.Perform(EM_CANREDO, 0, 0) <> 0; Undo.Enabled := RichEdit1.Perform(EM_CANUNDO, 0, 0) <> 0; end; procedure TForm1.UndoClick(Sender: TObject); begin RichEdit1.Undo; end; procedure TForm1.RedoClick(Sender: TObject); begin sendmessage(RichEdit1.handle, EM_REDO, 0, 0); end;
|
Zugriffe seit 6.9.2001 auf Delphi-Ecke