Scroll Bar does not appear when  Form resizes

Posted on 2006-04-30
Last Modified: 2012-05-05


  I am using Delphi 5. I have an MDI application. In child forms I have a Panel (align=alTop), a grid (align=alclient) and another panel (align=albottom).Buttons , editboxes etc. are on those top and bottom panels. Child forms have (borderstyle=bssizeable) .

  When the child forms  are resized, the horizontal scroll bar of the form do not appear even if the form is resized to a smaller width than its original.

 I think this happens because the panels have align properties. They also get smaller with form, so horizontal scroll bar does not appear.

 What can be  a solution to this problem? I want to resize the form but the horizonal scroll bar must be seen when necessary..

Question by:caglar_okat
    LVL 5

    Expert Comment

    In the onformcreate did you try making it visible := true;

    Author Comment


     Unfortunately this doesn't help. The problem is, form doesn't show the horizontal scroll bar because the albottom and altop panels gets smaller when form gets smaller.
    LVL 33

    Accepted Solution

    ??? not so sure about what ot why you are asking this?, the auto-scrollBars of a form only are used when componenets are OFF the client area. If you have your panels Aligned to top and bottom, then they are resized with the form, and are still with in the client area. . . So you seem not to want to set your panels NOT to be aligned, if you want them to NOT change size with the form, then do NOT align them with the form, I guess you want them to be at the top and bottom, but not to be changed in width? ? If so you may need to do that yourself.
    LVL 33

    Expert Comment

    I just remembered, , The Anchors  property, may be better for this, you can set the Anchors to  akTop  or  akBottom and Align to alNone, and this may do what you need?

    Author Comment

    Yes, I want the two panels to be at the top and bottom.

    I tried doing it with anchors. I set the appropriate anchors values for the two panels and the grid. When using anchors the horz. scrollbar appears (since the panels do not change widths as form gets smaller.)

    But there are some  problems with anchors property,
     when I make the form very smaller (the grid is not seen) , the top and bottom panels overlap.(if I use align they do not overlap).
     when the form is too small as the grid can not be seen, if I scroll the form's scrollbar to the right, the grid loses its original distance to the bottom edge (when I make the grid bigger), and gets behind the bottom panel.The grid behaves like it is anchored to the bottom edge (as if there is no bottom panel).

    LVL 33

    Assisted Solution

    OK, I really do Not understand any  about the "Grid", and it's positions, , but here is a way to have the Bottom panel do exactly as you want it to, you can position it to anywhere you want in the Parent's (a TForm in this cace) OnResize event, , the Panel1 is the TOP Panel, and Panel2 is the BOTTOM Panel , , ,both of these TPanels have the Default settings, Align= alNone, Anchors= [akLeft, akTop] -

    procedure TForm2.FormResize(Sender: TObject);
    if ClientHeight > Panel1.Height + Panel2.Height {+Grid1.Height} then // test for the minimum you will need here
      Panel2.Top := ClientHeight - Panel2.Height // move the Panel2 to the position you may require, I place at bottom
      else // if less than minimum, then place at bottom of Panel1
      Panel2.Top := Panel1.Height {+Grid1.Height}; // add any amount for more separation

     = = = = = = = = = =  = =
    you can test for the minimum with whatever amount you need to preserve (IE, something to do with the grid) and then place the Panel2 where you need it, , ,you can also move the grid to the position for best visiblility

    Author Comment


     Thanks for the answers. I was wondering if there is an easy method for solving this problem other than writing code in some events.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
    Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now