|
Introduction
When distributing an application that uses a web based interface or
information pages you may not want your pages available to the end
user. The res: protocol allows you to embed your html and
other objects into the resource file of an exe or dll file.
A good example of the res: protocol is
"about:blank". This is a blank embedded page.
In developing the project it is probably wiser to work directly
with the HTML files so that adjustments to layout can be made during
the development process. Once your interface and application
work you can embed the files into a resource file - either using the
VB 6 Resource Editor or the Resource Compiler (rc.exe - usually
found in the '..Microsoft Visual Studio\Common\Vb\Resources' folder.
You can include the Resource file in your project exe or have a
separate ActiveX dll file.
| The Res: Protocol |
| Format: |
res://path and filename[/resource
type]/resource ID |
| Path and
filename: |
The path and file name of the EXE
or DLL holding the resource. |
| Resource Type:
[Optional] |
If the resource is a recognised
Type (e.g. BITMAP) then the Type can be omitted. If the
resource is a custom resource (e.g. GIF) it should be labeled
in the RC (resource compiler script file) and referenced in
the res: information. See the examples below. |
| Resource ID: |
This is the identifier of the
resource in the resource file. Often in the VB Resource
Editor the first resource is 100 or 101. If you have
experience with defining names for resources you can use the
definition term. |
The resource type and ID can be referenced as numbers. The
format then requires a # (hash) inserted before the number - however
as hash is an 'HTML
special character' an escape
sequence should be used: The escape sequence for #
(hash) is %23. This can make the path look complicated
especially as the Resource Type value for HTML is 23.
To load an HTML document from a resource file in Visual Basic
use:
WebBrowser.Navigate2
"res://myres.dll/%2323/%23101"
Where 101 is the resource ID.
The table below shows examples of referencing elements in a
resource file within the HTML source code and how to add a reference
to the information in the VB6 Resource editor.
| HTML Files |
| Type: |
23 - this is the numerical value for the
resource type HTML
|
| HTML CODE: |
src="res://myresource.dll/%2323/%23101"
|
| RC Definition: |
101 HTML "C:\Example\index.htm"
|
| VB 6 Resource
Editor: |
Click the
'Add Custom' button, find the htm file and click 'Open'.
The resource will appear in a Folder named "CUSTOM"
and will most likely be numbered 101. Double click the
resource and change 'CUSTOM' to 23 in the Type box.
Renumber the resource as required. Click OK.
|
| Bitmap Files |
| Type: |
2 - this is the numerical value for the
resource type BITMAP
|
| HTML CODE: |
src="res://myresource.dll/%232/%23102"
|
| RC Definition: |
102 BITMAP "C:\Example\example.bmp"
|
| VB 6 Resource
Editor: |
Click the 'Add
Bitmap' button, find the bmp file and click 'Open'. The
Resource Editor will place the resource in a Folder named
"Bitmap". Double click the resource to change
its ID if required.
|
| Custom Types - e.g. GIF and
JPG Files |
| Type: |
GIF is a custom format, there is no equivalent
numerical type. Note that rather than a numerical
reference in the HTML CODE, we state the custom format
'GIF'. For Jpegs or other formats, replace 'GIF' with
the chosen custom name.
|
| HTML CODE: |
src="res://myresource.dll/GIF/%23103"
|
| RC Definition: |
103 GIF "C:\Example\picture.gif"
|
| VB 6 Resource
Editor: |
Click the
'Add Custom' button, find the GIF file and click 'Open'.
The resource will appear in a Folder named
"CUSTOM". Double click the resource and change
the type from 'CUSTOM' to 'GIF'. Renumber the resource
as required. Click OK.
|
|
|
|