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 6089285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:04:57+00:00 2026-05-23T12:04:57+00:00

How can I make the view like in the Yellow rectangle. Using TPanel +

  • 0

enter image description here
How can I make the view like in the Yellow rectangle. Using TPanel + Color? If yes what about an indent of the text from the left?

Thanks for help and advices!

  • 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-05-23T12:04:58+00:00Added an answer on May 23, 2026 at 12:04 pm

    The simplest way is to use a TPanel. Set ParentBackground to false, BevelOuter to bvNone, Font.Color to clWhite, Font.Style to [fsBold] and the Color to the background colour you want. Then simply put one or two spaces in front of your text in the Caption property, like ' This is an ordinary TPanel.'.

    Screenshot

    A more elegant soution is to write a custom control. This is really easy. Example:

    unit CaptionBar;
    
    interface
    
    uses
      Windows, SysUtils, Classes, Controls, Graphics;
    
    type
      TCaptionBar = class(TCustomControl)
      private
        FColor: TColor;
        FCaption: TCaption;
        FEllipsis: boolean;
        FIndent: integer;
        procedure SetCaption(const Value: TCaption);
        procedure SetColor(const Value: TColor);
        procedure SetEllipsis(const Value: boolean);
        procedure SetIndent(const Value: integer);
      protected
        procedure Paint; override;
      public
        constructor Create(AOwner: TComponent); override;
      published
        property Font;
        property Anchors;
        property Align;
        property Caption: TCaption read FCaption write SetCaption;
        property Color: TColor read FColor write SetColor default clSkyBlue;
        property Ellipsis: boolean read FEllipsis write SetEllipsis default true;
        property Indent: integer read FIndent write SetIndent default 4;
      end;
    
    procedure Register;
    
    implementation
    
    procedure Register;
    begin
      RegisterComponents('Rejbrand 2009', [TCaptionBar]);
    end;
    
    { TCaptionBar }
    
    constructor TCaptionBar.Create(AOwner: TComponent);
    begin
      inherited;
      FIndent := 4;
      FColor := clSkyBlue;
      FEllipsis := true;
    end;
    
    procedure TCaptionBar.Paint;
    const
      Ellipsis: array[boolean] of cardinal = (0, DT_END_ELLIPSIS);
    var
      r: TRect;
    begin
      inherited;
      Canvas.Brush.Color := FColor;
      Canvas.FillRect(ClientRect);
      r := ClientRect;
      r.Left := r.Left + FIndent;
      Canvas.Font.Assign(Font);
      DrawText(Canvas.Handle,
        PChar(FCaption),
        length(FCaption),
        r,
        DT_SINGLELINE or DT_LEFT or DT_VCENTER or Ellipsis[FEllipsis]);
    end;
    
    procedure TCaptionBar.SetCaption(const Value: TCaption);
    begin
      if not SameStr(FCaption, Value) then
      begin
        FCaption := Value;
        Invalidate;
      end;
    end;
    
    procedure TCaptionBar.SetColor(const Value: TColor);
    begin
      if FColor <> Value then
      begin
        FColor := Value;
        Invalidate;
      end;
    end;
    
    procedure TCaptionBar.SetEllipsis(const Value: boolean);
    begin
      if FEllipsis <> Value then
      begin
        FEllipsis := Value;
        Invalidate;
      end;
    end;
    
    procedure TCaptionBar.SetIndent(const Value: integer);
    begin
      if FIndent <> Value then
      begin
        FIndent := Value;
        Invalidate;
      end;
    end;
    
    end.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have heard that you can make a view popup like in the Mail
I would like to make popover view visible whenever user switches from landscape view
How can I make my view resize in response to the in-call status bar
How can I make the search bar to scroll together with the table view?
I would like to create button which contains text on left and checkbox on
I am adding a modal view using the following code: [self presentModalViewController:phrasesEditor animated:YES]; How
As seen in the picture shown below I'm trying to make a view like
I need to make a view in Oracle that will display all rows from
I would like to make a class that has different text to say to
I would like to know if I can make an image opaque if set

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.