//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "PrinterPageWidth.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
}
//---------------------------------------------------------------------------
// BeginExample: PrinterPageWidth
// Property: Printers.TPrinter.PageWidth

// BeginCode
/*
This example uses a button and a memo on a form. When the
user clicks the button, the content of the memo is printed,
with a 200-pixel border around the page. 
Note: The TMemo will wrap the lines of the text files, so to
see the TextRect clip, the memo width must be large and the
lines in the text file must be long.
*/
void __fastcall TForm1::FormCreate(TObject *Sender)
{
  Memo1->Width = 1000;
  Memo1->Lines->LoadFromFile("..\\readme.txt");
}

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  Printer()->BeginDoc();
  int margin = 1000;
  int X = margin;
  int Y = margin;
  int I = 0;
  while(Y < Printer()->PageHeight)
  {
	Canvas->TextRect(Rect(X, Y, Printer()->PageWidth-margin, Printer()->PageHeight-margin),
					X, Y, Memo1->Lines->Strings[I]);
	Y = Y + 100;
	I = I + 1;
  }
  Printer()->EndDoc();
}
// EndCode
// EndExample: PrinterPageWidth
//---------------------------------------------------------------------------
