Solved

Owner Drawn THeaderSections of a THeaderControl?

Posted on 1997-04-24
2
492 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Simple Delphi Question 9 89
Delphi application Soap connection 5 103
Multiple image collision 13 74
TEMBEDDEDWB how can i change its user agent ? 8 58
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…
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 a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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