// Mit dem
folgenden Code kann man in einem TRichEdit uses System.Win.ComObj, RichOLE; var State: Boolean = True; function UndoLock(Box: TCustomEdit; Lock: Boolean): Boolean; const UndoSuspend = -9999995; UndoResume = UndoSuspend + 1; var EditOle: IRichEditOle; Dispatch: IDispatch; Edt: OleVariant; Which: Integer; begin if Lock then Which := UndoSuspend else Which := UndoResume; if RichEdit_GetOleInterface(Box.Handle, EditOle) then begin OleCheck(EditOle.QueryInterface(IDispatch, Dispatch)); Edt := Dispatch; Edt.Undo(Which); Result := True; end else Result := False; end; // Beispielaufrufe procedure TForm1.Button1Click(Sender: TObject); begin if not UndoLock(RichEdit1, True) then ShowMessage('Locking error') else State := False; end; procedure TForm1.Button2Click(Sender: TObject); begin if not UndoLock(RichEdit1, False) then ShowMessage('Unlocking error') else State := True; end; procedure TForm1.Button3Click(Sender: TObject); begin if not State then ShowMessage('Undo is not possible') else RichEdit1.Undo; end;
|
Zugriffe seit
6.9.2001 auf Delphi-Ecke |