domus 1 Posted August 17, 2023 Would anyone know of a way for an external app to jump to a certain unit and position inside the IDE? Like, unit "Main.pas", line 100. Many thanks for pointers. Share this post Link to post
uligerhardt 18 Posted August 17, 2023 You can use ShellExecute(0, 'open', PChar(FileName), nil, nil, SW_SHOWNORMAL); to show the unit in your registered Pascal editor - which probably is Delphi. I don't know about the line number. 1 Share this post Link to post
domus 1 Posted August 17, 2023 That's indeed a way to get me started. Totally forgot about ShellExecute being an option here. Thanks for that! If anyone would know of a way to navigate to a certain procedure or class, or line number, I'd be grateful to receive that knowledge. But it's probably all documented somewhere in the Tools API documentation and I should just resort to reading it. Share this post Link to post
dummzeuch 1505 Posted August 17, 2023 (edited) 1 hour ago, domus said: Would anyone know of a way for an external app to jump to a certain unit and position inside the IDE? Like, unit "Main.pas", line 100. Many thanks for pointers. AFAIK this can only be done using the OTAPI which is only available for IDE plugins. Edited August 17, 2023 by dummzeuch 1 Share this post Link to post
domus 1 Posted August 17, 2023 35 minutes ago, dummzeuch said: AFAIK this can only be done using the OTAPI which ins only available for IDE plugins. That's the problem. I'd need to write a plugin that listens to the external app... Thanks and cheers. Share this post Link to post
aehimself 396 Posted August 18, 2023 To open a file you can use DDE, which @Attila Kovacs got working some time ago: As for repositioning, you can try to get the handle of the editor control and send a EM_SETSEL message. That would be my approach, that is. 1 Share this post Link to post
domus 1 Posted August 18, 2023 54 minutes ago, aehimself said: That would be my approach, that is. Excellent approach. I'll give it a try. Thanks! Share this post Link to post
dummzeuch 1505 Posted August 18, 2023 (edited) 6 hours ago, aehimself said: As for repositioning, you can try to get the handle of the editor control and send a EM_SETSEL message. I don't think this will work as the editor control (TEditControl) does not descend from TEdit or TMemo but from TWinControl (via TCustomControl -> TCustomEditControl): But I might be wrong, maybe one of those controls processes this message. Edit: TMemo descends from TCustomEdit (which itself descends from TWinControl), not from TCustomEditControl. Edited August 18, 2023 by dummzeuch 1 Share this post Link to post
aehimself 396 Posted August 18, 2023 That's a pity. Unfortunately the source of TEditControl and TCustomEditControl is buried somewhere so we can not be sure what it can do, what it will reply to. Worths a try though, maybe... Share this post Link to post
aehimself 396 Posted August 18, 2023 I wonder where @RRUZ got this unit. IF we are talking about the same component, according to it, TEditControl has two published properties: property CaretX: SmallInt; property CaretY: Integer; If we can find out how to access this type from a Delphi application (even without source) I'm sure TEditControl could be accessed via it's handle and some pointer magic... 1 Share this post Link to post
uligerhardt 18 Posted August 18, 2023 If you're prepared to write a wizard you might find something in this fragments from a very old wizard I no longer use: procedure TMyWizMainForm.ShowInMessageView(const FileName, MessageStr: string; LineNumber, ColumnNumber: Integer); var MessageServices: IOTAMessageServices40; begin MessageServices := BorlandIDEServices as IOTAMessageServices40; MessageServices.ClearCompilerMessages; MessageServices.ClearToolMessages; MessageServices.AddToolMessage(FileName, MessageStr, '.....', LineNumber, ColumnNumber); ShowMessageView; end; procedure TMyWizMainForm.ShowUnitSource(const FileName: string); begin (BorlandIDEServices as IOTAActionServices).OpenFile(FileName); end; procedure TMyWizMainForm.ShowParseError(e: EParseError); var EditorServices: IOTAEditorServices; TopView: IOTAEditView; EditActions: IOTAEditActions; begin ShowInMessageView(CurrUnit, e.Message, e.LineNo, e.ColumnNo); EditorServices := BorlandIDEServices as IOTAEditorServices; TopView := EditorServices.TopView; if TopView = nil then begin ShowUnitSource(CurrUnit); TopView := EditorServices.TopView; end; if TopView <> nil then begin EditActions := TopView as IOTAEditActions; EditActions.NextError; end; Close; Beep; end; It works (worked?) by inserting a custom line into the IDE's message window and make the IDE jump there. 1 Share this post Link to post