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

  1. unit Fdemo16;
  2.  
  3. interface
  4.  
  5. uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, Buttons,
  6.   StdCtrls, PrnWin, ExtCtrls, SysUtils,  CB_Types, CB_MFunc;
  7.  
  8. type
  9.   TForm16 = class(TForm)
  10.     OKBtn: TBitBtn;
  11.     InchesGrid: TBitBtn;
  12.     CentiGrid: TBitBtn;
  13.     PrintWin1: TPrintWin;
  14.     procedure InchesGridClick(Sender: TObject);
  15.     procedure CentiGridClick(Sender: TObject);
  16.   private
  17.     { Private declarations }
  18.   public
  19.      procedure DrawGrid;
  20.  end;
  21.  
  22. var
  23.   Form16: TForm16;
  24.  
  25. implementation
  26.  
  27. {$R *.DFM}
  28.  
  29. procedure TForm16.DrawGrid;
  30. var
  31.   i: Integer;
  32.   ir: Real;
  33.  
  34.   xmax: Integer;
  35.   ymax: Integer;
  36.  
  37.   m: Real;
  38. begin
  39.   PrintWin1.BeginPrint;
  40.  
  41.   if PrintWin1.Units = poInches then begin
  42.      m := 1.00
  43.   end else begin
  44.     m := 2.54;
  45.   end;
  46.  
  47.   PrintWin1.DrawRectAt(0,0,PrintWin1.PageWidth,PrintWin1.PageHeight);
  48.  
  49.   xmax := Round( PrintWin1.PageWidth);
  50.   ymax := Round( PrintWin1.PageHeight);
  51.  
  52.   PrintWin1.DrawGrid (0,0,1.0,1.0,xmax,ymax);
  53.  
  54.   ir := 1;
  55.   for i := 1 to xmax-1 do begin
  56.      PrintWin1.DrawTextAt (ir+0.05, 0.25, IntToStr(i));
  57.      ir := ir + 1;
  58.   end;
  59.  
  60.  
  61.   ir := 1;
  62.   for i := 1 to ymax-1 do begin
  63.      PrintWin1.DrawTextAt (0.3, ir, IntToStr(i));
  64.      ir := ir + 1;
  65.   end;
  66.  
  67.  
  68.   PrintWin1.EndPrint;
  69. end;
  70.  
  71. procedure TForm16.InchesGridClick(Sender: TObject);
  72. begin
  73.   PrintWin1.Units := poInches;
  74.   DrawGrid;
  75. end;
  76.  
  77. procedure TForm16.CentiGridClick(Sender: TObject);
  78. begin
  79.   PrintWin1.Units := poCentimetres;
  80.   DrawGrid;
  81. end;
  82.  
  83. end.
  84.