@Uwe Raabe The file is read-only. So unfortunately, the EditorViewModified event will never be triggered.
I got it to work. Here is a high level overview of how it works, in case it might be of help to someone else:
I react to the INTAEditServicesNotifier.EditorViewModified event. This is triggered whenever a new editor window is activated.
Here I can easily detect whether the source file is read only or not, using EditView.Buffer.IsReadOnly.
The trickiest part was then getting the handle of the editor control window (TEditControl). The Open Tools Api provides no functionality for that.
It does provide you with the IDE's TCustomForm though (INTAEditWindow.Form).
With the form you can find the editor control by searching for a child component with ClassName = 'TEditControl' and ComponentName = 'Editor'.
Instead of working with a Windows Hook, I just added a handler for Application.OnMessage.
procedure TEditorNotifier.ApplicationEventsMessage(var Msg: tagMSG; var Handled: Boolean);
begin
if (Msg.message = WM_KEYDOWN) and (FEditControl.Handle = Msg.hwnd) then
begin
// magic happens...
end;
if not Handled and Assigned(FPreviousMessageEvent) then
FPreviousMessageEvent(Msg, Handled);
end;