Einzelnen Beitrag anzeigen

Benutzerbild von uligerhardt
uligerhardt

Registriert seit: 19. Aug 2004
Ort: Hof/Saale
1.746 Beiträge
 
Delphi 2007 Professional
 
#3

AW: IDE von "außen" steuern

  Alt 31. Mär 2017, 11:25
Du könntest es mit einem IDE-Experten probieren und dann fleißig mit der ToiolsAPI hantieren.
Hier mal ein paar einschlägige Code-Schnipsel:
Delphi-Quellcode:
procedure TDMSParserWizMainForm.ShowUnitSource(const FileName: string);
begin
  (BorlandIDEServices as IOTAActionServices).OpenFile(FileName);
end;

procedure ShowMessageView;
var
  h: HWND;
  c: TComponent;
begin
  // The GetFocus/SetFocus is necessary in my case the IDE is popped up some
  // other message ("the contents of a.txt have changed: reload?") -- without
  // doing SetFocus, the technique would result in the messageview being in the
  // foreground, but the messagebox still waiting for an answer.
  h := Windows.GetFocus;
  try
    c := Application.FindComponent('EditorActionLists');
    if c = nil then
      Exit;
    c := c.FindComponent('ecMessageView');
    if (c = nil) or not (c is TAction) then
      Exit;
    TAction(c).Execute;
  finally
    Windows.SetFocus(h);
  end;
end;

procedure TDMSParserWizMainForm.ShowInMessageView(const FileName, MessageStr: string;
  LineNumber, ColumnNumber: Integer);
var
  MessageServices: IOTAMessageServices40;
begin
  MessageServices := BorlandIDEServices as IOTAMessageServices40;
  MessageServices.ClearCompilerMessages;
  MessageServices.ClearToolMessages;
  MessageServices.AddToolMessage(FileName, MessageStr, 'DMS-Parser', LineNumber, ColumnNumber);
  ShowMessageView;
end;

procedure TDMSParserWizMainForm.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;
Uli Gerhardt
  Mit Zitat antworten Zitat