StatusBar: any number of panels and use the same procedure to update (Views: 100)


Some times the use of a StatusBar is a hassle, when using 2 or more panels... and probably you write your procedure to update the statusbar... but then you notice you have to add another panel, then you have to change all the occurrences...


you can put this procedure in a separate unit ("goodys.pas" in this example)

procedure SetStatusBar(var StB: TStatusBar; Strs: array of string);
  X: Byte;
  for X := Low(Strs) to High(Strs) do
    if not (Strs[X] = '') then
      StB.Panels[X].Text := Strs[X];

Then include that unit in your formunit


uses goodys;

and whenever you need to update your status bar, make a call

SetStatusBar(MyStatusBar, ['panel', '', 'another panel'])

no matter how many panels the StatusBar has, you can use the same procedure:

SetStatusBar(MyStatusBar, ['update my first panel only'])

- to empty a panel, make a call with an space:

SetStatusBar(MyStatus, ['panel 2 should be empty', ' '])

- and make sure you have at least one panel in your statusbar, and the simplepanel property is False

<< Back to main page