Solved

Tab Custom Draw

Posted on 2001-06-04
1
208 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
[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
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

690 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