# Calculator Sample: Windows Forms Pocket Calculator

The Calculator sample implements a simple pocket calculator using C++ and the .NET Framework Windows Forms classes. It demonstrates using .NET Framework classes to write a user-interface without the support of the resource editors, and illustrates the following concepts:

- Working with forms, menus, edit fields, buttons, and icons for forms

- Manipulating managed arrays

- Using delegates/event handlers

- Exception handling

- Using enums

- Conversions between the .NET Framework String, Double, and Char classes

Security Note
This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices.

# Building and Running the Sample

#### To build and run Calculator using Visual Studio

1. In the Visual Studio IDE, load the solution file calc.sln.

2. In Solution Explorer, right-click the Calc solution.

3. On the shortcut menu, click Build.

   Note
   Since this program does not compile the icon file (calc.ico) into a XML-based resource file (*.resx), you must copy the icon file into the same directory as the .exe (built from the sample) before continuing.

4. Run the resulting application and try out various operations with the calculator.

# Classes and Keywords

This sample demonstrates the following classes:

Form; TextBox; Button; Icon; MainMenu; MenuItem; MessageBox; Exception; FileNotFoundException; Size structure; Font

This sample demonstrates the following keywords:

__gc; __value; enum; add_KeyPress; KeyPressEventHandler; EventHandler; __try_cast; EventArgs; KeyPressEventArgs; FormStartPosition; FormBorderStyle; SizeGripStyle; BorderStyle; SystemColors; HorizontalAlignment; FlatStyle; add_Click