A Simple Hello World Program (Windows Forms Application-Microsoft Visual C++ 2008 Express Edition)

From the name itself, a windows forms application is local-based application that uses a graphical user interface similar to windows. The following steps show you how to create a windows forms application and display a "Hello world!" text in it:

1. Start MSVC++ Express 2008 by clicking on the Start button, All Programs then clicking on the Microsoft Visual C++ Express Edition Start menu option.

2. Click File>New>Project. The new project dialog box will then come into view.

3. Select Windows Forms Application from the Visual Studio Installed templates, type the project name>Click Ok.
After clicking the Ok button, an IDE suited for windows forms application will then appear containing a form, a toolbox window, and a properties window.

4. Select your form by clicking its title bar. In the properties window, locate the Name property then assign “NameForm” as its value. In similar manner, locate the Text property then assign “Display Hello World” as its value. Both values should be entered without quotation marks.


5. In the toolbox window, Select the label tool then click and drag it into an area in your form where you wanted to appear your “Hello world!” text.

6. Select your label, in the properties window, locate the Name property then assign “HelloLabel” as its value. In the same manner, locate the Text property then assign “Hello world!” as its value. Both values should be typed without quotation marks.

7. Press F5 to execute your application. If all went well, you should now see you windows form application with a "Hello world!" text displayed in it.

Changing the value of a control property through codes (Windows Forms Application-Microsoft Visual C++ 2008 Express Edition)

In case you might not notice, Visual Programming otherwise known as Object-Oriented programming revolves around changing the values of a property of an object through codes. To change the value of a control property using codes in Visual C++ Express Edition, use the following syntax:

//enclosed the value in a quotation mark 
//if the value of a property is a string
this->ControlName->Property=”value”; 
//do not add quotation marks
//if the value of the property is Boolean or Number
this->ControlName->Property=value;

The following steps illustrate a sample application of this syntax:

1. Start MSVC++ Express 2008 by clicking on the Start button, All Programs then clicking on the Microsoft Visual C++ Express Edition Start menu option.

2. Click File>New>Project. The new project dialog box will then come into view.

3. Select Windows Forms Application from the Visual Studio Installed templates, type the project name>Click Ok.
After clicking the Ok button, an IDE suited for windows forms application will then appear containing a form, a toolbox window, and a properties window.

4. Design your interface similar to the one shown below:



Note: Those texts that appear beside each control are the suggested names for our form controls in this example. If you notice I am using .Net naming convention in naming controls because it is simpler to use than Leszynski naming convention. To change the value of the name property of each control, just click each individual control then locate the name property in the properties window then assign those descriptive names in our illustration correspondingly.


5. Double-click the control named FnameButton, then enter:

//this will assign John as an FnameLabel text
this->FnameLabel->Text=”John”; 

Your code will now look like this:

private: System::Void FnameButton_Click(System::Object^  sender, System::EventArgs^  e) {
this->FnameLabel->Text=”John”;
}

6. Double-click LnameButton, the following should then the following between the open and close curly brackets:

//this will assign John as an FnameLabel text
this->LnameLabel->Text=”Doe”; 


Your code will now look like this:


private: System::Void LnameButton_Click(System::Object^  sender, System::EventArgs^  e) {
this->LnameLabel->Text=”Doe”;
}

7. Double-click the control named ExitButton, then type this->Close(); between the open and curly brackets. The Close() method terminates the current form.

Your code will now look like this::


private: System::Void ExitButton_Click(System::Object^  sender, System::EventArgs^  e) {
this->Close();
}

8. Press F5 to run your application. If all went well, you will see our sample application instantly without build erros.