Calculator Sample: Windows Forms Pocket Calculator
The Calculator sample implements a simple pocket calculator using Managed Extensions for C++ and the .NET Framework Windows Forms classes. It demonstrates the use of the .NET Framework classes to write a user interface without the support of the resource editors. It illustrates the following concepts about Managed Extensions and Windows Forms programming:
- 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
Building and Running the Sample
To build and run Calculator using Visual Studio
- In the Visual Studio IDE, load the solution file calc.sln.
- In Solution Explorer, right-click the Calc solution.
- 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.
- 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