Return to Index
created by gbSnippets
'A resource file contains text and binary information (icons, bitmaps, sounds, ...)
'which may be used by an application. To create a resource file (*.pbr), a
'resource script (text file) is created which lists what is to be included in
'the resource file. The resource script file is then compiled using a special resource
'compiler that ships with PowerBASIC. The PowerBASIC IDE can be used to edit
'the resource script file, and can call the resource compiler to create the *.pbr file.
'More information on resource files can be found at MSDN,
'Including the following line in the source code listing will direct the PowerBASIC
'compiler to embed the resource file (*.pbr) into the EXE.
'With the resource file embedded within the EXE, the application can access the
'various text/binary elements within the resource file.
'Here's a list of the resource types supported by the resource compiler - just
'those most likely to be used by a PowerBASIC programmer.
Bitmap Defines a Bitmap by naming it AND specifying the Name of the file that contains it. (To use a particular Bitmap, the application requests it by Name.)
CURSOR Defines a cursor Or animated cursor by naming it AND specifying the Name of the file that contains it. (To use a particular cursor, the application requests it by Name.)
Font Specifies the Name of a file that contains a Font.
HTML Specifies an HTML file.
Icon Defines an Icon Or animated Icon by naming it AND specifying the Name of the file that contains it. (To use a particular Icon, the application requests it by Name.)
RCDATA Defines Data resources. Data resources Let you include binary Data in the executable file.
STRINGTABLE Defines String resources. String resources are Unicode Or ASCII strings that can be loaded From the executable file.
User-Defined Defines a resource that contains application-specific Data.
VERSIONINFO Defines a version-information resource. Contains information such as the version number, intended operating system, AND so On.
'A common use of a resource file is to contain a complete description of a dialog - mostly
'used by programmers in other languages to create dialogs, which form the heart of the
'PowerBASIC DDT capabilities. These additional resource types are supported by the resource
'compiler but are not typically used by PowerBASIC programmers. See MSDn
ACCELERATORS Defines Menu accelerator keys.
Dialog Defines a template that an application can use to Create Dialog boxes.
DIALOGEX Defines a template that an application can use to Create Dialog boxes.
Menu Defines the appearance AND Function of a Menu.
MENUEX Defines the appearance AND Function of a Menu.
MESSAGETABLE Defines a message table by naming it AND specifying the Name of the file that contains it. The file is a binary resource file generated by the message compiler.
Popup Defines a Menu Item that can contain Menu items AND submenus.
TEXTINCLUDE A special resource that is interpreted by Visual C++. For more information, see TN035 <http://go.microsoft.com/FWLink/?LinkId=83951>.
TYPELIB A special resource that is used with the /TLBID <http://go.microsoft.com/FWLink/?LinkId=83960> AND /TLBOUT <http://go.microsoft.com/FWLink/?LinkId=83947> linker options.
'Very Simple Resource Script File
'In this first example, a very simple resource script is shown - defining
'4 icons, 2 bitmaps, 'and two sound files. These lines of text, placed in
'a *.rc text file, are all that is needed for the PowerBASIC IDE to compile
'into a *.pbr resource file.
'Follow these 3 steps:
'1 Put these lines in a file called "gbsnippets.rc" (use your own icon/bmp/wav file names)
'2 Open the file in the PowerBASIC IDE
'3 Press "Compile" to create the gbsnippets.pbr
// Comment Lines start with a double forwardslash
Add Icon "c:\myimages\add.ico"
Check Icon "c:\myimages\check.ico"
0x0001 Icon "c:\myimages\x.ico"
0x0002 Icon "y.ico"
girl Bitmap "girl.bmp"
boy Bitmap "boy.bmp"
alarm wave "alarm.wav"
Beep wave "beep.wav"
/* Block comments are also supported, starting with a forwardslash/asterisk
AND ending with an asterisk/forwardslash */
'Here's what is in the columns:
'Column 1: the identifier used in the PowerBASIC app to refer to the resource item
'Column 2: the type of resource
'Column 3: the resource path name (relative to the *.rc file name)
'The information is case-insensitive. Actual column positions are up to the user.
'Then, once the "gbsnippets.pbr" file has been created, use the #Resource
'line as in the compilable code below.
'Compilable Example: (Jose Includes)
'This example shows how to use the "#Resource" metastatement to direct the
'compiler to include a *.pbr file within the EXE.
#Compiler PBWin 9, PBWin 10
MsgBox "I have a resource file in me!"
created by gbSnippets