Solved

Owner Drawn THeaderSections of a THeaderControl?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

895 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

12 Experts available now in Live!

Get 1:1 Help Now