Sunday, December 18, 2011

1-Tutorial 1 : Simple Intro on Setting up a Project and Using Basic Controls in Visual C++.NET 2010, 2008

Tutorial 1 : Simple Intro on Setting up a Project and Using Basic Controls in Visual C++.NET 2010, 2008
        This project will create a simple VB like interface using Windows C++ application in Microsoft Studio.NET 2008 which  transfers text from a TextBox to a Label at the click of a button.  Click here for the source code to the Click Me Program in Visual C++.NET for the 2010 version or here for the 2008 version. First set up the project by going to:
       File > New > Project  > Visual C++ Projects  > Windows Forms Application
       Then click browse and navigate to the folder to where you want to put your application and then click OK.  Name your project something simple like myInterface.  Go to the toolbox and add a button, a textbox and a label to your form, and make your form look something like this: 
Basic Controls in a Visual C++ Application
        To Change the caption on the button click on the button, and go to the buttons Property Window and select caption and type “Press Me”.   Click on the label, go to autosize under properties and set autosize to false. Still with the the label selected, set the borderstyle property to fixed3D. Go to text property for for the label remove all the text. Next double click on the button which will bring up the code window.     Add the one line of code between the brace below to the buton1_Click function:
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
       {
         label1->Text=textBox1->Text;
       }
        Notice the code you add is almost identical to what would be added in Studio.NET Visual Basic, except an arrow is used instead of  a period and the usual C++ semicolon and braces.

1 comments:

Teknik Informatika said...

What are the basic controls recommended to be added to the form in the Visual C++ application, and what is their intended functionality?
Regard Telkom University

Post a Comment