Home > Language Reference > Classes > ResourceDB
Resource Property
Accesses a resource in a database.
Syntax
Public Property Get Resource(ByRef sResType As String, ByVal lResID As Long) As StreamRecord
Public Property Set Resource(ByRef sResType As String, ByVal lResID As Long, ByRef objStream As StreamRecord)
| Parameter | Description |
| sResType | Resource type. |
| lResID | Resource identifier. |
Remarks
The Resource property accesses resources from a resource database.
The sResType parameter is the resource type :The resource type is a string of 4 characters (See also ResType property of the StreamRecord class).
The lResID parameter is the resource identifier : The resource identifier is a Long and distinguishes records of the same ResType (See also ResID property of StreamRecord class).
In the following example, we search for the icon (resource type 'tAIB', resource identifier 1000) of the built-in Address Book application using the Resource property.
Private Sub Button1_Click()
Dim db as new ResourceDB
Dim r as StreamRecord
Dim bm as Bitmap
'Open the Address Book resource database
db.OpenByName "Address Book",hbModeOpenExisting+hbModeReadOnly,"appl"
'Search the tAIB resource, id=1000
Set r=db.Resource("tAIB",1000)
'if Found, Create a bitmap from the resource and display result
If not r is nothing then
Set bm=New Bitmap
bm.CreateFromResource r
Me.CopyArea 20,20,bm.Width,bm.Height,bm,0,0
End if
End SubNote: In the case of a database opened in read only mode, the Resource property manages automatically the localisation database (overlay). However, if the database is opened in read / write mode, the Resource property will only manage the open database.
One particularity with the application database (see App global variable) is that it is possible to access its system resources using the Resource method. The Resource method of the global instance App affects all the open resource databases. For example, to retrieve the default icon for an application, the following code is required:
Private Sub Button1_Click()
Dim r as StreamRecord
Dim bm as Bitmap
'Retrieve the default icon from
' the system. We use the App object to ensure that
' all the open databases are searched.
Set r=App.Resource("tAIB",10000)
If r Is Nothing Then Exit Sub
' Create a bitmap from the resource
' and display the result
Set bm=New Bitmap
bm.CreateFromResource r
Me.CopyArea 50,50,bm.Width,bm.Height,bm,0,0
End Sub
System requirements
| System | Minimal version | Remarks |
| Palm OS | Palm OS 3.0 | N/A |