Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Hmmm. I don't know how to do that. I can tell you how to open and read it. Which version on Builder are you using?without opening and reading it.
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
//Make sure the font dialog starts with the same font as the memo box
FontDialog1->Font = mEdit->Font;
//Make sure the printer starts with the same font as the memo box
Printer()->Canvas->Font = mEdit->Font;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Exit1Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Font1Click(TObject *Sender)
{
//If the user pressed OK on the font dialog
if (FontDialog1->Execute())
{
//Change the font of the memo box
mEdit->Font = FontDialog1->Font;
//Change the font of the printer
Printer()->Canvas->Font = FontDialog1->Font;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::PrinterSetup1Click(TObject *Sender)
{
//Bring up the print setup dialog box
PrinterSetupDialog1->Execute();
//Change the font of the printer just in case user changed
Printer()->Canvas->Font = FontDialog1->Font;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Print1Click(TObject *Sender)
{
int Iterations, Copies, LineOnPage, LinesPerPage;
int StartLine, EndLine;
int x, y, z, PageNumber;
bool NewPageRequired;
//If the user did not press OK on the printer dialog, return
if (!PrintDialog1->Execute())
return;
//Change the font of the printer just in case user changed
Printer()->Canvas->Font = FontDialog1->Font;
//Printer will start at the top of a new page
//So we don't have to issue a new page before printing the
//first page
NewPageRequired = FALSE;
//Calculate number of lines that can fit on a page
LinesPerPage = (Printer()->PageHeight /
Printer()->Canvas->TextHeight("W"));
//If the user did not ask for collation
if (!PrintDialog1->Collate)
{
//Loop through all the pages once
Iterations = 1;
//Print as many copies of each page as the user requested
Copies = PrintDialog1->Copies;
}
//User wants to collate
else
{
//Loop through all the pages enough times
//to make all the copies the user requested
Iterations = PrintDialog1->Copies;
//Print each page once per iteration
Copies = 1;
}
//Set the title used in the print manager to identify this job
Printer()->Title = "C++ Builder How-to Printer Example 1";
//Start the printing job
Printer()->BeginDoc();
//Start with the first line
LineOnPage = 0;
//Outer loop runs only once unless user requested collation
for (x = 0; x < Iterations; x++)
{
//Always start at the first page
PageNumber = 1;
//Loop runs until we run out of pages to print
do
{
//Loop to print multiple copies of a page (if required)
for (y = 0; y < Copies; y++)
{
//If a new page is required
if (NewPageRequired)
{
//Print a new page
Printer()->NewPage();
//Reset the line count
LineOnPage = 0;
}
//Must always print a new page
//for pages after the first
NewPageRequired = TRUE;
//Calculate the memo line that prints at the top of this page
StartLine = ((PageNumber - 1) * LinesPerPage);
//Calculate the memo line that prints at the bottom of this page
EndLine = LinesPerPage + ((PageNumber - 1) * LinesPerPage) - 1;
//Asjust the ending line count for the last page (which may not be full)
if (EndLine >= mEdit->Lines->Count)
EndLine = mEdit->Lines->Count;
//For each memo line that will appear on this page
for (z = StartLine; z < EndLine; z++)
{
//Print out a line
Printer()->Canvas->TextOut(20,
Printer()->Canvas->TextHeight(mEdit->Lines->Strings[z]) * LineOnPage,
mEdit->Lines->Strings[z].c_str());
//Increment the line count
LineOnPage++;
}
}
//Required copies of page are printed
//Increment the page number
PageNumber++;
//Keep going until we're out of lines to print
} while (EndLine < mEdit->Lines->Count );
}
//Close the document
Printer()->EndDoc();
}
//---------------------------------------------------------------------------