A
Allen
Hi everybody,
I need your help.
I use MS VS C++ 2008
Hi everybody,
I need your help.
The code below is good if I want to print a sketch. The book did not show
how to print a simple text 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?
I would appreciate 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)
{
}
If I put the following code inside the empty function (PrintAPage)I will be
ablble to draw and print what I draw. But what I need is to print an
already written and saved simple text File.
Graphics* gr = pe->Graphics;
Pen* pen1 = new Pen(Color::Black);
// Draw the image
Bitmap* bmp = new Bitmap(S"ramp1.gif");
gr->DrawImage(bmp, 10,10);
for(int i=0; i<list->Count; i++)
{
Line* pl = dynamic_cast<Line*>(list->get_Item(i));
gr->DrawLine(pen1, pl->p1.X,pl->p1.Y, pl->p2.X,pl->p2.Y);
}
Hi everybody,
I need your help.
The code below is good if I want to print a sketch. The book did not show
how to print a simple text 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?
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)
{
}
If I put the following code inside the empty function (PrintAPage)I will be
ablble to draw and print what I draw. But what I need is to print an
already written and saved simple text File.
Graphics* gr = pe->Graphics;
Pen* pen1 = new Pen(Color::Black);
// Draw the image
Bitmap* bmp = new Bitmap(S"ramp1.gif");
gr->DrawImage(bmp, 10,10);
for(int i=0; i<list->Count; i++)
{
Line* pl = dynamic_cast<Line*>(list->get_Item(i));
gr->DrawLine(pen1, pl->p1.X,pl->p1.Y, pl->p2.X,pl->p2.Y);
}
good if I want to print a sketch. The book did not show how to print a
simple text 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?
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)
{
}
If I put the following code inside the empty function (PrintAPage)I will be
ablble to draw and print what I draw. But what I need is to print an
already written and saved simple text File.
Graphics* gr = pe->Graphics;
Pen* pen1 = new Pen(Color::Black);
// Draw the image
Bitmap* bmp = new Bitmap(S"ramp1.gif");
gr->DrawImage(bmp, 10,10);
for(int i=0; i<list->Count; i++)
{
Line* pl = dynamic_cast<Line*>(list->get_Item(i));
gr->DrawLine(pen1, pl->p1.X,pl->p1.Y, pl->p2.X,pl->p2.Y);
}
I need your help.
I use MS VS C++ 2008
Hi everybody,
I need your help.
The code below is good if I want to print a sketch. The book did not show
how to print a simple text 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?
I would appreciate 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)
{
}
If I put the following code inside the empty function (PrintAPage)I will be
ablble to draw and print what I draw. But what I need is to print an
already written and saved simple text File.
Graphics* gr = pe->Graphics;
Pen* pen1 = new Pen(Color::Black);
// Draw the image
Bitmap* bmp = new Bitmap(S"ramp1.gif");
gr->DrawImage(bmp, 10,10);
for(int i=0; i<list->Count; i++)
{
Line* pl = dynamic_cast<Line*>(list->get_Item(i));
gr->DrawLine(pen1, pl->p1.X,pl->p1.Y, pl->p2.X,pl->p2.Y);
}
Hi everybody,
I need your help.
The code below is good if I want to print a sketch. The book did not show
how to print a simple text 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?
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)
{
}
If I put the following code inside the empty function (PrintAPage)I will be
ablble to draw and print what I draw. But what I need is to print an
already written and saved simple text File.
Graphics* gr = pe->Graphics;
Pen* pen1 = new Pen(Color::Black);
// Draw the image
Bitmap* bmp = new Bitmap(S"ramp1.gif");
gr->DrawImage(bmp, 10,10);
for(int i=0; i<list->Count; i++)
{
Line* pl = dynamic_cast<Line*>(list->get_Item(i));
gr->DrawLine(pen1, pl->p1.X,pl->p1.Y, pl->p2.X,pl->p2.Y);
}
good if I want to print a sketch. The book did not show how to print a
simple text 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?
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)
{
}
If I put the following code inside the empty function (PrintAPage)I will be
ablble to draw and print what I draw. But what I need is to print an
already written and saved simple text File.
Graphics* gr = pe->Graphics;
Pen* pen1 = new Pen(Color::Black);
// Draw the image
Bitmap* bmp = new Bitmap(S"ramp1.gif");
gr->DrawImage(bmp, 10,10);
for(int i=0; i<list->Count; i++)
{
Line* pl = dynamic_cast<Line*>(list->get_Item(i));
gr->DrawLine(pen1, pl->p1.X,pl->p1.Y, pl->p2.X,pl->p2.Y);
}