///////////////////////////////////////////////////////////////// // Form1.h - Basic Demonstration of C++ WinForm Project // // // // Jim Fawcett, CSE775 - Distributed Objects, Spring 2005 // ///////////////////////////////////////////////////////////////// #pragma once namespace WinForm { 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::Runtime::InteropServices; // for MsgBox PInvoke /// /// 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. /// public __gc class Form1 : public System::Windows::Forms::Form { public: [DllImport("User32.dll", EntryPoint="MessageBox", CharSet=CharSet::Auto)] static int MsgBox(int hWnd, String* text, String* caption, unsigned int type); Form1(void) { InitializeComponent(); } protected: void Dispose(Boolean disposing) { if (disposing && components) { components->Dispose(); } __super::Dispose(disposing); } private: System::Windows::Forms::TextBox * textBox1; private: System::Windows::Forms::Button * button1; private: System::ComponentModel::Container * components; void InitializeComponent(void) { this->textBox1 = new System::Windows::Forms::TextBox(); this->button1 = new System::Windows::Forms::Button(); this->SuspendLayout(); // // textBox1 // this->textBox1->AcceptsReturn = true; this->textBox1->AcceptsTab = true; this->textBox1->Anchor = (System::Windows::Forms::AnchorStyles) (((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom) | System::Windows::Forms::AnchorStyles::Left) | System::Windows::Forms::AnchorStyles::Right); this->textBox1->Location = System::Drawing::Point(32, 56); this->textBox1->Multiline = true; this->textBox1->Name = S"textBox1"; this->textBox1->Size = System::Drawing::Size(232, 72); this->textBox1->TabIndex = 0; this->textBox1->Text = S"textBox1"; // // button1 // this->button1->Anchor = (System::Windows::Forms::AnchorStyles) ((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left) | System::Windows::Forms::AnchorStyles::Right); this->button1->Location = System::Drawing::Point(88, 160); this->button1->Name = S"button1"; this->button1->Size = System::Drawing::Size(112, 23); this->button1->TabIndex = 1; this->button1->Text = S"Submit"; this->button1->Click += new System::EventHandler(this, button1_Click); // // Form1 // this->AutoScaleBaseSize = System::Drawing::Size(5, 13); this->ClientSize = System::Drawing::Size(292, 266); this->Controls->Add(this->button1); this->Controls->Add(this->textBox1); this->Name = S"Form1"; this->Text = S"Form1"; this->Load += new System::EventHandler(this, Form1_Load); this->ResumeLayout(false); } private: System::Void button1_Click(System::Object * sender, System::EventArgs * e) { MsgBox(0,this->textBox1->Text,"A Submission",0); this->textBox1->set_SelectionStart(0); int len = this->textBox1->Text->Length; this->textBox1->set_SelectionLength(len); this->textBox1->Focus(); } System::Void Form1_Load(System::Object * sender, System::EventArgs * e) { this->textBox1->Text = " Hello Forms World\r\n CSE775 - Distributed Objects"; this->textBox1->Focus(); } }; }