Resources in Jabaco

This tutorial is about how to work with resources in Jabaco.



let's start:

select the files you want to integrate in your project:

in Jabaco right click on the project-explorer select the menu item "Add File..." or click the button "Add File...". From the drop-down menu select the menu item "Resource". An openfiledialog appears where you can select your files.

After selecting a file, Jabaco does the following things for you:

  • the files immediately will be copied to a new sub direcotry named "Res" below your jabaco-project folder
  • for each file an object of type IResource will be created that can be accessed through the static object "Resources" with a dynamically created property with the name of your file
  • the name will be simplyfied a little bit, points and other non alphanum-characters will be eliminated, just to create a valid property name.

Picture Resources (pixel based)

I also have bad news: I made bad experiences with pictures of type

  • .bmp (windows-bitmaps) and
  • .ico (windows-icons)

i did not get them to work. maybe because they are not supported under linux. But don't bother you

  • .png-, *.jpg- and *.gif-files work fine.

imho, the winner of all type of pictures is the png-format

Property Editor

For a PictureBox control and everywhere where you have a Picture property, you simply can select the image you like in the Property-editor.

Source Code

To assign a picture in your sourcecode where it suits for your needs you can use the dynamically created property of the static Resources object (as mentioned above).

code example:

Picture1.Picture = Resources.MyPicPng


The CommandButton has a Picture-property. You can select an image for it, and in the Jabaco-IDE you are able to see the picture on the button. But styled buttons in windows are not capable of holding a picture on it. So this does not work under WinXP with styled themes.

Wave Audio Resources

in VB6 you know the function LoadResData that returns an Array of Bytes and you can use it there like this:

Private m_Wave() As Byte
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" ( _
    ByRef lpSound As Byte, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Const SND_MEMORY As Long = &H4
Private Sub Form_Load()
'Function LoadResData(id, type)
'  Member of VB.Global
'  Loads data from different possible kind of data from a 
'  Ressource file (.RES) and returns a Byte-Array.
'Type: "WAVE", id: 101
   m_Wave = LoadResData(101, "WAVE")
End Sub
Private Sub Command1_Click()
    PlaySound m_Wave(0), 0, SND_MEMORY
End Sub

in Jabaco afair, there is no LoadResData-function but it simply can be written like this:

Public Function LoadResData(resID As IResource) As InputStream
   Set LoadResData = getClass.getResourceAsStream(resID)
End Function

we can combine it with something like this:

Public Function GetWavResClip(ResID As IResource) As Clip
   GetWavResClip = AudioSystem.getClip
End Function

we can play it with:

Private Sub CmdPlay_Click()
   Dim clip1 As Clip = GetWavResClip(Resources.ChimesWav)
   Dim clip2 As Clip = GetWavResClip(Resources.TadaWav)
End Sub

Of course the two sounds will be played mixed together in one.

Retrieved from ""

This page has been accessed 4,079 times. This page was last modified on 17 May 2009, at 21:55.

This page has been accessed 4,079 times. This page was last modified on 17 May 2009, at 21:55.