How can I use print handler to pring a file?

  • Thread starter Thread starter Allen
  • Start date Start date
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::PrintAPage);
// Print the page
pdoc->Print();

}
else
MessageBox::Show("Print cancelled", "Information");
}

void PrintAPage(Object^ pSender, PrintPageEventArgs^ pe)
{




}
 
Can you give me an address for a Windows programming group?

I would try a group such as :

microsoft.public.dotnet.framework.windowsforms.

Also the link I provided earlier shows how to print a file assuming each
line is small enought to fit on a single line. It uses C# but it should be
easy to convert to C++/CLI.
 
Back
Top