OTA experts, please help!
OTA experts, please help!
Is there a way to hook into 'buffer saved' event in a Delphi expert? Specifically, I would like to know when a contents of some editor tab were save to disk (and into which file).
Is there a way to hook into 'buffer saved' event in a Delphi expert? Specifically, I would like to know when a contents of some editor tab were save to disk (and into which file).
I'm pretty sure there is an interface that allows this, but I currently can't look it up. Will do when I get back to a computer.
ReplyDeletetype
ReplyDeleteTGxModuleNotifier = class(TInterfacedObject, IOTANotifier,
IOTAModuleNotifier, IGxModuleNotifier,
IGxNotifierUninstallation)
private
FIdeClient: TGxIdeNotifier;
private
FSelfNotifierIndex: Integer;
procedure RemoveSelfNotifier;
private
FCachedSourceEditors: array of IOTASourceEditor;
// Note that this list of editor notifiers contains both
// IOTAEditorNotifier and IOTAFormNotifier interface instances.
FInstalledEditorNotifiers: TInterfaceList;
private
FAssociatedModule: IOTAModule;
FFileName: string;
procedure InstallEditorNotifiers;
procedure RemoveEditorNotifiers;
procedure RemoveSelfFromClient;
protected
// IOTANotifier - just there for playing
procedure AfterSave;
procedure BeforeSave;
procedure Destroyed;
procedure Modified;
// IOTAModuleNotifier
function CheckOverwrite: Boolean;
procedure ModuleRenamed(const NewName: string);
// IGxModuleNotifier
function GetAssociatedModule: IOTAModule;
// IGxNotifierUninstallation
procedure UninstallNotifier;
public
constructor Create(AssociatedModule: IOTAModule; Client: TGxIdeNotifier);
destructor Destroy; override;
end;
BeforeSave/AfterSave will be executed before and After Saving. You can find it in the GX_EditorChangeServices.
IOTAEditBuffer inherits from IOTAEditor, which has a property Module of type IOTAModule where you get the FIleName. When you register an IOTAModuleNotifier for that module you get an AfterSave event.
ReplyDeleteAhhhhh, Module notifier. And I was trying to make AfterSave work at Editor notifier level.
ReplyDeleteThank you Roland Wind and Uwe Raabe!
Hmmmm, I'm still missing something. Who will tell me when an editor is created/destroyed so I can register/unregister the module notifier?
ReplyDeleteIs that IOTAIDENotifier.FileNotification? Or is there something easier to use?
ReplyDeleteINTAEditServicesNotifier.EditorViewActivated
ReplyDeleteDestruction is directly signaled to the notifier itself: IOTANotifier.Destroyed
ReplyDeleteThank you again!
ReplyDeleteOK, I guess I don't need to look it up now. ;-)
ReplyDeleteWorks like a charm! Thank you!
ReplyDelete