Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Calculator Sample: Windows Forms Pocket Calculator

Visual Studio .NET 2003

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

  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

See Also

Managed Extensions for C++ Samples

© 2015 Microsoft