PrintExample (C++)

From RAD Studio Code Examples
Jump to: navigation, search

Description

Place a button and a rich edit on the form. No print dialog appears. The content of the rich edit is printed to the currently configured printer.

Code

__fastcall TForm1::TForm1(TComponent* Owner)
  : TForm(Owner)
{
// You may need to change this path to suit your environment.
  wchar_t const *Path = L"..\\OVERVIEW.RTF";
  RichEdit1->Lines->LoadFromFile(Path);
}

void __fastcall TForm1::Button1Click(TObject *Sender)
{
// The parameter string shows in the print queue under "Document   // name".
  RichEdit1->Print(L"My Document Name");
}

Uses