Link to home
Start Free TrialLog in
Avatar of amielDorel
amielDorel

asked on

TpageControl tab drawing example.

I am looking for an example of how to draw a TpageControl tab (user draw)
Thanks
Amiel
ASKER CERTIFIED SOLUTION
Avatar of Ferruccio Accalai
Ferruccio Accalai
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of amielDorel
amielDorel

ASKER

Thanks it works,  how about painting the border of the tab?    is it posible to set an image to cover the tab ?
Thanks again
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;
just to follow this thread . . . currently no time for coding  . . . meikl ;-)
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