Link to home
Start Free TrialLog in
Avatar of Peter Kiers
Peter KiersFlag for Netherlands

asked on

Help needed with the SizeGrip of the Statusbar.

Hi,

I have a statusbar with 4 panels, one for the information and the other 3 for the
Capslock, NumLock and ScrollLock-keys. I have put the dfm of the statusbar along
with the OnResize-event in the code-section. The Statusbar itself resides on a panel
and it has to stay there. First I like to tell you how my the statusbar should react based
on another application, and then I tell you how my statusbar reacts.

This is what I would like the sizegrip of my statusbar to do:
1. The application starts in wsMaxized then the size grip has to be gone (example1).
2. When the application gets resized then the sizegrip has to be available (example2).

When my application starts I have it just like example1 but thats because I have
sizegrip = false. When I resize the application there is still no sizegrip and there
should be one, and next to the last panel not in the last panel (Because that's
what I get when i start my application with sizegrip = true).

Who knows the answer and is willing to help me?
because I have tried a lot of thing with no succes.

Who can help me with this?

Peter Kiers
object StatusBar1: TStatusBar
      Left = 0
      Top = 122
      Width = 800
      Height = 19
      Panels = <
        item
          Bevel = pbNone
          Width = 200
        end
        item
          Alignment = taCenter
          Width = 40
        end
        item
          Alignment = taCenter
          Width = 40
        end
        item
          Alignment = taCenter
          Width = 40
        end>
      SizeGrip = False
      OnResize = StatusBar1Resize
    end
  end

procedure TMainForm.StatusBar1Resize(Sender: TObject);
begin
  with StatusBar1 do
    Panels[0].Width := Width - Panels[1].Width -
      Panels[2].Width - Panels[3].Width;
end;

Open in new window

Example1.jpg
Example2.jpg
Avatar of Emmanuel PASQUIER
Emmanuel PASQUIER
Flag of France image

Hello Peter,

Can you provide an image of what you have because I don't understand this statement :
> next to the last panel not in the last panel

Also, why your status bar is not on the main form directly, where it is normally in applications ? why the need to put it on a Panel ? Is this panel bottom-aligned with the main form ?

Can you provide the whole DFM ? or at least all the objects in which this panel is ?
ASKER CERTIFIED SOLUTION
Avatar of Geert G
Geert G
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Peter Kiers

ASKER

First example is my application
second example is another application

MyApp.jpg
OtherApp.jpg
and Mahdi advised me to put the statusbar on a panel in my prev. question.
"Question about the statusbar"

P.
For Geert yes it does see example MyApp.
if you never want a sizegrip then you need to create your own descendant of the statusbar
and switch the option off



procedure TCustomStatusBar.CreateParams(var Params: TCreateParams);
const
  GripStyles: array[Boolean] of DWORD = (CCS_TOP, SBARS_SIZEGRIP);
begin
  InitCommonControl(ICC_BAR_CLASSES);
  inherited CreateParams(Params);
  CreateSubClass(Params, STATUSCLASSNAME);
  with Params do
  begin
    Style := Style or GripStyles[FSizeGrip and FSizeGripValid];
    if ThemeServices.ThemesEnabled then
      WindowClass.style := WindowClass.style or CS_HREDRAW or CS_VREDRAW
    else
      WindowClass.style := WindowClass.style and not (CS_HREDRAW or CS_VREDRAW);
  end;
end;

in your descendant, you'll need to override this:

let's assume you create a TPKStatusbar (Peter Kiers Statusbar)  :)

procedure TPKStatusBar.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  with Params do
    Style := Style and not SBARS_SIZEGRIP;
end;
oeps, your right Geerts, when I use the sizegrip I can move the panels over the statusbar.

Your right.

P.
it does an extra check to see if the lower right corner is the same as the form lower right corner
Oke, WAIT let me refrase my question.

I go for a sizegrip in full-mode and in resize-mode, but the sizegrip has to be
next to the last panel and not in the last panel.

Peter
easiest (nasty) fix for you would be to hide the size grip

put this above your form declaration
type
  TStatusbar = class(ComCtrls.TStatusbar)
  protected
    procedure CreateParams(var Params: TCreateParams); override;
  end;

  // etc
  TForm1 = class(TForm)
 
and then in the implementation

imlementation

uses // etc

procedure TStatusBar.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  with Params do
    Style := Style and not SBARS_SIZEGRIP;
end;
or create an extra panel at the end with a bevel of pbNone

> Mahdi advised me to put the statusbar on a panel in my prev. question.
> "Question about the statusbar"
Yes, I saw that but was wondering why it is necessary and did not ask. What's the problem with the statusbar in the main form ?
see with the extra statusbar panel  :

statbar (5) panels, and extra pbNone on 2 and 5 for bevel
statbar.png
I have created an extra panel but the problem is the OnResize-procedure!
when put panel4 not in the procedure, nothing happens it still the same (sizegrip in the last panel)
when I add panel 4 in the procedure, its just what i want ONLY the form does not risize.
You can move the panels over the statusbar.

P.
For Espasquier:
When I do not put the statusbar on a panel but below the panel, and I resize the listview with the splitter.
When I go with the splitter all the way down to the statusbar and the go up again the statusbar then resize with it.
See the picture of my previous question.
what panels over the statusbar ?
are you moving TPanels around in your form ?

The statusbar is lowest in the Z-order, everything goes on top of that
(except things like a TLabel)

procedure TMainForm.StatusBar1Resize(Sender: TObject);
begin
  with StatusBar1 do
    Panels[0].Width := Width - Panels[1].Width -
      Panels[2].Width - Panels[3].Width - Panels[4].Width;
end;
you could solve that with putting all the rest in a TPanel

start with a TPanel -> panelMain (align = alClient)
and below that the TStatusbar
all the rest goes into the panelMain

it's a bit difficult if you mix other question in with this to follow
I show you:
example1: This is good just like i wanted it.
example2: when I use the sizegrip i can move the panels over the statusbar
                  The form itself doesn't risize.


AtStartup.jpg
DragPanels.jpg
Hello peter
Please check my answer to your question
https://www.experts-exchange.com/questions/25677165/Question-about-the-statusbar.html

I had two answer, first with statusbar in panel and second with statusbar in form, and i suggested you to use my second answer, check again ;)
This is going the wrong way.

Let me try another approach:
And i got this from another application.

1. The app start in wsMaximized there is no sizegrip and the maximed/minimized button is set to minimized.
2. when the user clicks on the button because he want to minimized the form, the form's size stays the same
    only the sizegrip appears, so the user can resize the form himself.

How can I do that?

P.
I got it.
You where all right the reason is that my statusbar was on a panel.
Thank your for all the responses.

Peter
Check sample of my second answer to that question
file attached
Project1.exe
Sorry both solution statusbar was on panel, but second was in separated panel