Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to change width of panel in status bar

Status
Not open for further replies.

kinabalu

Programmer
Sep 21, 2007
8
MY
Hi everyone,
How can I change the width of each panel in the status bar to fit the length of the text? Is there any property equivalent to the 'spring' property in visual C##?

Tq
 
The width of each panel can be changed by modifying the Width property of the TStatusPanel component.

The width of the displayed string can be determined by using the TextWidth method of the StatusBar canvas.

So one way would be to loop through each of the panels in the status bar and set the width of the panel to the width of the string.

Something like:
Code:
var
  panel: integer;
begin
for panel := 0 to SBar.Panels.Count - 1 do
  StatusBar.Panels[panel].Width := StatusBar.Canvas.TextWidth( StatusBar.Panels[panel].Text ) + 8;
end;



Andrew
Hampshire, UK
 
Tq towerbase for the response.
I've got 5 panels in my status bar. The width of the first and second is according to the length of the text, which towerbase has shown (tq towerbase). The third one could be of any length. However, I want the last two positioned from the right end of the status bar and the length of each panel is according to the length of the text displayed. How can I positioned the last two in that way?

Tq in advance for any response?
 
I would recommend that you use the Form's OnResize event to handle all this.

Set the widths of panels 0, 1 and 3 according to the widths of their content. You then need to calculate the width of panel 2 based on the total width of the status bar and the width of the content of text in the panels 0, 1, 3 and 4.

Whenever the content of panels 0, 1, 3 or 4 change you need to call the Form's OnResize event.

If you are unable to get this to work post your code here and we'll take a look at it. Remember that Tek-Tips is not a free programming service!

Andrew
Hampshire, UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top