Einzelnen Beitrag anzeigen

r29d43

Registriert seit: 18. Jan 2007
287 Beiträge
 
Delphi 10.4 Sydney
 
#5

AW: IOTA-Editor mit sowas wie einem OnChange-Handler?

  Alt 10. Mai 2021, 19:00
Ja, super, danke! Funktioniert!

Ich habe das jetzt mal etwas minimalistisch so abgeleitet/hergeleitet (ausgehend von stahli's TViewPaintNotifier)

Delphi-Quellcode:
unit EditServiceNotifer;

interface

uses
  ToolsAPI, Winapi.Windows, System.Types, Vcl.Graphics, System.Classes, DockForm;

type
  TEditNotifierHelper = class(TInterfacedObject, IOTANotifier, INTAEditServicesNotifier)
  private
  public
    constructor Create;
    destructor Destroy; override;
  public
    // INTAEditServicesNotifier
    procedure WindowShow(const EditWindow: INTAEditWindow; Show, LoadedFromDesktop: Boolean);
    procedure WindowNotification(const EditWindow: INTAEditWindow; Operation: TOperation);
    procedure WindowActivated(const EditWindow: INTAEditWindow);
    procedure WindowCommand(const EditWindow: INTAEditWindow; Command, Param: Integer; var Handled: Boolean);
    procedure EditorViewActivated(const EditWindow: INTAEditWindow; const EditView: IOTAEditView);
    procedure EditorViewModified(const EditWindow: INTAEditWindow; const EditView: IOTAEditView);
    procedure DockFormVisibleChanged(const EditWindow: INTAEditWindow; DockForm: TDockableForm);
    procedure DockFormUpdated(const EditWindow: INTAEditWindow; DockForm: TDockableForm);
    procedure DockFormRefresh(const EditWindow: INTAEditWindow; DockForm: TDockableForm);
    // IOTANotifier
    procedure AfterSave;
    procedure BeforeSave;
    procedure Destroyed;
    procedure Modified;
  end;

procedure Register;
procedure RemoveNotifier;

implementation

uses
  System.SysUtils, Vcl.Dialogs, System.Generics.Collections, readEditorCode_Unit;


var
  NotifierIndex : integer = -1;


procedure Register;
var
  Services: IOTAEditorServices;
begin
  Services := BorlandIDEServices as IOTAEditorServices;
  NotifierIndex := Services.AddNotifier(TEditNotifierHelper.Create);
end;


procedure RemoveNotifier;
var
  Services: IOTAEditorServices;
begin
  if NotifierIndex <> -1 then
  begin
    Services := BorlandIDEServices as IOTAEditorServices;
    Services.RemoveNotifier(NotifierIndex);
    NotifierIndex := -1;
  end;
end;



{ TEditNotifierHelper }

constructor TEditNotifierHelper.Create; // Handler funktioniert
begin

end;

destructor TEditNotifierHelper.Destroy;
begin
  inherited;
end;

//==============================================================================
// INTAEditServicesNotifier -Handler

    procedure TEditNotifierHelper.WindowShow(const EditWindow: INTAEditWindow; Show, LoadedFromDesktop: Boolean);
    begin

    end;

    procedure TEditNotifierHelper.WindowNotification(const EditWindow: INTAEditWindow; Operation: TOperation);
    begin

    end;

    procedure TEditNotifierHelper.WindowActivated(const EditWindow: INTAEditWindow);
    begin

    end;

    procedure TEditNotifierHelper.WindowCommand(const EditWindow: INTAEditWindow; Command, Param: Integer; var Handled: Boolean);
    begin

    end;

    procedure TEditNotifierHelper.EditorViewActivated(const EditWindow: INTAEditWindow; const EditView: IOTAEditView);
    begin

    end;

    procedure TEditNotifierHelper.EditorViewModified(const EditWindow: INTAEditWindow; const EditView: IOTAEditView);
    begin
      Winapi.Windows.beep(1000,100); // Handler funktioniert ! ! ! ! !
    end;

    procedure TEditNotifierHelper.DockFormVisibleChanged(const EditWindow: INTAEditWindow; DockForm: TDockableForm);
    begin

    end;

    procedure TEditNotifierHelper.DockFormUpdated(const EditWindow: INTAEditWindow; DockForm: TDockableForm);
    begin

    end;

    procedure TEditNotifierHelper.DockFormRefresh(const EditWindow: INTAEditWindow; DockForm: TDockableForm);
    begin

    end;

//==============================================================================

procedure TEditNotifierHelper.AfterSave;
begin

end;

procedure TEditNotifierHelper.BeforeSave;
begin

end;

procedure TEditNotifierHelper.Destroyed;
begin

end;

procedure TEditNotifierHelper.Modified;
begin

end;



initialization


finalization

  RemoveNotifier;

end.
  Mit Zitat antworten Zitat