Try OpenEdge Now
skip to main content
GUI for .NET Programming
Creating and Using Forms and Controls : ABL support for managing .NET forms and controls : Accessing resource files for .NET forms
 

Accessing resource files for .NET forms

.NET supports a file type for storing resources, such as graphics and images, that a form uses. These resource files are XML files with the .resx filename extension. In .NET, you typically create one resource file for a given form class and give it a filename that is the same as the name of the given form class, and store it with the source file for the class. In ABL, you might give it the same filename as an ABL-derived .NET form class for which the resources are designed, and store it with the ABL class file. The Visual Designer in Progress Developer Studio for OpenEdge automatically creates this file for any ABL-derived form to which you add resources. For more information on creating such resource files yourself, see the MSDN documentation at the following location:
In order to retrieve resources from a given resource file, OpenEdge provides the .NET Progress.Util.ResourceHelper class. This class provides a single Load( ) method that allows you to retrieve the complete set of resources from a resource file. To call the method, you specify two INPUT parameters as CHARACTER expressions:
*A pathname that includes the filename (and extension) of the resource file. This can be an absolute or relative path, depending on the second parameter.
*Either a non-empty comma-separated list of pathnames (typically PROPATH) or an empty string (""). If it is non-empty, the first parameter must specify a file relative to a path on the list. Otherwise, the first parameter must specify a file either as an absolute pathname or as a pathname relative to the current working directory.
The Load( ) method returns an object reference to a System.Resources.ResXResourceSet. This is a .NET Framework object that stores the resources of a resource file as objects that you can access by name. This class provides a GetObject( ) method that you can use to return a specific resource object given its name.
The following code fragment loads a resource file, form1.resx, from PROPATH into a resources object (rResources). It then returns an image object named "open.Image" from rResources using the GetObject( ) method:
DEFINE VARIABLE rResources AS System.Resources.ResXResourceSet NO-UNDO.
DEFINE VARIABLE rImage AS System.Drawing.Image NO-UNDO.

rResources = Progress.Util.ResourceHelper:Load( INPUT "form1.resx",
                                                INPUT PROPATH ).
rImage = CAST( rResources:GetObject("open.Image"), System.Drawing.Image ).
For more information on the System.Resources.ResXResourceSet class, see the .NET Framework Class Library documentation referenced by Microsoft.NET UI Controls.