?
Solved

Owner Drawn THeaderSections of a THeaderControl?

Posted on 1997-04-24
2
Medium Priority
?
507 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
erajoj earned 70 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

719 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