Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8432619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:10:37+00:00 2026-06-10T06:10:37+00:00

Let’s say my status bar has 3 panels and he leftmost is the name

  • 0

Let’s say my status bar has 3 panels and he leftmost is the name of the file on which the app is working.

That might me c:\my.log or c:\a\very\deeply\nested\sub-directory\extremely_long_file_name_indeed.log

Is there an easy way to adjust the size of the 3 status bar panels when I load a new file? (maybe even a FOSS VCL component – although I can’t find one)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T06:10:39+00:00Added an answer on June 10, 2026 at 6:10 am

    This, actually is more like TLama’s first version of his deleted answer, which I liked better:

    type
      TForm1 = class(TForm)
        StatusBar1: TStatusBar;
        procedure FormResize(Sender: TObject);
      private
        procedure SetLeftPanelWidth;
      ..
    
    uses
      filectrl, commctrl;
    
    ...
    
    procedure TForm1.SetLeftPanelWidth;
    var
      Borders: array[0..2] of Integer;
      PanelWidth, MaxWidth: Integer;
    begin
      // calculate a little indent on both sides of the text (credit @TLama)
      SendMessage(StatusBar1.Handle, SB_GETBORDERS, 0, LPARAM(@Borders));
    
      StatusBar1.Canvas.Font := StatusBar1.Font;
      PanelWidth := StatusBar1.Canvas.TextWidth(StatusBar1.Panels[0].Text)
          + 2 * Borders[1] + 2;
    
      // Per Ken's comment, specify a maximum width, otherwise the panel can overgrow
      MaxWidth := StatusBar1.Width div 4 * 3; // arbitrary requirement
      if PanelWidth > MaxWidth then begin
        StatusBar1.Panels[0].Text := MinimizeName(TFileName(StatusBar1.Panels[0].Text),
            StatusBar1.Canvas, MaxWidth);
        // recalculate
        PanelWidth := StatusBar1.Canvas.TextWidth(StatusBar1.Panels[0].Text) +
            2 * Borders[1] + 2;
      end;
      StatusBar1.Panels[0].Width := PanelWidth;
    end;
    
    procedure TForm1.FormResize(Sender: TObject);
    begin
      // have to set the text again since original filename might have been minimized
      StatusBar1.Panels[0].Text := ...;
      SetLeftPanelWidth;
    end;
    

    The above shortens the path if it doesn’t fit to a maximum width, but the original file name is not visible to the user in any way. To be able to use native hint support for status bar panels, the width of a panel must be shorter than the text can fit.

    So, as an alternative, the below truncates the trailing part of the file name when it is longer than a maximum width and shows a tooltip when hovered with the mouse:

    type
      TStatusBar = class(comctrls.TStatusBar)
      protected
        procedure CreateParams(var Params: TCreateParams); override;
      end;
    
      TForm1 = class(TForm)
        StatusBar1: TStatusBar;
        procedure FormResize(Sender: TObject);
      private
        procedure SetLeftPanelWidth;
      ..
    
    
    procedure TStatusBar.CreateParams(var Params: TCreateParams);
    begin
      inherited;
      Params.Style := Params.Style or SBT_TOOLTIPS;
    end;
    
    procedure TForm1.SetLeftPanelWidth;
    var
      Borders: array[0..2] of Integer;
      PanelWidth, MaxWidth: Integer;
    begin
      SendMessage(StatusBar1.Handle, SB_GETBORDERS, 0, LPARAM(@Borders));
    
      StatusBar1.Canvas.Font := StatusBar1.Font;
      PanelWidth := StatusBar1.Canvas.TextWidth(StatusBar1.Panels[0].Text)
          + 2 * Borders[1] + 2;
    
      MaxWidth := StatusBar1.Width div 4 * 3; // arbitrary requirement
      if PanelWidth > MaxWidth then begin
        SendMessage(StatusBar1.Handle, SB_SETTIPTEXT, 0,
            NativeInt(PChar(StatusBar1.Panels[0].Text)));
        PanelWidth := MaxWidth;
      end else
        SendMessage(StatusBar1.Handle, SB_SETTIPTEXT, 0, 0);
    
      StatusBar1.Panels[0].Width := PanelWidth;
    end;
    
    procedure TForm1.FormResize(Sender: TObject);
    begin
      SetLeftPanelWidth;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a HomeController which has an Index action, in the Index.cshtml
Let's say I have a method in java, which looks up a user in
Let me explain best with an example. Say you have node class that can
Let's say that I have a SQLite database that I create in a separate
Let's say after I had login I will be prompt to enter the Name
Let's say, if I need to assign an id to element with first name,
Let's say I'm making a tool to help epicureans keep track of which delicacies
Let's say I have multiple requirements for a password. The first is that the
Let's say that I have a date in R and it's formatted as follows.
Let's say I have some text as follows: do this, do that, then this,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.