/////////////////////////////////////////////////////////////////
// Form1.h - Demonstrates building a simple WinForm in C++ //
// //
// Jim Fawcett, CSE775 - Distributed Objects, Spring 2011 //
/////////////////////////////////////////////////////////////////
#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 = static_cast((((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(38, 65);
this->textBox1->Multiline = true;
this->textBox1->Name = L"textBox1";
this->textBox1->Size = System::Drawing::Size(221, 42);
this->textBox1->TabIndex = 0;
this->textBox1->Text = L"textBox1";
//
// button1
//
this->button1->Anchor = static_cast(((System::Windows::Forms::AnchorStyles::Bottom
| System::Windows::Forms::AnchorStyles::Left)
| System::Windows::Forms::AnchorStyles::Right));
this->button1->Location = System::Drawing::Point(106, 144);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(76, 26);
this->button1->TabIndex = 1;
this->button1->Text = L"Submit";
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// Form1
//
this->AutoScaleBaseSize = System::Drawing::Size(6, 15);
this->ClientSize = System::Drawing::Size(292, 266);
this->Controls->Add(this->button1);
this->Controls->Add(this->textBox1);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);
this->PerformLayout();
}
private:
System::Void button1_Click(System::Object ^ sender, System::EventArgs ^ e)
{
MsgBox(0,this->textBox1->Text,"A Submission",0);
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();
}
};
}