Recent

Author Topic: Progressbar in Statusbar  (Read 4425 times)

dietmar

  • Full Member
  • ***
  • Posts: 170
Progressbar in Statusbar
« on: September 19, 2021, 10:02:46 pm »
Hi,

how can I place a progress bar in a panel of my status bar?

Thx,
--Dietmar
Lazarus 2.2.0RC1 with FPC 3.2.2 (32 Bit) on Windows10 (64Bit)

wp

  • Hero Member
  • *****
  • Posts: 12459
Re: Progressbar in Statusbar
« Reply #1 on: September 19, 2021, 11:18:37 pm »
Quote from: dietmar link=topic=56367.msg418795#msg
how can I place a progress bar in a panel of my status bar?
Put the progressbar anywhere on the form and hide it. When you start the process, set the Progressbar.Parent to the statusbar and adjust its location (this is a bit tricky, IIRC). Finally show the progressbar. At the end of the process, hide it again.

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1153
  • Professional amateur ;-P
Re: Progressbar in Statusbar
« Reply #2 on: September 19, 2021, 11:35:05 pm »
Hey WP,

Put the progressbar anywhere on the form and hide it. When you start the process, set the Progressbar.Parent to the statusbar and adjust its location (this is a bit tricky, IIRC). Finally show the progressbar. At the end of the process, hide it again.

This works perfectly for Windows but I think it fails for Linux GTK2. I seem to remember stumbling on this on another program.
But I have to tell you to take this with a grain of salt cuz my memory is crap and I could be remembering it wrong :(

Cheers,
Gus
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

Zvoni

  • Hero Member
  • *****
  • Posts: 2741
Re: Progressbar in Statusbar
« Reply #3 on: September 20, 2021, 08:53:46 am »
I remember finding a snippet you could "simulate" a Progressbar anywhere that offers a canvas without using the ProgressBar-Control.
But i would have to dig up my Fedora-Hat an Bullwhip and go on a jungle-hunt to find that snippet again....
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

balazsszekely

  • Guest
Re: Progressbar in Statusbar
« Reply #4 on: September 20, 2021, 11:38:16 am »
Works on windows, linux and osx(Lazarus 2.0.12/FPC 3.2.0). You can customize the appearance.

Zvoni

  • Hero Member
  • *****
  • Posts: 2741
Re: Progressbar in Statusbar
« Reply #5 on: September 20, 2021, 12:10:32 pm »
GetMem,
Yep. That's it pretty much
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 1153
  • Professional amateur ;-P
Re: Progressbar in Statusbar
« Reply #6 on: September 20, 2021, 02:57:46 pm »
Hey GetMem,

Works on windows, linux and osx(Lazarus 2.0.12/FPC 3.2.0). You can customize the appearance.

I now stand corrected and have only one thing to say: AWESOME SAUCE!!!

You da man GetMem, thank you so much for this!!!
This cures my fear of doing it due to past bad experiences and I'll use it extensively :P

Cheers,
Gus
Lazarus 3.99(main) FPC 3.3.1(main) Ubuntu 23.10 64b Dark Theme
Lazarus 3.0.0(stable) FPC 3.2.2(stable) Ubuntu 23.10 64b Dark Theme
http://github.com/gcarreno

dietmar

  • Full Member
  • ***
  • Posts: 170
Re: Progressbar in Statusbar
« Reply #7 on: September 20, 2021, 03:46:52 pm »
Thx to all of you guys... you are the best as always ;-)

--Dietmar
Lazarus 2.2.0RC1 with FPC 3.2.2 (32 Bit) on Windows10 (64Bit)

Paolo

  • Hero Member
  • *****
  • Posts: 538
Re: Progressbar in Statusbar
« Reply #8 on: September 23, 2021, 04:09:09 pm »
I create the progressbar at fly in this way

TForm1...
...
    StBar: TStatusBar;
    PrBar : TProgressBar;
...
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  ....
  PrBar:=TProgressBar.Create(StBar);
  PrBar.Parent:=StBar;
  ...
end;

and also (I have the progressbar in a panel with index = cPnlPrBar)

procedure TForm1.StBarDrawPanel(StatusBar: TStatusBar; Panel: TStatusPanel; const Rect: TRect);
begin
  if (Panel = StatusBar.Panels[cPnlPrBar]) then
    PrBar.BoundsRect:=Rect
end;

 

TinyPortal © 2005-2018