RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TCustomTabControl.Canvas Property

Gives access to the tab control's canvas.

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

Use Canvas to paint to the tab control's canvas during the OnDrawTab event.  

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);
  TPageControl *myPageControl;
  TClass ClassRef = ListBox1->Items->Objects[Index]->ClassType();
  if (String(ClassRef->ClassName()) == "TPageControl")
  {
    myPageControl = dynamic_cast<TPageControl *>(ListBox1->Items->Objects[Index]);
    // make sure we are using the TControls canvas and not the from's!
    myPageControl->Canvas->MoveTo(myPageControl->ClientRect.Left, myPageControl->ClientRect.Top);
    myPageControl->Canvas->LineTo(myPageControl->ClientRect.Right, myPageControl->ClientRect.Bottom);
    myPageControl = 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 TPageControl) then
  begin
    myPageControl:= (ListBox1.Items.Objects[Index] as TPageControl);
    with myPageControl.ClientRect do
    begin // make sure we are using the TControl's canvas and not the form's!
      myPageControl.Canvas.MoveTo(Left, Top);
      myPageControl.Canvas.LineTo(Right, Bottom);
    end;
  myPageControl:= nil;
  end;

 

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