home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / Basic / Visual Basic.60 / COMMON / TOOLS / VB / RESOURCE / RESOURCE.TXT < prev   
Encoding:
Text File  |  1996-07-05  |  8.3 KB  |  244 lines

  1. *****************************************************************************
  2. INTRODUCTION 
  3. *****************************************************************************
  4.  
  5. This text file explains how to use the Resource Compiler (RC.EXE) to create 
  6. resource files (.RES) that can be added to your Microsoft (R) 
  7. Visual Basic (R) project.
  8.  
  9. For information on how to add the .RES file to your Visual Basic project and
  10. replace string literals and binary data in code, please search Visual Basic 
  11. Help and Books On-Line.
  12.  
  13. *****************************************************************************
  14. CONTENTS OF RESOURCE.TXT
  15. *****************************************************************************
  16.  
  17. 1. OVERVIEW
  18. 2. STRING RESOURCES
  19. 3. BINARY RESOURCES
  20. 4. RESOURCE COMPILER OPTIONS
  21.  
  22. *****************************************************************************
  23. 1. OVERVIEW
  24. *****************************************************************************
  25.  
  26. The RC.EXE file located in the \TOOLS\RESOURCE directory can be 
  27. used for 32-bit resources used in applications under Windows 95 or later and 
  28. Windows NT 3.51 or later.
  29.  
  30. The resource sample project (ATM.VBP) in the \SAMPLES\RESOURCE directory of 
  31. your Visual Basic installation demonstrates most of the functionality 
  32. described in this file. The ATM.RC file is the resource definition file used
  33. to create the .RES file for the ATM project. You won't be able to recompile
  34. the ATM.RC without removing the references to bitmaps, sound files and
  35. cursors not shipped in Visual Basic version 4.0
  36.  
  37. The Resource Compiler compiles the resource definition file and the resource
  38. files (binary files such as icon, bitmap, and cursor files) into a binary 
  39. resource (.RES) file.
  40.  
  41. Resources can be divided into two groups:
  42.  
  43. - String resources (text strings such as "Hello World").
  44. - Binary resources (icons, bitmaps, cursors, sounds, video, and so forth).
  45.  
  46. *****************************************************************************
  47. 2. STRING RESOURCES
  48. *****************************************************************************
  49.  
  50. String resources are stored in a string table in the resource definition 
  51. file.
  52.  
  53. SYNTAX:
  54.  
  55. STRINGTABLE [load-option] [mem-option]
  56. BEGIN
  57.     stringID string
  58.     .
  59.         .
  60.         .
  61. END
  62.  
  63. The STRINGTABLE statement defines one or more string resources for an
  64. application.  String resources are simply null-terminated ASCII strings that 
  65. can be loaded when needed from the executable file, using the LoadResString 
  66. function.
  67.  
  68. PARAMETERS
  69.  
  70. - load-option.  Specifies when the resource is to be loaded.  This optional 
  71. parameter must be one of the following options:
  72.   
  73. Option        Description
  74. ------        -----------
  75. PRELOAD        Resource is loaded immediately.
  76. LOADONCALL    (Default) Resource is loaded when called. 
  77.  
  78. - mem-option.  Specifies whether the resource is fixed or can be moved
  79. and whether or not can be discarded.  This optional parameter can 
  80. be one of the following options:
  81.   
  82. Option        Description
  83. ------        -----------
  84. FIXED        Resource remains at a fixed memory location.
  85. MOVEABLE    Resource can be moved if necessary in order to compact 
  86.         memory.
  87. DISCARDABLE    Resource can be discarded if no longer needed.
  88.  
  89.  
  90. - stringID.  Specifies an integer value that identifies the resource.
  91.  
  92. - string.  Specifies one or more ASCII strings, enclosed in double quotation 
  93. marks.  The string must be no longer than 255 characters and must occupy a 
  94. single line in the source file. 
  95.  
  96. Grouping strings in separate segments allows all related strings to be read 
  97. once in a single reading and discarded together.  When possible, you should 
  98. be able to move and discard the table.  The Resource Compiler allocates 
  99. 16 strings per segment and uses the identifier value to determine which
  100. segment will contain the string.  Strings with the same upper-12 bits in 
  101. their identifiers are placed in the same segment.
  102.  
  103. EXAMPLE
  104.  
  105. The following example demonstrates the STRINGTABLE statement:
  106.   
  107. #define IDS_HELLO    1
  108. #define IDS_GOODBYE  2
  109.  
  110. STRINGTABLE
  111. BEGIN
  112.     IDS_HELLO,   "Hello"
  113.     IDS_GOODBYE, "Goodbye"
  114. END 
  115.  
  116. *****************************************************************************
  117. 3. BINARY RESOURCES
  118. *****************************************************************************
  119.  
  120. Binary resources are not stored in the resource definition file.  The 
  121. resource definition file includes only a pointer to the files containing 
  122. the binary resources, for example, icon (.ICO), bitmap (.BMP), cursor (.CUR), 
  123. sound (.WAV), and video (.AVI) files.
  124.  
  125. This pointer is called a Single-Line Statement in the resource definition 
  126. file.
  127.  
  128. SYNTAX
  129.  
  130. nameID keyword [load-option] [mem-option] filename
  131.  
  132. PARAMETERES
  133.  
  134. - nameID.  Specifies either a name or an integer value identifying the
  135. resource. This ID has to be unique for every category specified by the 
  136. keyword. In the category ICON the ID 0 is reserved for the Visual Basic
  137. icon. Therefore you'll have to start ID for ICONS at 1.
  138.  
  139. - keyword.  Specifies the type of file.  The parameter must be one of the 
  140. following options:
  141.  
  142. Option        Description
  143. ------        -----------
  144. BITMAP        Defines a bitmap (.BMP)
  145. CURSOR        Defines a cursor (.CUR)
  146. ICON        Defines an icon (.ICO)
  147. SOUND        Defines a wave file (.WAV)
  148. VIDEO        Defines a video file (.AVI)
  149.  
  150.  
  151. - load-option.    Specifies when the resource is to be loaded.  The parameter 
  152. must be one of the following options:
  153.   
  154. Option        Description
  155. ------        -----------
  156. PRELOAD        Resource is loaded immediately.
  157. LOADONCALL    (Default) Resource is loaded when called. 
  158.  
  159. - mem-option.    Specifies whether the resource is fixed or can be moved and
  160. whether it can be discarded.  The parameter must be one of the following 
  161. options:
  162.   
  163. Option        Description
  164. ------        -----------
  165. FIXED        Resource remains at a fixed memory location.
  166. MOVEABLE    Resource can be moved if necessary in order to compact
  167.         memory.
  168. DISCARDABLE    Resource can be discarded if no longer needed.
  169.  
  170. The default for binary resources is MOVEABLE.
  171.  
  172. - filename.  Specifies the name of the file that contains the resource. 
  173. The name must be a valid MS-DOS (R) filename; it must be a full path 
  174. if the file is not in the current working directory.  The path can 
  175. be either a quoted or non-quoted string.
  176.  
  177. EXAMPLE
  178.  
  179. The following example specifies two bitmap resources:
  180.   
  181. disk1   BITMAP disk.bmp
  182. 12      BITMAP PRELOAD diskette.bmp
  183.   
  184. To load binary resources in your Visual Basic code use the LoadResBitmap
  185. function for icons, bitmaps and cursor. Use the LoadResData function to
  186. load wave files and AVI files.
  187.  
  188. For the creation of binary resource files, Microsoft provides the 
  189. following tools to make it easier to store sounds and graphics in a 
  190. format that is usable in the Resource Compiler:
  191.  
  192. - Imagedit is an image editor that supports icons (.ICO), bitmaps (.BMP) 
  193. and cursors (.CUR).  You can find this tool in the \TOOLS\IMAGEDIT 
  194. directory on your Visual Basic CD-ROM.
  195.  
  196. - Microsoft Sound System is a multimedia application that supports 
  197. wave files (.WAV).
  198.  
  199. - Microsoft Video is a multimedia application that supports video 
  200. files (.AVI).
  201.  
  202. *****************************************************************************
  203. 4. RESOURCE COMPILER OPTIONS
  204. *****************************************************************************
  205.  
  206. To start the Resource Compiler, use the rc command.  What you need to 
  207. specify in the command line depends on whether you are compiling resources, 
  208. adding compiled resources to an executable file, or doing both.
  209.  
  210. However, to use the resources in your Visual Basic application, you 
  211. will only need to compile the resources into a .RES file and add it to
  212. your Visual Basic project.
  213.  
  214. SYNTAX
  215.  
  216. rc /r [options] definition-file
  217.  
  218.  
  219. PARAMETERS
  220.  
  221. - /r        This parameter specifies that the .RC file will only be
  222.         compiled, not linked to any executable.
  223.  
  224. - options.  You can use the following options with the rc command:
  225.  
  226. Option        Description
  227. ------        -----------
  228. /?        Displays a list of rc command-line options.
  229. /fo newname    Uses newname for the name of the .RES file. 
  230.  
  231. - definition-file.  The definition-file parameter specifies the name of 
  232. the resource definition file (.RC) that contains the names, types, 
  233. filenames, and descriptions of the resources to be compiled.
  234.  
  235.  
  236. EXAMPLE
  237.  
  238. RC /r /fo TEST32.RES TEST.RC
  239.  
  240.  
  241. NOTE
  242.  
  243. You'll have to close your Visual Basic project or remove the .RES file from your
  244. project when you recreate the resource file.