Solved

Tab Custom Draw

Posted on 2001-06-04
1
203 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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 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

7 Experts available now in Live!

Get 1:1 Help Now