This documentation is archived and is not being maintained.

BirthdayPicker Sample: Demonstrates .NET Framework Resources with Windows Forms 

Download sample

The BirthdayPicker sample shows how the .NET Framework resource mechanism can be used in C++ applications. It also demonstrates some common Window Forms components.

Security noteSecurity 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. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.

Building and Running the Sample

To take advantage of .NET Framework resources, 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

Other Resources

General Samples