Creating the .NET Resource File


Before you can use the ResEditor utility, you have to build the executable from the C# source files. The utility is located in the .NET Framework SDK tutorials folder in the resourcesandlocalization\reseditor directory. You can use the supplied batch (.bat) file to build the application.

During this hour you're going to create a managed C++ project using a single Windows Form and two controls a Label control and a PictureBox control. To begin, open the ResEditor utility. At the bottom of the dialog, select System.String under the Add group box and type in a value of IDS_HELLO in the edit box next to it. To add the string, click the Add button. This adds the string ID to the resource file, but you still have to set the actual string data. Click the IDS_HELLO item you just added and enter the string you want to use for your application.

The next step is to create and add an image to the resource file. Create a bitmap file of any color depth and size before you begin this step. Using the same procedure as before, select System.Drawing.Bitmap from the Add group box and give it the ID IDB_PICTURE. Click the IDB_PICTURE item you just added. This time you should see a small browse button where the data should go. Click this button and browse to the bitmap item you just created. Your results should look similar to Figure 8.1.

Figure 8.1. Creating .NET managed resources using ResEditor.


To create the .resx file, click File, Save As on the menu bar. The default file format to save as is a .resources file. A .resources file is a binary format that is embedded within an assembly during the linking step of the build process. If you save in this format, you will not be able to open the file in an editor and make any changes. Therefore, set the file format to .resx by changing the Save As Type group box. Save the file to the location where you plan on creating your project.


Sams Teach Yourself Visual C++. NET in 24 Hours
Sams Teach Yourself Visual C++.NET in 24 Hours
ISBN: 0672323230
EAN: 2147483647
Year: 2002
Pages: 237

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: