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

  1. unit Fdemo10;
  2.  
  3. interface
  4.  
  5. uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, Buttons,
  6.   StdCtrls, ExtCtrls, Printers, PrnWin, SysUtils,  CB_Types, CB_MFunc;
  7.  
  8. type
  9.   TForm10 = class(TForm)
  10.     CancelBtn: TBitBtn;
  11.     Bevel1: TBevel;
  12.     Label9: TLabel;
  13.     Label10: TLabel;
  14.     Preview: TBitBtn;
  15.     PrintWin1: TPrintWin;
  16.     procedure PreviewClick(Sender: TObject);
  17.   private
  18.     { Private declarations }
  19.   public
  20.   end;
  21.  
  22. var
  23.   Form10: TForm10;
  24.  
  25. implementation
  26.  
  27. {$R *.DFM}
  28.  
  29. { This runs the Print Viewer }
  30. procedure TForm10.PreviewClick(Sender: TObject);
  31. var
  32.     Str: String;
  33.   Str2: String;
  34.   Border: Real;
  35.   MyUnits: String;
  36.   Mul: Real;
  37. begin
  38.    PrintWin1.BeginPrint;
  39.    PrintWin1.NewFont ('Arial',16,True,True,False);
  40.    PrintWin1.SetTheTextColor (RGB(0,0,0));
  41.    Border := 0.5;
  42.    if PrintWin1.Units <> poCentimetres then begin
  43.      MyUnits := 'Inches';
  44.      Mul := 1.0;
  45.    end else begin
  46.      MyUnits := 'Centimetre';
  47.      Mul := 2.54;
  48.    end;
  49.    PrintWin1.DrawRectAt( Border*Mul, Border*Mul, PrintWin1.PageWidth-(Border*Mul),
  50.       PrintWin1.PageHeight-(Border*Mul));
  51.    PrintWin1.DrawText( 1.0*Mul, poCenter, 'The Layout of the selected page');
  52.    Str2 := Printer.Printers[Printer.PrinterIndex];
  53.    Str := Format('You have selected Printer : %s',[Str2]);
  54.    PrintWin1.DrawTextAt( 1*Mul, 1.4*Mul, Str);
  55.    if Printer.Orientation = poPortrait then
  56.        Str := 'You have selected Portrait Mode'
  57.    else
  58.        Str := 'You have selected Landscape Mode';
  59.    PrintWin1.DrawTextAt( 1*Mul, 1.8*Mul, Str);
  60.  
  61.    Str := Format('The Page Height in pixels is : %d',[Printer.PageHeight]);
  62.    PrintWin1.DrawTextAt( 1*Mul, 2.2*Mul, Str);
  63.    Str := Format('The Page Width in pixels is : %d',[Printer.PageWidth]);
  64.    PrintWin1.DrawTextAt( 1*Mul, 2.6*Mul, Str);
  65.    Str := Format('The Page Width in %s is : %f',[MyUnits,PrintWin1.PageWidth]);
  66.    PrintWin1.DrawTextAt( 1*Mul, 3*Mul, Str);
  67.  
  68.    PrintWin1.EndPrint;
  69. end;
  70.  
  71.  
  72. end.
  73.