Resource File Contents and Structure
Resource files create and define resources for use in Visual PRO/5 applications, and contain the following:
-
Version Number - The version of the text in the resource file. The current version is 4.x.
-
Mandatory Resource Properties - The attributes of a resource that are required.
-
Optional Resource Properties - The attributes of a resource that are not mandatory but enhance functionality and appearance.
-
Comments - Remarks contained in the resource file that make it easier to review and debug the code.
Resource File Example
The following resource file defines a window that contains two edit controls. The first line contains the version indicator, followed by definitions of the window and edit controls and comments. While the window and first edit control contain only the mandatory definitions, the second edit control contains optional settings.
VERSION "4.01"
WINDOW 1 "Status" 0 0 200 100
BEGIN
EDIT 1, "OK", 10, 10, 50, 25
BEGIN
END
EDIT 2, "Done", 50, 10, 50, 25
BEGIN
BACKGROUNDCOLOR RGB(64,128,64)
CLIENTEDGE
DISABLED
FONT "Arial" 12, bold, CS_DEFAULT
FOREGROUNDCOLOR RGB(128,255,128)
INITIALCONTENTS "Figures"
PASSHOMEDEL
PASSWORDENTRY
RAISEDEDGE
INVISIBLE
END
END
Version Number
The first line of a resource file must contain the version number of the content. At the time of publication, the current version is 4.x.
Mandatory Resource Properties
Resource files can contain definitions for both mandatory and optional properties. The mandatory properties, for example, resource type, ID number, title, and position, are defined on the first line pertaining to the resource. The following lists the mandatory properties of the window and two edit controls:
Window 1 "Status" 0 0 200 100
Edit 1 "OK" 10 10 50 25
Edit 2 "Done" 50 10 50 25
The following describes the properties listed in the previous example:
Property |
Resource |
Entry |
Description |
resource |
Window First edit control Second edit control |
Window Edit Edit |
Identifies each resource, in this case one window and two edit controls. |
resource-id |
Window |
1 |
Unique resource ID number that identifies the window in the resource file. It must be an integer between 1 and 32767. |
control-id |
First edit control Second edit control |
1 2 |
Control ID number. It must be an integer between 1 and 32767. |
"title" |
Window First edit control Second edit control |
"Status" "OK" "Done" |
Resource title, contained in quotation marks. |
x |
Window First edit control Second edit control |
0 10 50 |
Horizontal position of the upper-left corner of the resource in current units. |
y |
Window First edit control Second edit control |
0 10 10 |
Vertical position of the upper-left corner of the resource in current units. |
width |
Window First edit control Second edit control |
200 50 50 |
Width of the resource in current units. |
height |
Window First edit control Second edit control |
100 25 25 |
Height of the resource in current units. |
Optional Resource Properties
The second and following lines of information pertaining to a resource define its optional properties, for example, color, text justification, and borders. The following lists the optional properties for the example's second edit control:
Name |
Description |
Type |
Default Setting |
Backgroundcolor |
Sets the background color of the edit control. |
Color |
System default |
Clientedge |
Creates a recessed client edge around the edit control. |
Flag |
False |
Disabled |
Sets the edit control to be initially disabled. |
Flag |
False |
Font |
Sets the font of the edit control. |
Font |
Windows default |
Foregroundcolor |
Sets the foreground color of the edit control. |
Color |
System default |
Initialcontents |
Sets the initial contents of the edit control. |
String |
Null |
Invisible |
Sets the edit control to be initially invisible. |
Flag |
False |
Passhomedel |
Passes the <Home> and <Delete> keys as Keypress Notify events. |
Flag |
False |
Raisededge |
Creates a raised client edge around the edit control. |
Flag |
False |
The Resource Properties Index identifies and describes all optional properties for each resource.
Comments
ResCompiler ignores all text that follows two forward-slash [//] characters. Comments can be placed alone either on a line or at the end of a line of code. The following lists the use of comments in the example. The first line contains only comments, while the second line contains code followed by comments.
// The second edit control contains optional settings
Initialcontents "Figures" //Default Contents
Resource File Structure
Resource file contents are hierarchically structured, as illustrated in the following example. Top level resources include windows, referenced menus, and referenced child windows. Lower level resources are nested within top-level resources. Nesting levels are defined by either "BEGIN" and "END" or by "{" and "}". Indentation using white space is encouraged for readability but is not required.
VERSION "4.01"
WINDOW 1 "Status" 0 0 200 100 //This is a top level resource.
BEGIN
EDIT 1, "OK", 10, 10, 50, 25 //This is a lower level resource.
BEGIN
END
EDIT 2, "Done", 106, 10, 50, 25
BEGIN //This is a lower level resource.
BACKGROUNDCOLOR RGB(64,128,64)
CLIENTEDGE
DISABLED
FONT "Arial" 12, bold, CS_DEFAULT
FOREGROUNDCOLOR RGB(128,255,128)
INITIALCONTENTS "Figures" //Default Contents
PASSHOMEDEL
PASSWORDENTRY
RAISEDEDGE
INVISIBLE
END