How can I use print handler to pring a file?

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)
{




}
 
P

Patrice

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,045
Messages
2,570,389
Members
47,052
Latest member
ketan

Latest Threads

Top