Microsoft KB Archive/268166

= How To Create Resource Files and Use Them in eMbedded Visual Basic =

Article ID: 268166

Article Last Modified on 7/1/2004

-

APPLIES TO


 * Microsoft eMbedded Visual Basic 3.0

-



This article was previously published under Q268166



SUMMARY
This article describes how to use eMbedded Visual C++ (eVC) to create a resource file that you can use in eMbedded Visual Basic (eVB) 3.0. This procedure is divided into the following sections:


 * 1) Create a resource file in eVC.Compile the resource file in eVC.Add the resource file to your eVB project.Write code to load the strings from the resource file.
 * 2) Compile the resource file in eVC.Add the resource file to your eVB project.Write code to load the strings from the resource file.
 * 3) Add the resource file to your eVB project.Write code to load the strings from the resource file.
 * 4) Write code to load the strings from the resource file.



How to Create a Resource File

 * 1) In eMbedded Visual C++, from the File menu, click New.
 * 2) In the New dialog box, on the Files tab, click Resource Script.
 * 3) Type the file name MyRes . If you receive a warning that resource.h is being used by MyRes.rc, click Yes to overwrite the existing file.
 * 4) From the Insert menu, click Resource.
 * 5) In the Insert Resource dialog box, click String Table, and then click New.
 * 6) From the Insert menu, click New String.
 * 7) In the String Properties dialog box, change the ID from IDS_STRING1 to 101 . You must type a value that is larger than 1, otherwise your resource will not be readable from eVB.
 * 8) In the Caption text box, type This is test item 1, and then press ENTER.
 * 9) From the Insert menu, click New String to add another string to the string table. In the String Properties dialog box, change the existing ID to 102.
 * 10) In the Caption text box, type This is test item 2, and then press ENTER.
 * 11) Save the file as MyRes.rc.

How to Compile the .rc File to Make a .res File
To compile the newly created .rc file into a .res file, use the Rc.exe compiler.

At a command prompt, type the following command:

:\Program Files\Microsoft eMbedded Tools\Common\EVC\Bin\rc.exe \MyRes.rc

How to Add the Resource File to Your eVB Project

 * 1) Create an eVB project for the Pocket PC. You can also use HPC Pro or Palm Size projects. Form1 is created by default.
 * 2) From the Project menu, click Add File.
 * 3) Do not select the Add as Related Document check box. eVB automatically adds the .res file as a related document.
 * 4) Double-click MyRes.res. The file is added in the project explorer under Related Documents.

How to Write Code to Load the String from the Resource File
 Add a command button to Form1.  Paste the following code in the click event of Form1: MsgBox LoadResString(101) MsgBox LoadResString(102)  Run the project on the device, and click the command button. Both strings are displayed in message boxes, one at a time.

Keywords: kbhowto KB268166

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.