A
Allen
How can I use print handler to pring a file?
--------------------------------------------------------------------------------
Hi everybody,
I need your help.
The code below came from a book which teaches how to print a sketch. The
book did not show how to print a file. Right now if I run this program (as
is)it will show the printer dialog box. If I click OK (to print), the
printer will print an empty paper. How can I use this code to print a file
("ReadMe.txt")?
I would apprciate it if you could help.
private: System::Void printToolStripMenuItem_Click(System::Object ^ sender,
System::EventArgs ^ e)
{
// The PrintDocument holds the settings
PrintDocument^ pdoc = gcnew PrintDocument();
// Create a dialog and attach it to the document
PrintDialog^ pd = gcnew PrintDialog();
pd->Document = pdoc;
// Show the dialog
if (pd->ShowDialog() == System::Windows::Forms:ialogResult::OK)
{
// Add the page handler
pdoc->PrintPage += gcnew PrintPageEventHandler(this,&Form1:rintAPage);
// Print the page
pdoc->Print();
}
else
MessageBox::Show("Print cancelled", "Information");
}
void PrintAPage(Object^ pSender, PrintPageEventArgs^ pe)
{
}
--------------------------------------------------------------------------------
Hi everybody,
I need your help.
The code below came from a book which teaches how to print a sketch. The
book did not show how to print a file. Right now if I run this program (as
is)it will show the printer dialog box. If I click OK (to print), the
printer will print an empty paper. How can I use this code to print a file
("ReadMe.txt")?
I would apprciate it if you could help.
private: System::Void printToolStripMenuItem_Click(System::Object ^ sender,
System::EventArgs ^ e)
{
// The PrintDocument holds the settings
PrintDocument^ pdoc = gcnew PrintDocument();
// Create a dialog and attach it to the document
PrintDialog^ pd = gcnew PrintDialog();
pd->Document = pdoc;
// Show the dialog
if (pd->ShowDialog() == System::Windows::Forms:ialogResult::OK)
{
// Add the page handler
pdoc->PrintPage += gcnew PrintPageEventHandler(this,&Form1:rintAPage);
// Print the page
pdoc->Print();
}
else
MessageBox::Show("Print cancelled", "Information");
}
void PrintAPage(Object^ pSender, PrintPageEventArgs^ pe)
{
}