C++ Windows Form Application Printing
-
this is my code in windows form.... it compiles without error but it prints blank page.... where i done wrong?? please help...
#pragma endregion
// Declare the PrintDocument object.private: System::Void Button1\_Click\_1(System::Object^ sender, System::EventArgs^ e) {
PrintDialog1->AllowSomePages = true;
PrintDialog1->ShowHelp = true;
PrintDocument ^docToPrint = gcnew PrintDocument;
PrintDialog1->Document = docToPrint;
if ( docToPrint == nullptr )
System::Windows::Forms::MessageBox::Show( "null" );if ( PrintDialog1 == nullptr )
System::Windows::Forms::MessageBox::Show( "pnull" );System::Windows::Forms::DialogResult result = PrintDialog1->ShowDialog();
System::Windows::Forms::MessageBox::Show( result.ToString() );if ( result == System::Windows::Forms::DialogResult::OK )
{
docToPrint->Print();
}}
private: System::Void document_PrintPage_1(System::Object^ sender, System::Drawing::Printing::PrintPageEventArgs^ e) {
String^ text = "In document_PrintPage method.";
System::Drawing::Font^ printFont = gcnew System::Drawing::Font( "Times New Roman",20,System::Drawing::FontStyle::Bold );e->Graphics->DrawString("EAK TEAM TEST!!!",printFont,Brushes::Black,50,50);
e->Graphics->DrawString( text, printFont, System::Drawing::Brushes::Black, 10, 10 );
} -
this is my code in windows form.... it compiles without error but it prints blank page.... where i done wrong?? please help...
#pragma endregion
// Declare the PrintDocument object.private: System::Void Button1\_Click\_1(System::Object^ sender, System::EventArgs^ e) {
PrintDialog1->AllowSomePages = true;
PrintDialog1->ShowHelp = true;
PrintDocument ^docToPrint = gcnew PrintDocument;
PrintDialog1->Document = docToPrint;
if ( docToPrint == nullptr )
System::Windows::Forms::MessageBox::Show( "null" );if ( PrintDialog1 == nullptr )
System::Windows::Forms::MessageBox::Show( "pnull" );System::Windows::Forms::DialogResult result = PrintDialog1->ShowDialog();
System::Windows::Forms::MessageBox::Show( result.ToString() );if ( result == System::Windows::Forms::DialogResult::OK )
{
docToPrint->Print();
}}
private: System::Void document_PrintPage_1(System::Object^ sender, System::Drawing::Printing::PrintPageEventArgs^ e) {
String^ text = "In document_PrintPage method.";
System::Drawing::Font^ printFont = gcnew System::Drawing::Font( "Times New Roman",20,System::Drawing::FontStyle::Bold );e->Graphics->DrawString("EAK TEAM TEST!!!",printFont,Brushes::Black,50,50);
e->Graphics->DrawString( text, printFont, System::Drawing::Brushes::Black, 10, 10 );
} -
this is my code in windows form.... it compiles without error but it prints blank page.... where i done wrong?? please help...
#pragma endregion
// Declare the PrintDocument object.private: System::Void Button1\_Click\_1(System::Object^ sender, System::EventArgs^ e) {
PrintDialog1->AllowSomePages = true;
PrintDialog1->ShowHelp = true;
PrintDocument ^docToPrint = gcnew PrintDocument;
PrintDialog1->Document = docToPrint;
if ( docToPrint == nullptr )
System::Windows::Forms::MessageBox::Show( "null" );if ( PrintDialog1 == nullptr )
System::Windows::Forms::MessageBox::Show( "pnull" );System::Windows::Forms::DialogResult result = PrintDialog1->ShowDialog();
System::Windows::Forms::MessageBox::Show( result.ToString() );if ( result == System::Windows::Forms::DialogResult::OK )
{
docToPrint->Print();
}}
private: System::Void document_PrintPage_1(System::Object^ sender, System::Drawing::Printing::PrintPageEventArgs^ e) {
String^ text = "In document_PrintPage method.";
System::Drawing::Font^ printFont = gcnew System::Drawing::Font( "Times New Roman",20,System::Drawing::FontStyle::Bold );e->Graphics->DrawString("EAK TEAM TEST!!!",printFont,Brushes::Black,50,50);
e->Graphics->DrawString( text, printFont, System::Drawing::Brushes::Black, 10, 10 );
} -
See http://www.codeproject.com/KB/printing/[^] for samples and articles on printing in .NET.
Use the best guess
-
i dont see any tutorial for c++ windows form???? please help
"The more quieter you become, the more you are able to hear..."
-
yes .. but i didnt get an answer... and this is very very important to me...
"The more quieter you become, the more you are able to hear..."
-
eakteam wrote:
very very important to me
So? That is no reason to rudely post this over and over.
-
You will have to look at the C# and VB.NET samples and adapt your code from them, as they all use the same .NET framework.
Use the best guess
-
ok i see ur disturbing... im sorry. nobody born with c++ LANGUAGE knowledge.. u too, like me was amateur....
"The more quieter you become, the more you are able to hear..."