Re: Fruit basket program in C++/CLI

  • From: "Lamar Upshaw" <lupshaw@xxxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Mon, 19 Nov 2007 00:30:03 -0800

Just to clarify, I should be able to run this using minGW, correct?

With All Respect,
Upshaw, Lamar T
----- Original Message ----- 
From: "Jamal Mazrui" <empower@xxxxxxxxx>
To: <programmingblind@xxxxxxxxxxxxx>
Sent: Sunday, November 18, 2007 8:14 PM
Subject: Fruit basket program in C++/CLI


> From the archive at
> http://www.EmpowermentZone.com/cli_fruit.zip
>
> This fruit basket program is written in C++/CLI:  the C++ language with
> extensions to support the Common Language Infrastructure of the .NET
> Framework.  C++/CLI can create native Win32 executables or libraries,
> .NET-based ones, or a combination of both.  Related development resources
> that are freely available from Microsoft.com include the following:  the
> .NET Framework 2.0 SDK, the Microsoft Platform SDK for Windows Server
> 2003, and Visual C++ 2005 Express Edition.
>
> The archive includes a batch file, compile.bat, which invokes the
> command-line compiler to create an executable, cli_fruit.exe, which is
> about 5K in size.  The batch file initially sets environmental variables
> that may need to be tweaked on another computer so that appropriate
> directories are referenced.
>
> Besides the resulting executable, No other files are needed to run the
> program -- as long as .NET 2.0 is installed.   The included Source code is
> also pasted below.
>
> Jamal
>
> /*;
> content of cli_fruit.cpp;
> Fruit Basket program in C++/CLI
> //public domain by Jamal Mazrui
> */;
>
> // Reference libraries
> #using <System.dll>
> #using <System.Windows.Forms.dll>
>
> // Import namespaces
> using namespace System;
> using namespace System::Windows::Forms;
>
> // Define class
> ref class FruitBasket : public Form {
> public :
> //Define constructor
> FruitBasket() {
> // Initialize controls and set properties
> tlp = gcnew TableLayoutPanel();
> tlp->ColumnCount = 3;
> tlp->RowCount = 2;
>
> lblFruit = gcnew Label();
> lblFruit->Text = "&Fruit:";
> tlp->Controls->Add(lblFruit);
>
> txtFruit = gcnew TextBox();
> tlp->Controls->Add(txtFruit);
>
> btnAdd = gcnew Button();
> btnAdd->Text = "&Add";
> btnAdd->Click += gcnew EventHandler(this, &FruitBasket::Button_Click);
> tlp->Controls->Add(btnAdd);
>
> lblBasket = gcnew Label();
> lblBasket->Text = "&Basket:";
> tlp->Controls->Add(lblBasket);
>
> lstBasket = gcnew ListBox();
> tlp->Controls->Add(lstBasket);
>
> btnDelete = gcnew Button();
> btnDelete->Text = "&Delete";
> btnDelete->Click += gcnew EventHandler(this, &FruitBasket::Button_Click);
> tlp->Controls->Add(btnDelete);
>
> Text = "Fruit Basket";
> AcceptButton = btnAdd;
> StartPosition = FormStartPosition::CenterScreen;
> AutoSize = true;
> AutoSizeMode = System::Windows::Forms::AutoSizeMode::GrowAndShrink;
> Controls->Add(tlp);
> } // FruitBasket constructor
>
> // Define destructor
> virtual ~FruitBasket() {
> } // FruitBasket destructor
>
> // Define event handler;
> void Button_Click(Object^ sender, EventArgs^ e) {
> if (sender == btnAdd) {
> String^ sFruit = txtFruit->Text->Trim();
> if (sFruit->Length == 0) {
> MessageBox::Show("No fruit to add!", "Alert");
> return;
> }
>
> lstBasket->Items->Add(sFruit);
> txtFruit->Clear();
> lstBasket->SelectedIndex = lstBasket->Items->Count - 1;
> }
> else if (sender == btnDelete) {
> int iFruit = lstBasket->SelectedIndex;
> if (iFruit == -1) {
> MessageBox::Show("No fruit to delete->", "Alert");
> return;
> }
>
> lstBasket->Items->RemoveAt(iFruit);
> if (iFruit == lstBasket->Items->Count) iFruit--;
> lstBasket->SelectedIndex = iFruit;
> }
> } // Button_Click event handler
>
> // Declare controls;
> TableLayoutPanel^ tlp;
> Label^ lblFruit;
> TextBox^ txtFruit;
> Button^ btnAdd;
> Label^ lblBasket;
> ListBox^ lstBasket;
> Button^ btnDelete;
> }; // FruitBasket class
>
> // Define entry point of program
> int main() {
> Application::Run(gcnew FruitBasket());
> return 0;
> } // main method
>
> // End of cli_fruit.cpp
>
> __________
> View the list's information and change your settings at
> //www.freelists.org/list/programmingblind
>

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: