Board index » cppbuilder » Parent a progress bar to a panel in a status bar

Parent a progress bar to a panel in a status bar

I am trying to parent a progress bar into a panel in a status bar, but I
can't seem to do it because TStatusPanel isn't derived from a TWinControl.
Anyone know how to do it?
 

Re:Parent a progress bar to a panel in a status bar


Quote
> I am trying to parent a progress bar into a panel in a status bar, but I

Maybe this note from "Mauro" will help:

Make the panel where you want the progress bar placed owner-drawn and
then use the code below.

__fastcall TForm1::TForm1(TComponent* Owner)
         : TForm(Owner)
{
   ProgressBar1->Parent = StatusBar1;

Quote
}

//---------------------------------------------------------------------------

void __fastcall TForm1::StatusBar1DrawPanel(TStatusBar *StatusBar,
       TStatusPanel *Panel, const TRect &Rect)
{
   // place it in the second panel
   if (Panel->Index == 1)
     ProgressBar1->SetBounds(Rect.Left, Rect.Top, Rect.Right -
Rect.Left,  Rect.Bottom - Rect.Top);

Quote
}

//---------------------------------------------------------------------------

--
Jonathan Arnold                   Keen Advice:
http://www.keen.com/categories/categorylist_expand.asp?sid=5156620
    Comprehensive C++Builder link site:
http://www.buddydog.org/C++Builder/c++builder.html

Re:Parent a progress bar to a panel in a status bar


Beautiful!  Thanks.

Quote
"Jonathan Arnold" <jdarn...@buddydog.org> wrote in message

news:3BD98863.4070201@buddydog.org...
Quote
> > I am trying to parent a progress bar into a panel in a status bar, but I

> Maybe this note from "Mauro" will help:

> Make the panel where you want the progress bar placed owner-drawn and
> then use the code below.

> __fastcall TForm1::TForm1(TComponent* Owner)
>          : TForm(Owner)
> {
>    ProgressBar1->Parent = StatusBar1;
> }

file://---------------------------------------------------------------------
------
Quote

> void __fastcall TForm1::StatusBar1DrawPanel(TStatusBar *StatusBar,
>        TStatusPanel *Panel, const TRect &Rect)
> {
>    // place it in the second panel
>    if (Panel->Index == 1)
>      ProgressBar1->SetBounds(Rect.Left, Rect.Top, Rect.Right -
> Rect.Left,  Rect.Bottom - Rect.Top);
> }

file://---------------------------------------------------------------------
------
Quote

> --
> Jonathan Arnold                   Keen Advice:
> http://www.keen.com/categories/categorylist_expand.asp?sid=5156620
>     Comprehensive C++Builder link site:
> http://www.buddydog.org/C++Builder/c++builder.html

Other Threads