?
Solved

Tab Custom Draw

Posted on 2001-06-04
1
Medium Priority
?
209 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 150 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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month14 days, 5 hours left to enroll

801 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