TVCustomDraw (C++)
Description
The following example is taken from the custom draw demo. It shows how the OnCustomDraw event handler draws the background for the tree view before the items and lines are drawn.
Code
void __fastcall TCustomDrawForm::TVCustomDraw(TCustomTreeView *Sender,
const TRect &ARect, bool &DefaultDraw)
{
/*
This event should be used to draw any background colors or
images. ARect represents the entire client area of the TreeView.
Use the TreeView's canvas to do the drawing. Note that drawing
a background bitmap is not really supported by CustomDraw,
so scrolling can get disorganized. It is best to subclass the TreeView
and handle scrolling messages.
*/
if (None1 != NULL)
{
if (None1->Checked) //No picture
{
TV->Canvas->Brush->Color = BkgColorDialog->Color;
TV->Canvas->Brush->Style = FBrushStyle;
TV->Canvas->FillRect(ARect);
}
else if (Tile1->Checked) //Tile bitmap
{
TV->Canvas->Brush->Bitmap = Image1->Picture->Bitmap;
TV->Canvas->FillRect(ARect);
}
else //Stretch across the canvas.
TV->Canvas->StretchDraw(ARect, Image1->Picture->Bitmap);
};
DefaultDraw = FDefaultDraw;
// Setting DefaultDraw to False prevents all calls to
// OnCustomDrawItem.
}
Uses
- Vcl.ComCtrls.TCustomTreeView.OnCustomDraw ( fr | de | ja )
- Vcl.ComCtrls.TCustomTreeView.Canvas ( fr | de | ja )
- Vcl.Graphics.TPicture.Bitmap ( fr | de | ja )
- Vcl.Graphics.TCanvas.StretchDraw ( fr | de | ja )