RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TToolBar.Canvas Property

Specifies the drawing surface for the toolbar.

Pascal
property Canvas: TCanvas;
C++
__property TCanvas Canvas;

Use Canvas to draw or paint on the surface of the toolbar in an OnCustomDraw or OnCustomDrawItem event handler. The TCanvas object provides the properties and methods needed for drawing and painting.  

C++ Examples: 

 

/*
The following code uses ClientRect to find and draw a line
from the top left to the bottom right of the current
control.  Select a TControl in the ListBox list.  This
example assumes that the current object is a descendent of
TControl and has a public Canvas property.
*/
{
  TPoint APoint = Point(X, Y);
  int Index = ListBox1->ItemAtPos(APoint, True);
  TToolBar *myToolBar;
  TClass ClassRef = ListBox1->Items->Objects[Index]->ClassType();
  if (String(ClassRef->ClassName()) == "TToolBar")
  {
    myToolBar = dynamic_cast<TToolBar *>(ListBox1->Items->Objects[Index]);
    // make sure we are using the TControls canvas and not the from's!
    myToolBar->Canvas->MoveTo(myToolBar->ClientRect.Left, myToolBar->ClientRect.Top);
    myToolBar->Canvas->LineTo(myToolBar->ClientRect.Right, myToolBar->ClientRect.Bottom);
    myToolBar = NULL;
  }
}

 

Delphi Examples: 

{
The following code uses ClientRect to find and draw a line
from the top left to the bottom right of the current
control.  Select a TControl in the ListBox list.  This
example assumes that the current object is a descendent of
TControl and has a public Canvas property.
}
  if (ListBox1.Items.Objects[Index] is TToolBar) then
  begin
    myToolBar:= (ListBox1.Items.Objects[Index] as TToolBar);
    with myToolBar.ClientRect do
    begin // make sure we are using the TControls canvas and not the from's!
      myToolBar.Canvas.MoveTo(Left, Top);
      myToolBar.Canvas.LineTo(Right, Bottom);
    end;
  myToolBar:= nil;
  end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!