Solved

Tab Custom Draw

Posted on 2001-06-04
1
205 Views
Last Modified: 2010-04-06
Hi all,

I draw the Tab(the part you click on to select another sheet) as below. Problem is, I can't get it to draw the _ below the shortcut character.

The result is:-
  '&Customer'

Thanks,
Dion.

procedure TPupilForm.pcFamDetailsDrawTab(Control: TCustomTabControl;
  TabIndex: Integer; const Rect: TRect; Active: Boolean);
var
  ARect: TRect;
begin
  with Control do
  begin
    if Active then
      Canvas.Brush.Color := RGB(195, 193, 205)
    else
      Canvas.Brush.Color := clBtnFace;

    ARect := Rect;
    ARect.Bottom := ARect.Bottom+2;
    Canvas.FillRect(ARect);

    Canvas.Font.Color := clBlack;

    { make sure that the tab is going to be wide enough. }

    Canvas.TextOut(Rect.Left+4, Rect.Top+4, TPageControl(Control).Pages[TabIndex].Caption);

  end;
0
Comment
Question by:Diono
1 Comment
 
LVL 4

Accepted Solution

by:
fva earned 50 total points
ID: 6152105
Normally you should use the TCM_SETITEM API to change the text in the tab (and that's what VCL does).
If you want to change colors as your code suggests, try

// determine the aRect surrounding the text
....
// output formatted text
DrawText(Canvas.Handle,PChar(TPageControl(Control).Pages[TabIndex].Caption),length(TPageControl(Control).Pages[TabIndex].Caption),aRect,0);

DrawText will take care of your & unless the last parameter includes DT_NOPREFIX. Check Win API for more detail.

HTH,
F.
 
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

816 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

9 Experts available now in Live!

Get 1:1 Help Now