Printing in Borland Builder C++

I'm a selfmade programmer in C++ and I have Borland Builder C++ 4
I need to print several pages and I have problems.
I did the following program who has a Window (Unit1.cpp) only whith a Button.
When clicking that Button the program must print 3 pages:
//---------------------------------------------------------------------
#pragma hdrstop
#include "Unit1.h"
#include <iostream> // cout cin e outras I/O basicas
#include <cstdlib> // biblioteca standard
#include <cstdio> // biblioteca standard
#include <cstring> // rotinas de manuseio de strings
#include <Printers.hpp>
#include <vcl/dstring.h>
#pragma package(smart_init)
#pragma resource "*.dfm"
//
// char actualline = "The Quick Brown Fox Jumps Over the Lazy Dog ";
// char pagetitle = "Headings...";
// I've tried with char and with AnsiString with the same result.
//
AnsiString actualline = "The Quick Brown Fox Jumps Over the Lazy Dog ";
AnsiString pagetitle = "Headings...";
//---------------------------------------------------------------------------
TPrinter *myPrinter;
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { }
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender) //
{
// frist method
Printer()->BeginDoc();
Printer()->Canvas->TextOut(0, 0, "Hello, world");
Printer()->EndDoc();
// second method
myPrinter = new TPrinter(); // opens printer
myPrinter->Canvas->Font->Name = "Courier New"; // Font
myPrinter->Canvas->Font->Size = 8; // Size
myPrinter->Orientation = poLandscape; // Orientation
myPrinter->BeginDoc(); // Begins Doc
for (int pages=1;pages<3;pages++) // will do 2 pages
{
myPrinter->Canvas->TextOut(1,1,pagetitle); // Writes Page Heading
for (int lines=2;lines<30;lines++) // will do 28 lines
myPrinter->Canvas->TextOut(lines,1,actualline);// do a line
myPrinter->NewPage(); // next page
};
myPrinter->EndDoc(); // Closes Doc
}
//---------------------------------------------------------------------------
/* Builder Help file says:
TCanvas::TextOut example

This example displays a text string at a specified position on
the form when the user clicks the button on the form:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Canvas->TextOut(20, 20, "C++Builder makes Windows programming easy");
}
and says also:
TPrinter::Canvas example

Printer()->BeginDoc();
Printer()->Canvas()->TextOut(0, 0, "Hello, world");
Printer()->EndDoc;

but the compiler doesn't accept that statement and accuses "Call of nonfuntion"
to Canvas() and "E2235 Member function must be called..." to EndDoc;
so I tried to take out the Canvas parentesis and I put one to EnDoc()

This way it functions well (almost)
It printed a page with "Hello, word"
and two pages ONE LINE EACH in landscape with "The Quick....."
The word "Headings" did NOT appear anywhere.

Where are the Heading and the 27 next lines of each page?
Can someone HELP ME, PLEASE...MANY THANKS.
*/
//---------------------------------------------------------------------------
Topic archived. No new replies allowed.