Natural for Windows Version 8.3.7 for Windows
 —  Programming Guide  —

Resource

This section describes the Natural object of type resource.

This document covers the following topics:


Use of Resources

Natural distinguishes two kinds of resources:

Both shared and private resources belonging to a Natural library are maintained in a subdirectory named ..\RES in the directory that represents the Natural library in the file system.

Top of page

Shared Resources

A shared resource is any non-Natural file that is used in a Natural application and is maintained in the Natural library system. A non-Natural file that is to be used as a shared resource must be contained in the subdirectory named ..\RES of a Natural library.

Example of Using a Shared Resource

The bitmap MYPICTURE.BMP is to be displayed in a bitmap control in a dialog MYDLG, contained in a library MYLIB. First the bitmap is put into the Natural library MYLIB by moving it into the directory ..\MYLIB\RES. The following code snippet from the dialog MYDLG shows how it is then assigned to the bitmap control:

DEFINE DATA LOCAL
01 #BM-1 HANDLE OF BITMAP 
... 
END-DEFINE 
* (Creation of the Bitmap control omitted.) 
... 
#BM-1.BITMAP-FILE-NAME := "MYPICTURE.BMP" ... 

The advantages of using the bitmap as a shared resource are:

Note:
In previous Natural versions non-Natural files were usually kept  in a directory that was defined with the environment variable NATGUI_BMP. Existing applications that use this approach will work in the same way as before, because Natural always searches for a shared resource file in this directory, if it was not found in the current library.

Top of page

Private Resources

Private resources are used internally by Natural to store binary data that is part of Natural objects. These files are recognized by the file name extension NR*, where * is a character that depends on the type of the Natural object. Natural maintains private resource files and their contents automatically. A Natural object can have a maximum of one private resource file.

Currently, only Natural dialogs have a private resource file. This file is used to store the configuration of ActiveX controls that are defined in a dialog and are configured with their own property pages.

For information on how to configure an ActiveX control, see Attributes Windows for Dialogs and Dialog Elements, ActiveX Control Property Pages.

Example of Private Resources

The name of the private resource file of the dialog MYDLG is MYDLG.NR3.

Natural creates, modifies and deletes this file automatically as needed, when the dialog is created, modified, deleted, etc.

The private resource file is used to store binary data related to the dialog MYDLG.

Top of page

API for Processing Resources

In the library SYSEXT, the following application programming interface (API) exists, which gives user applications access to resources' unique user exit routines:

API Purpose
USR4208N Write, read, delete a resource by using short or long name.

Top of page