This documentation is archived and is not being maintained.

BirthdayPicker Sample: Demonstrates Using .NET Framework Resources with Windows Forms

Visual Studio .NET 2003

The BirthdayPicker sample shows how the .NET Framework resource mechanism works for Managed Extensions for C++ applications. It also shows usage of common Window Forms components in a managed application.

Building and Running the Sample

To take advantage of .NET Framework resources, Managed Extensions for C++ applications can use the .NET Framework tool WinRes.exe. This tool is specialized in creating ".resx" files (the equivalent of ".rc" files in Win32 C++ applications). Birthdaypicker.resx contains the imageList1 resource along with the collection of bitmaps it handles. The resultant .resx file is then compiled by resgen.exe into the file birthdaypicker.resources, which is then linked into the resulting assembly of the application.

To build and run BirthdayPicker using Visual Studio

  1. In the Visual Studio IDE, load the solution file BirthdayPicker.sln.
  2. In Solution Explorer, right-click the BirthdayPicker solution.
  3. On the Debug menu, click Start.

    Observe the Custom build step, running resgen.exe on birthdaypicker.resx and generating the resource file for the application. In addition, note the linker option /assemblyresource, used to link the resulting birthdaypicker.resources to the application.

  4. On the Debug menu, click Start.

Once the sample is running, two DateTimePicker controls are displayed. Select your birthday using the first control and an arbitrary date (such as today) with the second control. Once the date range has been selected, the linked tree control is propagated with multiple nodes interpreting the timespan in different ways. For example, the number of years or days elapsed, the equivalent in dog years or in fruit fly generations, and how many full moons have passed in this time interval.

Classes and Keywords

This sample demonstrates the following classes:

DateTimePicker; ImageList; ResourceManager; TreeView

This sample demonstrates the following keywords:

ResourceManager::GetObject; DateTimePicker::Format; TimeSpan; KeyPressEventHandler; ToolTip::SetToolTip; ContextMenu; TreeView::Nodes; TreeView::SelectedNode; TreeNode::GetNodeCount; TreeNode::Remove; TreeNodeCollection::Insert; TreeNodeCollection::Clear; String::Format; Panel; dynamic_cast

See Also

Managed Extensions for C++ Samples

Show: