Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TPageControl.OwnerDraw vs TTabSheet.ImageIndex

Status
Not open for further replies.

rcloutie

Programmer
May 26, 2005
164
CA
Hi there,

I've built a VCL based on TPageControl.
I've set the OwnerDraw property to True.
Here's why:
--
if Active Then Font.Style := [fsBold]
--

Now, I would like to paint bitmaps on the
left side of each tab captions.
OwnerDraw property cancels images painting...

Any idea?

Thanks in advance...

 
turn ownerdraw off before painting images? and back on
when their done?

[bobafett] BobbaFet [bobafett]

Code:
if not Programming = 'Severe Migraine' then
                       ShowMessage('Eureka!');
faq102-5352
 
Now it works... Here's my code:
--------------------------------
procedure MyPage.DrawTab(TabIndex: Integer; const Rect: TRect; Active: Boolean);
var
iImage: Integer;
TabRect: TRect;
begin
with Canvas do
begin
TabRect:= Rect;
Canvas.Brush.Color := clBtnFace;
Canvas.Font.Color := clBtnText;

Canvas.FillRect(TabRect);
iImage := GetImageIndex(TabIndex);
If (iImage >=0) and Assigned(Images) Then
begin
SaveDC(Canvas.Handle);
Images.Draw(Canvas, Rect.Left+4,
Rect.Top+2, iImage,
Pages[TabIndex].Enabled);
RestoreDC(Canvas.Handle, -1);
TabRect.Left := TabRect.Left+Images.Width+4;
End;
InflateRect(TabRect,-2,-2);
DrawFocusRect(Rect);

if Active and bTabBold Then
Font.Style := [fsBold]
else
Font.Style := [];

TextRect(TabRect, TabRect.Left+(TabRect.Right-
TabRect.Left) div 2 - (TextWidth(
Trim(Pages[TabIndex].Caption))) div 2,
TabRect.Top, Pages[TabIndex].Caption);
end;
end;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top