Share via


Adding Resources to a Control Panel Application (Windows Embedded CE 6.0)

1/6/2010

To compile the code described in Creating a Control Panel Application, you must replicate the string and icon resources of the HelloWorld application in your control panel application. To do this, add the following to your project:

  • Three string resources, IDS_APP_TITLE, IDS_HELLO and IDC_HelloWorld.
  • An icon resource, IDI_HELLOWORLD.

Note that these string and icon resource names should be the same as the resources for the HelloWorld application.

The following steps describe how to create a resource file and add resources to it.

To add a resource file to your HelloCPL project

  1. In the Solution Explorer window, expand Subprojects, and then choose the node for your HelloCPL project.

  2. Right-click the node, choose Add, and then choose Add item.

    The Add New Item dialog box appears.

  3. Choose the Resource, and then choose Resource File (.rc).

  4. In the Name box, type the name HelloCPL for your project's new resource file. Choose Add.

    Your resource file opens in a new window.

  5. Close the HelloCPL.rc window.

With the resource file created, you next add a string table resource and an icon resource to it. The string table contains the displayed text for your Control Panel application, and the icon represents your application in Control Panel.

To add a string table to your resource file

  1. In the Solution Explorer window, expand Subprojects, expand the node for your HelloCPL project, and navigate to HelloCPL.rc.

  2. Double-click HelloCPL.rc.

  3. In Resource View, right-click HelloCTL.rc, and choose Add Resource.

    The Add Resource dialog box appears.

  4. In the Add Resource dialog box, choose String Table and choose New.

    The String Table window opens.

  5. Double-click a blank line in the String Table window.

    The String Editor property page appears in the Properties window.

    The value in the ID box in the String Editor property page should be highlighted.

  6. Create the IDS_APP_TITLE resource identifier by replacing the highlighted value in the String Editor property page with the string IDS_APP_TITLE.

  7. In the Caption box, type the string Hello Control Panel and press the RETURN key to close the property page and to save the value.

  8. To add the resource identifiers IDS_HELLO andIDC_HelloWorld, repeat steps 4 through 6, and assign to it the value A sample Control Panel application.

  9. Close the String Table window.

The Windows Embedded CE Subproject Wizard does not automatically create an icon for DLL projects. You must provide an icon for HelloCPL so it can be represented in Control Panel.

The following steps describe how to use the icon that the Windows Embedded CE Subproject Wizard created for HelloWorld.exe in Creating a Hello World Application as the icon for HelloCPL.

To import an icon into your resources

  1. In the Solution Explorer window, expand Subprojects, expand the node for your HelloCPL project, and navigate to HelloCPL.rc.

  2. Double-click HelloCPL.rc.

  3. In Resource View, right-click HelloCTL.rc, and choose Add Resource.

    The Add Resource dialog box appears.

  4. In the Add Resource dialog box, choose Icon and choose Import.

  5. The Import dialog box appears and displays your project directory.

  6. Open the directory for your Hello World application.

  7. Choose the icon (.ico) file for your HelloWorld.exe, and choose Open.

    The Icon window opens.

    You can close the window to proceed with the default icon, or you can customize the icon with the available tools prior to closing the window.

    On the ResourceView tab, you should see a resource identifier for your icon in the Icon folder.

  8. Choose the resource identifier for your icon and view the Properties window.

  9. Change the resource identifier for your icon to IDI_HELLOWORLD and press RETURN to close the property page.

Platform Builder processes the resource identifiers and creates a file in your project directory called Resources.h at compile time.

Your HelloCPL.cpp file already contains the preprocessor directive #include "resource.h" to compile these identifiers into your code.

Although your code for HelloCPL compiles with your project and your files in this case, the Resource.h file is not actually in your HelloCPL project; it does not appear in the Header Files folder for your HelloCPL project in the IDE.

To make your project easier to understand in the IDE and more maintainable, manually add Resource.h to your HelloCPL project.

See Also

Concepts

How to Implement a Control Panel Application