whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1548)

Database (90)
Files (137)
Forms (107)
Graphic (116)
IDE (21)
Indy (5)
Internet / LAN (131)
IntraWeb (0)
Math (76)
Misc (127)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (268)
VCL (243)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

35 Visitors Online


 
...Add a progressbar to a statusbar?
Autor: Ronald Hoek
Homepage: http://www.componentago.nl
[ Print tip ]  

Tip Rating (26):  
     




{ -----------------------------------------------------------------------

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;


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners