• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1099
  • Last Modified:

TpageControl tab drawing example.

I am looking for an example of how to draw a TpageControl tab (user draw)
Thanks
Amiel
0
amielDorel
Asked:
amielDorel
  • 2
  • 2
1 Solution
 
Ferruccio AccalaiSenior developer, analyst and customer assistance Commented:


Take a look at this thread (not already PAQ but the posted code does the trick)
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_21037452.html
0
 
amielDorelAuthor Commented:
Thanks it works,  how about painting the border of the tab?    is it posible to set an image to cover the tab ?
Thanks again
0
 
Ferruccio AccalaiSenior developer, analyst and customer assistance Commented:
well, in that link there's an addition by meikl about the tab border

BTW it's possible also to draw some images using the canvas methods...

here a dirty example just to explane how it can work:

procedure TForm1.PageControl1DrawTab(Control: TCustomTabControl;
  TabIndex: Integer; const Rect: TRect; Active: Boolean);
var ARect : TRect;
begin

ARect := Rect;
  //clear complete
  control.Canvas.brush.Color := clBtnFace;
  control.Canvas.FillRect(ARect);
  InflateRect(ARect,-2,-2);
  //decide the color
  if active then
    control.Canvas.brush.Color := clRed
  else
    control.Canvas.brush.Color := clBtnFace;
  //paint the tab
  control.Canvas.FillRect(ARect);
  control.Canvas.TextRect(ARect,ARect.Left+2,ARect.top+1,
                         TPageControl(Control).Pages[TabIndex].Caption);
  Control.Canvas.StretchDraw(rect,Application.icon);//this paints the app.icon on every tab. If you use a appropriate bitmap you can have a nice effect
end;
0
 
kretzschmarCommented:
just to follow this thread . . . currently no time for coding  . . . meikl ;-)
0
 
amielDorelAuthor Commented:
Hi,

i could not find a code example for updating tab's frame.
As far as painting the tab, I found a problem, trying to paint a tab that has the tabvisible property setup for false.

Thanks
Amiel
 
0

Featured Post

Hire Technology Freelancers with Gigs

Work with 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.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now