Compartilhar via


Adding Resources to a Control Panel Application (Windows CE 5.0)

Send Feedback

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 Workspace view, choose the FileView tab.

  2. From the File menu, choose New Project or File.

    The New Project or File dialog box appears.

  3. In the New Project or File dialog box, choose the Files tab and then choose Resource Script.

  4. In the File name field, type the name HelloCPL for your project's new resource file. Ensure that the Add to project checkbox is highlighted and that you have choosen HelloCPL in the textbox that follows the checkbox, and choose OK.

    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 Workspace view, choose the ResourceView tab, and select HelloCPL resources.

  2. From the Project menu, choose Insert and then choose Resource.

    The Insert Resource dialog box appears.

  3. In the Insert Resource dialog box, choose String Table and choose New.

    The String Table window opens.

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

    The String Properties dialog box appears.

    The value in the ID box in the String Properties dialog box should be highlighted.

  5. Create the IDS_APP_TITLE resource identifier by replacing the highlighted value in the String Properties dialog box with the string IDS_APP_TITLE.

  6. In the Caption box, type the string Hello Control Panel and press the RETURN key to close the dialog box and save the value.

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

  8. Close the String Table window.

The New Project 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 New Project 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 Workspace view, choose the ResourceView tab.

  2. On the ResourceView tab, right-click HelloCPL resources and choose Import.

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

  3. Open the directory for your Hello World application.

  4. Select the icon (.ico) file for your HelloWorld.exe and choose Import.

    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.

  5. Right-click the resource identifier for your icon and choose Properties.

    The Properties dialog box appears.

  6. Change the resource identifier for your icon to IDI_HELLOWORLD and press RETURN to close the dialog box.

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

How to Implement a Control Panel Application

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.