Solved

Owner Drawn THeaderSections of a THeaderControl?

Posted on 1997-04-24
2
483 Views
Last Modified: 2012-06-27
Section Style = OwnerDraw

How do i draw a bmp and text in an individual THeaderSection
of a THeader Control.

When I use the Canvas to place a bmp on it, it shows on each section.
0
Comment
Question by:sholmes
2 Comments
 
LVL 4

Accepted Solution

by:
erajoj earned 35 total points
ID: 1335722
Something like this?:

procedure TMainForm.HeaderControl1DrawSection(
  HeaderControl: THeaderControl; Section: THeaderSection;
  const Rect: TRect; Pressed: Boolean);
var
  MaxWidth, Trailer, Height, RMargin: Integer;
  TruncStr : string;
  Truncated: Boolean;
begin
  with HeaderControl1.Canvas do begin
    TruncStr := Section.Text;
    Trailer := TextWidth('...');
    with rect do begin
      Height := (Bottom-Top); RMargin := Right-Height; MaxWidth := RMargin-2;
      Truncated := False;
      while (TextWidth(TruncStr)+Trailer)>MaxWidth
      do begin
        SetLength(TruncStr, Length(TruncStr)-1);
        Truncated := True;
      end;
      if Truncated then AppendStr(TruncStr, '...');
      TextRect(Rect, 4, (Height-TextHeight('A')) div 2, TruncStr);

{ --- Here is where you determine which section you're drawing -------------- }
      case Section.Index of
        0: begin
          rectangle(RMargin+4, top+4, Right-4, Bottom-4);
        end;
        1: begin
          Ellipse(RMargin+4, top+4, Right-4, Bottom-4);
        end;
      end;
{ --------------------------------------------------------------------------- }

    end;
  end;
end;

0
 

Author Comment

by:sholmes
ID: 1335723
Thanks!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

708 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

17 Experts available now in Live!

Get 1:1 Help Now