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
Solved

Owner Drawn THeaderSections of a THeaderControl?

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi Form ownership 4 111
tidtcpserver connection lost handle 2 102
Firemonkey android show image from resource ? 1 46
CheckListBox usage 3 71
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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 an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 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