///////////////////////////////////////////////////////////////////// // Form1.h - Demonstrates building a simple WinForm in C++ // // // // Jim Fawcett, CSE681 - Software Modeling and Analysis, Fall 04 // ///////////////////////////////////////////////////////////////////// #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 ref 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: ~Form1() { if(components) { delete components; } } private: System::Windows::Forms::TextBox ^ textBox1; private: System::Windows::Forms::Button ^ button1; private: System::ComponentModel::Container ^ components; void InitializeComponent(void) { this->textBox1 = gcnew System::Windows::Forms::TextBox(); this->button1 = gcnew 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 = "textBox1"; this->textBox1->Size = System::Drawing::Size(232, 72); this->textBox1->TabIndex = 0; this->textBox1->Text = "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 = "button1"; this->button1->Size = System::Drawing::Size(112, 23); this->button1->TabIndex = 1; this->button1->Text = "Submit"; this->button1->Click += gcnew System::EventHandler(this, &WinForm::Form1::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 = "Form1"; this->Text = "Form1"; this->Load += gcnew System::EventHandler(this, &WinForm::Form1::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->SelectionStart = 0; int len = this->textBox1->Text->Length; this->textBox1->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(); } }; }