1

I want to know how can I write a module to show something like clock or other thing on Borland Delphi 7 IDE status bar, because I know it's possible but I couldn't find how!

Free Consulting
  • 4,300
  • 1
  • 29
  • 50
user3615169
  • 31
  • 1
  • 1
  • 2
  • IIUYC you have to write an IDE expert. Check out ToolsAPI/OTA. See [this FAQ](http://www.gexperts.org/open-tools-api-faq/) for a start. – Uli Gerhardt May 08 '14 at 21:32
  • possible duplicate of [Create a Simple Delphi IDE Expert](http://stackoverflow.com/questions/4488873/create-a-simple-delphi-ide-expert) – Graymatter May 08 '14 at 22:40
  • 2
    Why so many downvotes? Question looks perfectly clear and reasonable for me, and it did so since very first revision. @user3615169, I feel quite lazy today, sorry, so I'm going to ask you *what did you try, what you researched so far, in other words, **what did you know already?*** – Free Consulting May 10 '14 at 10:55

2 Answers2

2

To insert a text in a StatusBar, you have to insert a panel first. Just select your statusbar, find the property "Panels" (or perform double click over the statusbar) and click in "Add new". After that, you can write what you want inside the panel in the property "Text" (you can insert one or more panels). To do it programmatically, you can do something like this:

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  StatusBar1.Panels[0].Text := 'Today is: ' + FormatDateTime('dd/mm/yyyy hh:nn:ss', Now);
end;
R.P Silveira
  • 372
  • 2
  • 10
  • Your answer is not my answer because I want to write on Delphi7 status bar not on my own form of application but thanks for your attention – user3615169 May 09 '14 at 18:25
  • 1
    Actually, I'm not understanding exactly what you want, sorry. Try to give us more details about it. – R.P Silveira May 09 '14 at 20:52
0

Since OP didn't replied with more details, I'm going to post a little demonstration how to reach a status bar of Delphi's edit window. I had no success with adding new distinct status panel w/o disturbing layout, so I'm just changing the text of INS/OVR indicator panel.

Disclaimer: I still do not have access to the machine with Delphi 7 installed, so I've done that in BDS ("Galileo") IDE. However, differences should be minor. I believe what main difference lies in the way how we locate edit window.

Key strings are: 'TEditWindow' for edit window class name and 'StatusBar' for TStatusBar control name owned by edit window. These strings are consistent across versions.

{ helper func, see below }
function FindForm(const ClassName: string): TForm;
var
  I: Integer;
begin
  Result := nil;
  for I := 0 to Screen.FormCount - 1 do
  begin
    if Screen.Forms[I].ClassName = ClassName then
    begin
      Result := Screen.Forms[I];
      Break;
    end;
  end;
end;

procedure Init;
var
  EditWindow: TForm;
  StatusBar: TStatusBar;
  StatusPanel: TStatusPanel;
begin
  EditWindow := FindForm('TEditWindow');
  Assert(Assigned(EditWindow), 'no edit window');
  StatusBar := EditWindow.FindComponent('StatusBar') as TStatusBar;
  (BorlandIDEServices as IOTAMessageServices).AddTitleMessage(Format('StatusBar.Panels.Count = %d', [StatusBar.Panels.Count]));
  //StatusPanel := StatusBar.Panels.Add;
  StatusPanel := StatusBar.Panels[2];
  StatusPanel.Text := 'HAI!';
end;

initialization
  Init;

finalization
  // nothing to clean up yet

Another note: As you see, I use Open Tools API to output debug messages only, to interact with IDE I do use Native VCL classes. Therefore, this code must be in package.


The code above is a relevant part of the unit which should be contained in package. Do not forget to add ToolsAPI to uses clause as well as other appropriate referenced units (up to you). Package should require rtl, vcl and designide (important!). Since I run the testcase directly from initialization section, installing the package is enough for testcase to run and produce some result.

Free Consulting
  • 4,300
  • 1
  • 29
  • 50
  • Dear Free Consulting , Thanks for your answer, I want to test your answer, but I couldn't find where and in which module, may you help me for thisthis – user3615169 May 14 '14 at 02:51
  • 1
    @user3615169, I updated the answer. But I strongly suggest you to step back to the basics, because writing IDE add-ins is rather complex field for a novice. Feel free to request more details, tho. – Free Consulting May 14 '14 at 06:54