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

  1. unit Cbtests;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, CB_Gdi, CB3Party, StdCtrls, Printers, CB_MFunc;
  8.  
  9. type
  10.   TWPrintMes = record
  11.     Msg: Word;
  12.     {$IFDEF WIN32}
  13.     wPar: WParam;
  14.     {$ELSE}
  15.     wPar: Word;
  16.     {$ENDIF}
  17.     CBPrint: ^TCBPrint;
  18.     Result: Longint;
  19.   end;
  20.  
  21.  
  22.  
  23. type
  24.   TCBCustomControlTest = class(TCustomControl)
  25.   protected
  26.           procedure Paint; override;
  27.         procedure CBPrint(var msg: TWPrintMes); message CB_PRINT;
  28.   published
  29.           property Brush;
  30.       property Font;
  31.   end;
  32.  
  33. procedure Register;
  34.  
  35. implementation
  36.  
  37. procedure Register;
  38. begin
  39.   RegisterComponents('CBSuite', [TCBCustomControlTest]);
  40. end;
  41.  
  42. procedure TCBCustomControlTest.Paint;
  43. begin
  44.      inherited Paint;
  45.  
  46.    with Canvas do begin
  47.        Font.Assign(Font);
  48.        Brush.Assign(Brush);
  49.        Rectangle( 0,0,Width,Height);
  50.        MoveTo(0,0);
  51.        LineTo(Width,Height);
  52.        MoveTo(Width,0);
  53.        LineTo(0,Height);
  54.        TextOut (2, Height div 2 , 'Hi there, My Parent is a TCustomControl');
  55.     end;
  56.  
  57. end;
  58.  
  59. procedure TCBCustomControlTest.CBPrint(var msg: TWPrintMes);
  60. var
  61.    Point: TPoint;
  62. begin
  63.    Point.X := msg.CBPrint^.Point.x;
  64.    Point.y := msg.CBPrint^.Point.y;
  65.  
  66.    with msg.CBPrint^.Gdi do begin
  67.        SetFinalFont (Font);
  68.        SetBrushPrivate(Brush);
  69.        DFillRect( Rect(0,0,Width,Height), Point);
  70.        DDrawRectangle( 0,0,Width,Height, Point);
  71.        DDrawLine(0,0,Width,Height,Point);
  72.        DDrawLine(Width,0,0,Height,Point);
  73.        DDrawTheText (2, Height div 2 , 'Hi there, My Parent is a TCustomControl', msg.CBPrint^.Point);
  74.    end;
  75.  
  76. end;
  77.  
  78.  
  79. end.
  80.