Solved

Statusbar resize problem.

Posted on 2006-11-11
7
414 Views
Last Modified: 2010-04-05
Dear Experts,

I am trying to create something that allready exists in another application.

I have put 3 pictures of the original application on my site to let you see what
happens when the user resizes the application. You see 2 statusbars resizes very well
(the first statusbar where you see the text ‘keyboard Locked’ is on a TPanel).

URL:  http://members.home.nl/peterkiers/
Beneath the 3 pictures you can download the example I made by clicking
on the floppy.

When you have run my example, press Enter so the text 'Keyboard Locked' appears.
When you resize my example you'll see the statusbar at the bottom resizes jus fine.
But not the one on top. For the statusbar at the bottom I have used this procedure:

procedure TForm1.MainBarResize(Sender: TObject);
begin
  with MainBar do
    Panels[0].Width := Width - Panels[1].Width - Panels[2].Width
      - Panels[3].Width - Panels[4].Width;
end;

But the procedure above doesn't work for the statusbar on top.

Can someone help me, to solve this problem?


Greetings,

Peter Kiers
0
Comment
Question by:peterkiers
7 Comments
 
LVL 28

Expert Comment

by:2266180
ID: 17921894
change:
procedure TForm1.MainBarResize(Sender: TObject);
begin
  with MainBar do

to

procedure TForm1.MainBarResize(Sender: TObject);
begin
  with sender as TStatusBar do

and assign to the hostbar onresize event the event of teh mainbar resize. it should do what you expect if I understood correctly your request.
0
 
LVL 17

Accepted Solution

by:
mokule earned 500 total points
ID: 17921946
I can't see any problem.

I'm not sure where do you want to have the panels.
You should call DoResize after each Panels[1] changing size and in form creation

Additionally i would advice adding
  Panel1.DoubleBuffered := True;
in form creation

procedure TForm1.DoResize;
begin
  with Hostbar do
    Panels[2].Width := Width - Panels[1].Width - Panels[0].Width
      - Panels[3].Width - Panels[4].Width- Panels[5].Width - Panels[6].Width;
end;

(*---------------------------------------------------*)
procedure TForm1.HostbarResize(Sender: TObject);
begin
  DoResize;
end;

0
 
LVL 28

Expert Comment

by:TName
ID: 17922181
Hi,
Peter, I'm also not sure if I understand your problem. Do you want the status panel at the right to stay at the right as if it had an anchor akRight?
I've never used status panels, so there might be a property I don't know about (the others might tell you if there is one ;), but if not,  then you could try something like this:
Have one status panel (let's say nr 4) act like an invisible spacer. Let it stay "invisible" as it is, don't use it for anything else and let it push everything to the right of it by adapting it's width:


procedure TForm1.FormResize(Sender: TObject);
var
i,c:Integer;
begin
  c:=0;
  for i:=0 to HostBar.Panels.Count -1 do begin
     if i<>4 then
        c:=c+HostBar.Panels[i].Width;
  end;
  HostBar.Panels[4].Width:=HostBar.Width-c;
end;


This is just an idea, untested and maybe not necessary...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 28

Expert Comment

by:TName
ID: 17922201
Omg, forget it, this is exactly what mokule's solution does!!! Sorry, I should really really read the other posts thoroughly before posting!
So disregard my post please!  :/
0
 
LVL 1

Author Comment

by:peterkiers
ID: 17922573
hi, thanks for all the help but I need a little time
to try out all the examples I received.

P.
0
 
LVL 1

Author Comment

by:peterkiers
ID: 17922757
I go for the answer from Mokule, his code works just fine.
Only i have one little question:

The 3 example pictures on my site you not only see that the
panels resize correctly, but also the width of the font gets smaller.
Does someone know how to do this?


Peter
0
 
LVL 1

Author Comment

by:peterkiers
ID: 17924627
Because Mokule gave me the answer that I was looking for.
500p comming your way.

Greetings,

Peter Kiers
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question