home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / delphi / cbsuite.lzh / SU1SRC.ZIP / CBTESTS2.PAS < prev    next >
Pascal/Delphi Source File  |  1997-01-15  |  2KB  |  82 lines

  1. unit Cbtests2;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, CB_Gdi, CB3Party;
  8.  
  9. type
  10.   TCBGraphicControlTest = class(TCBGraphicControl)
  11.   private
  12.           FBrush: TBrush;
  13.   protected
  14.       constructor Create(AOwner: TComponent); override;
  15.       destructor  Destroy; override;
  16.         procedure   Paint; override;
  17.   public
  18.         procedure PrintWindow( var CBPrint: TCBPrint ); override;
  19.   published
  20.           property Brush: TBrush   read   FBrush   write  FBrush;
  21.       property Font;
  22.   end;
  23.  
  24. procedure Register;
  25.  
  26. implementation
  27.  
  28. procedure Register;
  29. begin
  30.   RegisterComponents('CBSuite', [TCBGraphicControlTest]);
  31. end;
  32.  
  33. constructor TCBGraphicControlTest.Create(AOwner: TComponent);
  34. begin
  35.    inherited Create(AOwner);
  36.    FBrush := TBrush.Create;
  37. end;
  38.  
  39. destructor  TCBGraphicControlTest.Destroy;
  40. begin
  41.     FBrush.Free;
  42.    inherited Destroy;
  43. end;
  44.  
  45.  
  46. procedure TCBGraphicControlTest.Paint;
  47. begin
  48.      inherited Paint;
  49.    Canvas.Brush.Assign(FBrush);
  50.    Canvas.Font.Assign(Font);
  51.    Canvas.Rectangle( 0,0,Width,Height);
  52.    Canvas.MoveTo(0,0);
  53.    Canvas.LineTo(Width,Height);
  54.    Canvas.MoveTo(Width,0);
  55.    Canvas.LineTo(0,Height);
  56.    Canvas.TextOut (2, Height div 2 , 'Hi there, My Parent is a TCBGraphicControl');
  57.  
  58.  
  59. end;
  60.  
  61.  
  62. procedure TCBGraphicControlTest.PrintWindow( var CBPrint: TCBPrint );
  63. var
  64.     Point: TPoint;
  65. begin
  66.    Point.X := CBPrint.Point.x;
  67.    Point.y := CBPrint.Point.y;
  68.  
  69.    with CBPrint.Gdi do begin
  70.        SetFinalFont (Font);
  71.        SetBrushPrivate(FBrush);
  72.        DFillRect( Rect(0,0,Width,Height), CBPrint.Point);
  73.        DDrawRectangle( 0,0,Width,Height, CBPrint.Point);
  74.        DDrawLine(0,0,Width,Height,CBPrint.Point);
  75.        DDrawLine(Width,0,0,Height,CBPrint.Point);
  76.        DDrawTheText (2, Height div 2 , 'Hi there, My Parent is a TCBGraphicControl', CBPrint.Point);
  77.     end;
  78. end;
  79.  
  80.  
  81. end.
  82.