Thanks so far. Sure, You are right, I tried now to create my own subclasses. But I'm new in that, so it fails. (I work on that great word processor, unit3 from your zip) That is, what I've done:
1. in dmActions.pas (copied to my project) inserted
Code: Select all
rvActionInsertCDate: TmyActionInsertCDate;
2. myActions.pas
Code: Select all
unit myActions;
interface
{$I RV_Defs.inc}
uses
Windows, Messages, Classes, Graphics, SysUtils, Controls, StdCtrls,
Printers, Dialogs, Forms, ShellApi, Clipbrd,
{$IFDEF RICHVIEWDEF6}
DateUtils,
{$ENDIF}
RichView, rvrvData, rvEdit, ActnList, RVTable,
RVItem, RVStyle, RVTInplace, rvScroll, rvUni, PtblRV, RVERVData, RVMisc,
{$IFDEF USERVXML}
RichViewXML,
{$ENDIF}
{$IFDEF USERVHTML}
RVHTMLImport, RVNormalize,
{$ENDIF}
{$IFDEF USERVADDICT3}
ad3RichViewCmpnts, ad3SpellBase,
{$ENDIF}
{$IFDEF USERVKSDEVTE}
te_controls,
{$ENDIF}
{$IFDEF USEINDY}
idhttp,
{$ENDIF}
{$IFDEF USEJVCL}
JvWinDialogs,
{$ENDIF}
{$IFDEF USETB2K}
TB2Item,
{$ENDIF}
{$IFDEF USETBX}
TBX,
{$ENDIF}
CRVData, RVClasses,RVOfficeCnv, ExtDlgs, RVFuncs, Menus,
RVALocalize, RichViewActions;
type
TmyAction = class(TrvAction);
TmyActionInsertCDate = class(TmyAction)
private
FOnInsertCDate: TRVAInsertTextEvent;
public
procedure ExecuteTarget(Target: TObject); override;
procedure UpdateTarget(Target: TObject); override;
published
property OnInsertCDate: TRVAInsertTextEvent read FOnInsertCDate write FOnInsertCDate;
end;
implementation
procedure TmyActionInsertCDate.ExecuteTarget(Target: TObject);
var rve: TCustomRichViewEdit;
s: String;
begin
if Assigned(FOnInsertCDate) then begin
rve := GetControl(Target);
s := FormatDateTime('d. mmmm yyyy', Now);
// FOnInsertText(Self, rve, s); ###comple error
rve.InsertText(s);
end else
Beep;
end;
procedure TmyActionInsertCDate.UpdateTarget(Target: TObject);
var rve: TCustomRichViewEdit;
begin
if not RVA_ActionsEnabled or Disabled then begin
Enabled := False;
exit;
end;
rve := GetControl(Target).TopLevelEditor;
Enabled := rve.RVData.PartialSelectedItem=nil;
end;
end.
3. Translation: todo
Whe I compile it, I get a message "rvActionInsertCDate must be from class TAction, should I correct it?". Clicking on "no", it compiles, but the menu entry in my app is disabled.
May be, I do it completly wrong. Can you give me please a working example?
Much thanks,
Frank