C++ Visual.net : GUI Form ex 3
1 Mouse Jump
using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { this->SuspendLayout(); // // Form1 // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(450, 300); this->Name = L"Form1"; this->Text = L"Mouse Jump"; this->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::Form1_MouseDown); this->ResumeLayout(false); } private: System::Void Form1_MouseDown(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) { // Get mouse x and y coordinates int x = e->X; int y = e->Y; // Get Forms upper left location Point loc = DesktopLocation; // Handle left button mouse click if (e->Button == Windows::Forms::MouseButtons::Left) { Text = String::Format("Mouse Jump - Left Button at {0},{1}", x, y); DesktopLocation = Drawing::Point(loc.X + x, loc.Y +y); } // Handle right button mouse click else if (e->Button == Windows::Forms::MouseButtons::Right) { Text = String::Format("Mouse Jump - Right Button at {0},{1}", x, y); DesktopLocation = Point((loc.X+1) - (ClientSize.Width - x), (loc.Y+1) - (ClientSize.Height - y)); } // Handle middle button mouse click else { Text = String::Format("Mouse Jump - Middle Button at {0},{1}", x, y); DesktopLocation = Point((loc.X+1) - ((ClientSize.Width/2) - x), (loc.Y+1) - ((ClientSize.Height/2) - y)); } } }; [STAThreadAttribute] int main(array<System::String ^> ^args) { Application::Run(gcnew Form1()); return 0; }
2 Panels
using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); } private: System::Windows::Forms::Panel^ Rightpanel; System::Windows::Forms::Button^ button2; System::Windows::Forms::Button^ button1; System::Windows::Forms::Panel^ Leftpanel; System::Windows::Forms::Button^ bnHide; System::Windows::Forms::Button^ bnDisable; void InitializeComponent(void) { this->Rightpanel = (gcnew System::Windows::Forms::Panel()); this->button2 = (gcnew System::Windows::Forms::Button()); this->button1 = (gcnew System::Windows::Forms::Button()); this->Leftpanel = (gcnew System::Windows::Forms::Panel()); this->bnHide = (gcnew System::Windows::Forms::Button()); this->bnDisable = (gcnew System::Windows::Forms::Button()); this->Rightpanel->SuspendLayout(); this->Leftpanel->SuspendLayout(); this->SuspendLayout(); // // Rightpanel // this->Rightpanel->AutoScroll = true; this->Rightpanel->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D; this->Rightpanel->Controls->Add(this->button2); this->Rightpanel->Controls->Add(this->button1); this->Rightpanel->Location = System::Drawing::Point(161, 22); this->Rightpanel->Name = L"Rightpanel"; this->Rightpanel->Size = System::Drawing::Size(121, 60); this->Rightpanel->TabIndex = 3; // // button2 // this->button2->Location = System::Drawing::Point(20, 62); this->button2->Name = L"button2"; this->button2->Size = System::Drawing::Size(75, 23); this->button2->TabIndex = 1; this->button2->Text = L"button 2"; // // button1 // this->button1->Location = System::Drawing::Point(20, 7); this->button1->Name = L"button1"; this->button1->Size = System::Drawing::Size(75, 23); this->button1->TabIndex = 0; this->button1->Text = L"button 1"; // // Leftpanel // this->Leftpanel->BorderStyle = System::Windows::Forms::BorderStyle::FixedSingle; this->Leftpanel->Controls->Add(this->bnHide); this->Leftpanel->Controls->Add(this->bnDisable); this->Leftpanel->Location = System::Drawing::Point(28, 22); this->Leftpanel->Name = L"Leftpanel"; this->Leftpanel->Size = System::Drawing::Size(120, 95); this->Leftpanel->TabIndex = 2; // // bnHide // this->bnHide->Location = System::Drawing::Point(17, 62); this->bnHide->Name = L"bnHide"; this->bnHide->Size = System::Drawing::Size(75, 23); this->bnHide->TabIndex = 1; this->bnHide->Text = L"Hide"; this->bnHide->Click += gcnew System::EventHandler(this, &Form1::bnHide_Click); // // bnDisable // this->bnDisable->Location = System::Drawing::Point(17, 7); this->bnDisable->Name = L"bnDisable"; this->bnDisable->Size = System::Drawing::Size(75, 23); this->bnDisable->TabIndex = 0; this->bnDisable->Text = L"Disable"; this->bnDisable->Click += gcnew System::EventHandler(this, &Form1::bnDisable_Click); // // Form1 // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(310, 139); this->Controls->Add(this->Rightpanel); this->Controls->Add(this->Leftpanel); this->Name = L"Form1"; this->Text = L"A hidden fourth button"; this->Rightpanel->ResumeLayout(false); this->Leftpanel->ResumeLayout(false); this->ResumeLayout(false); } private: System::Void bnDisable_Click(System::Object^ sender, System::EventArgs^ e) { Rightpanel->Enabled = !Rightpanel->Enabled; } private: System::Void bnHide_Click(System::Object^ sender, System::EventArgs^ e) { Rightpanel->Visible = !Rightpanel->Visible; } }; [STAThreadAttribute] int main(array<System::String ^> ^args) { Application::Run(gcnew Form1()); return 0; }
3 Grouping Radios
[STAThreadAttribute] int main(array<System::String ^> ^args) { Application::Run(gcnew Form1()); return 0; } using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); BuildRadios(); } private: System::Windows::Forms::GroupBox^ groupBox2; System::Windows::Forms::GroupBox^ groupBox1; array<System::Windows::Forms::RadioButton^>^ radio1; array<System::Windows::Forms::RadioButton^>^ radio2; array<System::Windows::Forms::RadioButton^>^ radio3; void InitializeComponent(void) { this->groupBox2 = (gcnew System::Windows::Forms::GroupBox()); this->groupBox1 = (gcnew System::Windows::Forms::GroupBox()); this->SuspendLayout(); // // groupBox2 // this->groupBox2->Location = System::Drawing::Point(125, 153); this->groupBox2->Name = L"groupBox2"; this->groupBox2->Size = System::Drawing::Size(152, 134); this->groupBox2->TabIndex = 3; this->groupBox2->TabStop = false; this->groupBox2->Text = L"Use"; // // groupBox1 // this->groupBox1->Location = System::Drawing::Point(125, 12); this->groupBox1->Name = L"groupBox1"; this->groupBox1->Size = System::Drawing::Size(152, 135); this->groupBox1->TabIndex = 2; this->groupBox1->TabStop = false; this->groupBox1->Text = L"You"; // // Form1 // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(352, 330); this->Controls->Add(this->groupBox2); this->Controls->Add(this->groupBox1); this->Name = L"Form1"; this->Text = L"Using Group Boxes"; this->ResumeLayout(false); } void BuildRadios() { this->SuspendLayout(); // Text for RadioButton places on Form directly array<String^>^ rbText1 = gcnew array<String^> { L"Can", L"You", L"Click", L"More", L"Than", L"One" }; // Build a RadioButton for each rbText1 radio1 = gcnew array<RadioButton^>(6); for (int i = 0; i < radio1->Length; i++) { radio1[i] = gcnew RadioButton(); radio1[i]->Location = Drawing::Point(20, 20+(40*i)); radio1[i]->Text = rbText1[i]; } // Add RadioButtons to Form Controls->AddRange(radio1); // Text for RadioButton places in first GroupBox array<String^>^ rbText2 = gcnew array<String^> { L"Can", L"If", L"You" }; // Build a RadioButton for each rbText2 radio2 = gcnew array<RadioButton^>(3); for (int i = 0; i < radio2->Length; i++) { radio2[i] = gcnew RadioButton(); radio2[i]->Location = Drawing::Point(40, 30+(35*i)); radio2[i]->Text = rbText2[i]; } // Add RadioButtons to GroupBox groupBox1->Controls->AddRange(radio2); // Text for RadioButton places in second GroupBox array<String^>^ rbText3 = gcnew array<String^> { L"Different", L"Group", L"Boxes" }; // Build a RadioButton for each rbText3 radio3 = gcnew array<RadioButton^>(3); for (int i = 0; i < radio3->Length; i++) { radio3[i] = gcnew RadioButton(); radio3[i]->Location = Drawing::Point(40, 30+(35*i)); radio3[i]->Text = rbText3[i]; } // Add RadioButtons to GroupBox2 groupBox2->Controls->AddRange(radio3); this->ResumeLayout(false); } };
4 An Array Of RadioButtons
#include "stdafx.h" [STAThreadAttribute] int main(array<System::String ^> ^args) { Application::Run(gcnew Form1()); return 0; } using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); array<String^>^ rbText = gcnew array<String^> {L"Can", L"You", L"Click", L"More", L"Than", L"One"}; radios = gcnew array<RadioButton^>(6); label = gcnew Label(); for (int i = 0; i < radios->Length; i++) { int j = 50*i; radios[i] = gcnew RadioButton(); radios[i]->BackColor = Color::FromArgb(255,j+5,j+5,j+5); radios[i]->ForeColor = Color::FromArgb(255,250-j,250-j,250-j); radios[i]->Location = Drawing::Point(90, 10+(40*i)); radios[i]->TabIndex = i; radios[i]->TabStop = true; radios[i]->Text = rbText[i]; radios[i]->CheckedChanged += gcnew EventHandler(this, &Form1::radioCheckedChanged); } Controls->AddRange(radios); label->Location = Drawing::Point(90, 10+(40*radios->Length)); Controls->Add(label); } private: array<RadioButton^>^ radios; Label ^label; System::ComponentModel::Container ^components; void InitializeComponent(void) { this->SuspendLayout(); this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(292, 273); this->Text = L"An Array Of Radios"; this->ResumeLayout(false); } private: void radioCheckedChanged(Object ^sender, EventArgs ^e) { RadioButton ^rb = (RadioButton^)sender; if (rb->Checked == true) label->Text = rb->Text; } };
5 Split Container Demo
using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); } private: System::Windows::Forms::SplitContainer^ splitContainer1; System::Windows::Forms::TextBox^ textBox1; System::Windows::Forms::SplitContainer^ splitContainer2; System::Windows::Forms::TextBox^ textBox2; System::Windows::Forms::TextBox^ textBox3; void InitializeComponent(void) { this->splitContainer1 = (gcnew System::Windows::Forms::SplitContainer()); this->textBox1 = (gcnew System::Windows::Forms::TextBox()); this->splitContainer2 = (gcnew System::Windows::Forms::SplitContainer()); this->textBox2 = (gcnew System::Windows::Forms::TextBox()); this->textBox3 = (gcnew System::Windows::Forms::TextBox()); this->splitContainer1->Panel1->SuspendLayout(); this->splitContainer1->Panel2->SuspendLayout(); this->splitContainer1->SuspendLayout(); this->splitContainer2->Panel1->SuspendLayout(); this->splitContainer2->Panel2->SuspendLayout(); this->splitContainer2->SuspendLayout(); this->SuspendLayout(); // // splitContainer1 // this->splitContainer1->BackColor = System::Drawing::Color::Green; this->splitContainer1->Dock = System::Windows::Forms::DockStyle::Fill; this->splitContainer1->Location = System::Drawing::Point(0, 0); this->splitContainer1->Name = L"splitContainer1"; // // splitContainer1.Panel1 // this->splitContainer1->Panel1->Controls->Add(this->textBox1); // // splitContainer1.Panel2 // this->splitContainer1->Panel2->Controls->Add(this->splitContainer2); this->splitContainer1->Size = System::Drawing::Size(292, 273); this->splitContainer1->SplitterDistance = 116; this->splitContainer1->TabIndex = 1; this->splitContainer1->Text = L"splitContainer1"; // // textBox1 // this->textBox1->AutoSize = false; this->textBox1->BorderStyle = System::Windows::Forms::BorderStyle::None; this->textBox1->Dock = System::Windows::Forms::DockStyle::Fill; this->textBox1->Location = System::Drawing::Point(0, 0); this->textBox1->Name = L"textBox1"; this->textBox1->Size = System::Drawing::Size(116, 273); this->textBox1->TabIndex = 0; this->textBox1->Text = L"Left Textbox"; this->textBox1->TextAlign = System::Windows::Forms::HorizontalAlignment::Center; // // splitContainer2 // this->splitContainer2->BackColor = System::Drawing::Color::Red; this->splitContainer2->Location = System::Drawing::Point(18, 82); this->splitContainer2->Name = L"splitContainer2"; this->splitContainer2->Orientation = System::Windows::Forms::Orientation::Horizontal; // // splitContainer2.Panel1 // this->splitContainer2->Panel1->Controls->Add(this->textBox2); // // splitContainer2.Panel2 // this->splitContainer2->Panel2->Controls->Add(this->textBox3); this->splitContainer2->Size = System::Drawing::Size(132, 102); this->splitContainer2->SplitterDistance = 42; this->splitContainer2->TabIndex = 0; this->splitContainer2->Text = L"splitContainer2"; // // textBox2 // this->textBox2->AutoSize = false; this->textBox2->BorderStyle = System::Windows::Forms::BorderStyle::None; this->textBox2->Dock = System::Windows::Forms::DockStyle::Fill; this->textBox2->Location = System::Drawing::Point(0, 0); this->textBox2->Name = L"textBox2"; this->textBox2->Size = System::Drawing::Size(132, 42); this->textBox2->TabIndex = 0; this->textBox2->Text = L"Top Right Textbox"; this->textBox2->TextAlign = System::Windows::Forms::HorizontalAlignment::Center; // // textBox3 // this->textBox3->AutoSize = false; this->textBox3->BorderStyle = System::Windows::Forms::BorderStyle::None; this->textBox3->Dock = System::Windows::Forms::DockStyle::Fill; this->textBox3->Location = System::Drawing::Point(0, 0); this->textBox3->Name = L"textBox3"; this->textBox3->Size = System::Drawing::Size(132, 56); this->textBox3->TabIndex = 0; this->textBox3->Text = L"Bottom Right Textbox"; this->textBox3->TextAlign = System::Windows::Forms::HorizontalAlignment::Center; // // Form1 // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(292, 273); this->Controls->Add(this->splitContainer1); this->Name = L"Form1"; this->Text = L"Form1"; this->splitContainer1->Panel1->ResumeLayout(false); this->splitContainer1->Panel2->ResumeLayout(false); this->splitContainer1->ResumeLayout(false); this->splitContainer2->Panel1->ResumeLayout(false); this->splitContainer2->Panel2->ResumeLayout(false); this->splitContainer2->ResumeLayout(false); this->ResumeLayout(false); } }; [STAThreadAttribute] int main(array<System::String ^> ^args) { Application::Run(gcnew Form1()); return 0; }
6 TabControl Demo
using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); } System::Windows::Forms::TabControl^ tabControl1; System::Windows::Forms::TabPage^ tabPage1; System::Windows::Forms::Label^ label2; System::Windows::Forms::TabPage^ tabPage2; System::Windows::Forms::Label^ label1; void InitializeComponent(void) { this->tabControl1 = (gcnew System::Windows::Forms::TabControl()); this->tabPage1 = (gcnew System::Windows::Forms::TabPage()); this->label2 = (gcnew System::Windows::Forms::Label()); this->tabPage2 = (gcnew System::Windows::Forms::TabPage()); this->label1 = (gcnew System::Windows::Forms::Label()); this->tabControl1->SuspendLayout(); this->tabPage1->SuspendLayout(); this->tabPage2->SuspendLayout(); this->SuspendLayout(); // // tabControl1 // this->tabControl1->Alignment = System::Windows::Forms::TabAlignment::Bottom; this->tabControl1->Controls->Add(this->tabPage1); this->tabControl1->Controls->Add(this->tabPage2); this->tabControl1->Dock = System::Windows::Forms::DockStyle::Fill; this->tabControl1->HotTrack = true; this->tabControl1->Location = System::Drawing::Point(0, 0); this->tabControl1->Multiline = true; this->tabControl1->Name = L"tabControl1"; this->tabControl1->SelectedIndex = 0; this->tabControl1->ShowToolTips = true; this->tabControl1->Size = System::Drawing::Size(215, 129); this->tabControl1->TabIndex = 1; // // tabPage1 // this->tabPage1->BackColor = System::Drawing::Color::PaleGreen; this->tabPage1->Controls->Add(this->label2); this->tabPage1->Location = System::Drawing::Point(4, 4); this->tabPage1->Name = L"tabPage1"; this->tabPage1->Padding = System::Windows::Forms::Padding(3); this->tabPage1->Size = System::Drawing::Size(207, 103); this->tabPage1->TabIndex = 0; this->tabPage1->Text = L"Tab One"; this->tabPage1->ToolTipText = L"This is tab one"; this->tabPage1->UseVisualStyleBackColor = false; // // label2 // this->label2->AutoSize = true; this->label2->Location = System::Drawing::Point(61, 44); this->label2->Name = L"label2"; this->label2->Size = System::Drawing::Size(78, 13); this->label2->TabIndex = 1; this->label2->Text = L"This is Tab One"; // // tabPage2 // this->tabPage2->BackColor = System::Drawing::Color::Plum; this->tabPage2->Controls->Add(this->label1); this->tabPage2->Location = System::Drawing::Point(4, 4); this->tabPage2->Name = L"tabPage2"; this->tabPage2->Padding = System::Windows::Forms::Padding(3); this->tabPage2->Size = System::Drawing::Size(207, 103); this->tabPage2->TabIndex = 1; this->tabPage2->Text = L"Tab Two"; this->tabPage2->ToolTipText = L"This is tab two"; this->tabPage2->UseVisualStyleBackColor = false; // // label1 // this->label1->AutoSize = true; this->label1->Location = System::Drawing::Point(61, 44); this->label1->Name = L"label1"; this->label1->Size = System::Drawing::Size(79, 13); this->label1->TabIndex = 0; this->label1->Text = L"This is Tab Two"; // // Form1 // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(215, 129); this->Controls->Add(this->tabControl1); this->Name = L"Form1"; this->Text = L"Tab Control Example"; this->tabControl1->ResumeLayout(false); this->tabPage1->ResumeLayout(false); this->tabPage1->PerformLayout(); this->tabPage2->ResumeLayout(false); this->tabPage2->PerformLayout(); this->ResumeLayout(false); } }; [STAThreadAttribute] int main(array<System::String ^> ^args) { Application::Run(gcnew Form1()); return 0; }
7 ToolStrip Demo
using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; public ref class Form1 : public System::Windows::Forms::Form { public: Form1(void) { InitializeComponent(); } System::Windows::Forms::Label^ lbOutput; System::Windows::Forms::ToolStrip^ toolStrip; System::Windows::Forms::ToolStripButton^ tsbnHappy; System::Windows::Forms::ToolStripButton^ tsbnSad; System::Windows::Forms::ToolStripContainer^ toolStripContainer1; System::Windows::Forms::ToolStripSeparator^ Sep1; System::Windows::Forms::ToolStripLabel^ Label; System::Windows::Forms::ToolStripTextBox^ tstbName; System::ComponentModel::Container ^components; void InitializeComponent(void) { System::ComponentModel::ComponentResourceManager^ resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid)); this->lbOutput = (gcnew System::Windows::Forms::Label()); this->toolStripContainer1 = (gcnew System::Windows::Forms::ToolStripContainer()); this->toolStrip = (gcnew System::Windows::Forms::ToolStrip()); this->tsbnHappy = (gcnew System::Windows::Forms::ToolStripButton()); this->tsbnSad = (gcnew System::Windows::Forms::ToolStripButton()); this->Sep1 = (gcnew System::Windows::Forms::ToolStripSeparator()); this->Label = (gcnew System::Windows::Forms::ToolStripLabel()); this->tstbName = (gcnew System::Windows::Forms::ToolStripTextBox()); this->toolStripContainer1->ContentPanel->SuspendLayout(); this->toolStripContainer1->TopToolStripPanel->SuspendLayout(); this->toolStripContainer1->SuspendLayout(); this->toolStrip->SuspendLayout(); this->SuspendLayout(); // // lbOutput // this->lbOutput->AutoSize = true; this->lbOutput->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, static_cast<System::Byte>(0))); this->lbOutput->Location = System::Drawing::Point(47, 42); this->lbOutput->Name = L"lbOutput"; this->lbOutput->Size = System::Drawing::Size(208, 13); this->lbOutput->TabIndex = 7; this->lbOutput->Text = L"Enter a name then click an emotion"; // // toolStripContainer1 // // // toolStripContainer1.ContentPanel // this->toolStripContainer1->ContentPanel->Controls->Add(this->lbOutput); this->toolStripContainer1->ContentPanel->Size = System::Drawing::Size(300, 104); this->toolStripContainer1->Dock = System::Windows::Forms::DockStyle::Fill; this->toolStripContainer1->Location = System::Drawing::Point(0, 0); this->toolStripContainer1->Name = L"toolStripContainer1"; this->toolStripContainer1->Size = System::Drawing::Size(300, 129); this->toolStripContainer1->TabIndex = 8; this->toolStripContainer1->Text = L"toolStripContainer1"; // // toolStripContainer1.TopToolStripPanel // this->toolStripContainer1->TopToolStripPanel->Controls->Add(this->toolStrip); // // toolStrip // this->toolStrip->Dock = System::Windows::Forms::DockStyle::None; this->toolStrip->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^ >(5) {this->tsbnHappy, this->tsbnSad, this->Sep1, this->Label, this->tstbName}); this->toolStrip->Location = System::Drawing::Point(0, 0); this->toolStrip->Name = L"toolStrip"; this->toolStrip->Size = System::Drawing::Size(300, 25); this->toolStrip->Stretch = true; this->toolStrip->TabIndex = 6; this->toolStrip->Text = L"toolStrip1"; // // tsbnHappy // this->tsbnHappy->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"tsbnHappy.Image"))); this->tsbnHappy->Name = L"tsbnHappy"; this->tsbnHappy->Size = System::Drawing::Size(58, 22); this->tsbnHappy->Text = L"Happy"; this->tsbnHappy->ToolTipText = L"a happy camper"; this->tsbnHappy->Click += gcnew System::EventHandler(this, &Form1::tsbn_Click); // // tsbnSad // this->tsbnSad->Image = (cli::safe_cast<System::Drawing::Image^ >(resources->GetObject(L"tsbnSad.Image"))); this->tsbnSad->Name = L"tsbnSad"; this->tsbnSad->Size = System::Drawing::Size(46, 22); this->tsbnSad->Text = L"Sad"; this->tsbnSad->ToolTipText = L"major gloomy"; this->tsbnSad->Click += gcnew System::EventHandler(this, &Form1::tsbn_Click); // // Sep1 // this->Sep1->Name = L"Sep1"; this->Sep1->Size = System::Drawing::Size(6, 25); // // Label // this->Label->Name = L"Label"; this->Label->Size = System::Drawing::Size(35, 22); this->Label->Text = L"Name"; // // tstbName // this->tstbName->Name = L"tstbName"; this->tstbName->Size = System::Drawing::Size(92, 25); this->tstbName->Text = L"Computer"; // // Form1 // this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Inherit; this->ClientSize = System::Drawing::Size(300, 129); this->Controls->Add(this->toolStripContainer1); this->Name = L"Form1"; this->Text = L"Emotional Tool Strip"; this->toolStripContainer1->ContentPanel->ResumeLayout(false); this->toolStripContainer1->ContentPanel->PerformLayout(); this->toolStripContainer1->TopToolStripPanel->ResumeLayout(false); this->toolStripContainer1->TopToolStripPanel->PerformLayout(); this->toolStripContainer1->ResumeLayout(false); this->toolStripContainer1->PerformLayout(); this->toolStrip->ResumeLayout(false); this->toolStrip->PerformLayout(); this->ResumeLayout(false); } private: System::Void tsbn_Click(System::Object^ sender, System::EventArgs^ e) { this->lbOutput->Text = String::Format("{0} is {1}!", tstbName->Text, ((ToolStripButton^)sender)->ToolTipText); } }; [STAThreadAttribute] int main(array<System::String ^> ^args) { Application::Run(gcnew Form1()); return 0; }