Recent

Author Topic: Progressbar in Statusbar  (Read 1378 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)

jamie

  • Hero Member
  • *****
  • Posts: 4906
Re: Progressbar in Statusbar
« Reply #1 on: September 19, 2021, 10:39:19 pm »
There is a OnDrawPanel event you can use to simulate a progress bar which is actually better than putting a progress control within it.
The only true wisdom is knowing you know nothing

wp

  • Hero Member
  • *****
  • Posts: 8875
Re: Progressbar in Statusbar
« Reply #2 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.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 757
  • Professional amateur ;-P
Re: Progressbar in Statusbar
« Reply #3 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 2.3.0(trunk) FPC 3.3.1(trunk) Ubuntu 21.04 64b Dark Theme
Lazarus 2.0.12(stable) FPC 3.2.2(stable) Ubuntu 21.04 64b Dark Theme
http://github.com/gcarreno

Zvoni

  • Hero Member
  • *****
  • Posts: 732
Re: Progressbar in Statusbar
« Reply #4 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 IDE to find them,
One Code to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
People call me crazy, because i'm jumping out of perfectly fine aircraft

GetMem

  • Hero Member
  • *****
  • Posts: 3490
Re: Progressbar in Statusbar
« Reply #5 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: 732
Re: Progressbar in Statusbar
« Reply #6 on: September 20, 2021, 12:10:32 pm »
GetMem,
Yep. That's it pretty much
One System to rule them all, One IDE to find them,
One Code to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
People call me crazy, because i'm jumping out of perfectly fine aircraft

Gustavo 'Gus' Carreno

  • Hero Member
  • *****
  • Posts: 757
  • Professional amateur ;-P
Re: Progressbar in Statusbar
« Reply #7 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 2.3.0(trunk) FPC 3.3.1(trunk) Ubuntu 21.04 64b Dark Theme
Lazarus 2.0.12(stable) FPC 3.2.2(stable) Ubuntu 21.04 64b Dark Theme
http://github.com/gcarreno

dietmar

  • Full Member
  • ***
  • Posts: 170
Re: Progressbar in Statusbar
« Reply #8 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

  • Full Member
  • ***
  • Posts: 225
Re: Progressbar in Statusbar
« Reply #9 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