Click here to Skip to main content
14,772,793 members
Home » Discussions » Managed C++/CLI
   

Managed C++/CLI

 
AnswerRe: I get Input string was not in a correct format. error Pin
Richard MacCutchan15-Apr-13 5:38
mveRichard MacCutchan15-Apr-13 5:38 
AnswerRe: I get Input string was not in a correct format. error Pin
eakteam17-Apr-13 0:35
professionaleakteam17-Apr-13 0:35 
AnswerRe: I get Input string was not in a correct format. error Pin
Member 1000269911-May-13 1:48
MemberMember 1000269911-May-13 1:48 
QuestionC++ CLR Windows Form Application (Printing to the Printer) Pin
eakteam14-Apr-13 12:58
professionaleakteam14-Apr-13 12:58 
AnswerRe: C++ CLR Windows Form Application (Printing to the Printer) Pin
Richard MacCutchan14-Apr-13 21:59
mveRichard MacCutchan14-Apr-13 21:59 
GeneralRe: C++ CLR Windows Form Application (Printing to the Printer) Pin
eakteam15-Apr-13 0:59
professionaleakteam15-Apr-13 0:59 
GeneralRe: C++ CLR Windows Form Application (Printing to the Printer) Pin
Richard MacCutchan15-Apr-13 1:24
mveRichard MacCutchan15-Apr-13 1:24 
GeneralRe: C++ CLR Windows Form Application (Printing to the Printer) Pin
eakteam15-Apr-13 1:43
professionaleakteam15-Apr-13 1:43 
THIS IS MY CODE AND VISUAL STUDIO DEBUGER SHOW : A first chance exception of type 'System.NullReferenceException' occurred in System.Drawing.dll



#pragma once
#using <System.dll>
#using <System.Windows.Forms.dll>
#using <System.Drawing.dll>


namespace Printing2 {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;
	using namespace System::Drawing::Printing;
	using namespace System::IO;
	

	/// <summary>
	/// Summary for Form1
	///
	/// WARNING: If you change the name of this class, you will need to change the
	///          'Resource File Name' property for the managed resource compiler tool
	///          associated with all .resx files this class depends on.  Otherwise,
	///          the designers will not be able to interact properly with localized
	///          resources associated with this form.
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::Button^  Button1;
	private: System::Windows::Forms::PrintDialog^  PrintDialog1;
	private: System::Drawing::Printing::PrintDocument^  document;
	protected: 

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->Button1 = (gcnew System::Windows::Forms::Button());
			this->PrintDialog1 = (gcnew System::Windows::Forms::PrintDialog());
			this->document = (gcnew System::Drawing::Printing::PrintDocument());
			this->SuspendLayout();
			// 
			// Button1
			// 
			this->Button1->Location = System::Drawing::Point(94, 106);
			this->Button1->Name = L"Button1";
			this->Button1->Size = System::Drawing::Size(75, 23);
			this->Button1->TabIndex = 0;
			this->Button1->Text = L"button1";
			this->Button1->UseVisualStyleBackColor = true;
			this->Button1->Click += gcnew System::EventHandler(this, &Form1::Button1_Click);
			// 
			// PrintDialog1
			// 
			this->PrintDialog1->UseEXDialog = true;
			// 
			// document
			// 
			this->document->PrintPage += gcnew System::Drawing::Printing::PrintPageEventHandler(this, &Form1::document_PrintPage_1);
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(292, 266);
			this->Controls->Add(this->Button1);
			this->Name = L"Form1";
			this->Text = L"Form1";
			this->ResumeLayout(false);

		}
#pragma endregion
		System::Drawing::Printing::PrintDocument ^ docToPrint;

	private: System::Void Button1_Click(System::Object^  sender, System::EventArgs^  e) {
			 
				 // Allow the user to choose the page range he or she would 
   // like to print.
   PrintDialog1->AllowSomePages = true;

   // Show the help button.
   PrintDialog1->ShowHelp = true;

   // Set the Document property to the PrintDocument for  
   // which the PrintPage Event has been handled. To display the 
   // dialog, either this property or the PrinterSettings property  
   // must be set 
   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());
   ;
   ;
   try{
   // If the result is OK then print the document. 
   if ( result == System::Windows::Forms::DialogResult::OK )
   {
      docToPrint->Print();
   }
   }
   catch (Exception ^T){
	   MessageBox::Show(T->Message);
   }

			 }
	
	private: System::Void document_PrintPage_1(System::Object^  sender, System::Drawing::Printing::PrintPageEventArgs^  e) {
				 // Insert code to render the page here. 
   // This code will be called when the control is drawn. 
   // The following code will render a simple 
   // message on the printed document.
   String^ text = "In document_PrintPage method.";
   System::Drawing::Font^ printFont = gcnew System::Drawing::Font( "Arial",35,System::Drawing::FontStyle::Regular );

   // Draw the content.
   e->Graphics->DrawString( text, printFont, System::Drawing::Brushes::Black, 10, 10 );
			 }
};
}

GeneralRe: C++ CLR Windows Form Application (Printing to the Printer) Pin
Richard MacCutchan15-Apr-13 2:06
mveRichard MacCutchan15-Apr-13 2:06 
GeneralRe: C++ CLR Windows Form Application (Printing to the Printer) Pin
eakteam15-Apr-13 2:33
professionaleakteam15-Apr-13 2:33 
GeneralRe: C++ CLR Windows Form Application (Printing to the Printer) Pin
Pete O'Hanlon15-Apr-13 4:38
mvePete O'Hanlon15-Apr-13 4:38 
GeneralRe: C++ CLR Windows Form Application (Printing to the Printer) Pin
eakteam15-Apr-13 7:00
professionaleakteam15-Apr-13 7:00 
GeneralRe: C++ CLR Windows Form Application (Printing to the Printer) Pin
kklim27-Aug-13 0:07
Memberkklim27-Aug-13 0:07 
GeneralRe: C++ CLR Windows Form Application (Printing to the Printer) Pin
Richard MacCutchan27-Aug-13 4:47
mveRichard MacCutchan27-Aug-13 4:47 
GeneralRe: C++ CLR Windows Form Application (Printing to the Printer) Pin
kklim27-Aug-13 19:40
Memberkklim27-Aug-13 19:40 
GeneralRe: C++ CLR Windows Form Application (Printing to the Printer) Pin
Richard MacCutchan27-Aug-13 21:51
mveRichard MacCutchan27-Aug-13 21:51 
GeneralRe: C++ CLR Windows Form Application (Printing to the Printer) Pin
kklim27-Aug-13 23:47
Memberkklim27-Aug-13 23:47 
GeneralRe: C++ CLR Windows Form Application (Printing to the Printer) Pin
Richard MacCutchan27-Aug-13 23:55
mveRichard MacCutchan27-Aug-13 23:55 
GeneralRe: C++ CLR Windows Form Application (Printing to the Printer) Pin
kklim29-Aug-13 19:49
Memberkklim29-Aug-13 19:49 
QuestionC++ and xaml connection to access database code Pin
juma owori11-Apr-13 0:34
Memberjuma owori11-Apr-13 0:34 
AnswerRe: C++ and xaml connection to access database code Pin
Richard MacCutchan11-Apr-13 1:48
mveRichard MacCutchan11-Apr-13 1:48 
Questionconversion from tchar* to string^ Pin
raghunath sahoo3-Apr-13 5:38
Memberraghunath sahoo3-Apr-13 5:38 
AnswerRe: conversion from tchar* to string^ Pin
NotPolitcallyCorrect3-Apr-13 6:13
MemberNotPolitcallyCorrect3-Apr-13 6:13 
AnswerRe: conversion from tchar* to string^ Pin
Richard MacCutchan3-Apr-13 6:13
mveRichard MacCutchan3-Apr-13 6:13 
QuestionCreating a global array of labels at runtime Pin
Douglas Kirk31-Mar-13 12:30
MemberDouglas Kirk31-Mar-13 12:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.