Title: Add a progressbar to a statusbar?
{ -----------------------------------------------------------------------
What I wanted was a TProgressBar component sitting on a TStatusBarPanel.
The problem is, that TStatusPanel isn't a panel at all, thus not having
a handle to use SetParent.
Basicly I do this.
- Place a TProgressBar and a TStatusBar on the form
- Put the code as show below in the OnCreate event of the form
- And voila, you've got a fully functional progressbar exactly where I wanted it
I've create a THackControl to acces the TControl.SetParent procedure.
With it I can easelly place the Progressbar in the Statusbar.
NOTE:
If you resize the panels on the progressbar, you need to re-execute
the last 2 line of code in the example, to reposition the progressbar.
Hope you like it :)
Ronald
hoek@componentagro.nl
-------------------------------------------------------------------------- }
type
THackControl = class(TControl);
procedure TfrmWebsite.FormCreate(Sender: TObject);
var
PanelRect: TRect;
begin
// Place progressbar on the statusbar
THackControl(ProgressBar1).SetParent(StatusBar1);
// Retreive the rectancle of the statuspanel (in my case the second)
SendMessage(StatusBar1.Handle, SB_GETRECT, 1, Integer(@PanelRect));
// Position the progressbar over the panel on the statusbar
with PanelRect do
ProgressBar1.SetBounds(Left, Top, Right - Left, Bottom - Top);
end;