|

When to use:
Using IE & Delphi Resource Tool you can store webpages (including
images, cascading stylesheets etc.) inside your application exe-file or in
a separate DLL-file.
You can also choose to add permanent or pluggable protocol handler, so
your webpages can be called from Internet Explorer or your webbrowser
using a protocolname similar to the built-in about-protocol:
"iedelphi:mywebpage"
where "iedelphi" is the name of your protocol and "mywebpage"
the name of the stored webpage.
The tool also include a WYSIWYG helper for editing and adding features
to html-dialogs.
How to use:
Place IEResTool.exe in its own directory.

First time you run IERestool you will need to tell the full path to
your Delphi bin-directory, where BRCC32.EXE and DCC32.EXE are located.
Next add full path to the directory where the files you want to add are
located.

It is important that all files to be included are placed in this
directory. IEResTool don't include subdirectories. All html-files must use
simple links, e.g.:
<A HREF="page.htm"><IMG SRC="picture.jpg"></A>
If you need IeResTool to be more flexible on this point (read files
from subdirectories and resolve relative links) you can make the nessecary
changes to the included source code.
IEResTool first reads all files in the directory with file-ext.
".htm" or ".html". Next it includes all files called
from these files. This means that you don't have to worry about extra
files in the directory. If they are not needed to display the .htm or
.html files, they are not included in the resource files.
Next step is adding a protocol name:

You can use any letters or numbers [a..z, A..Z, 0..9] in the protocol
name. However you cant use a number as the first character:
abc123 = works fine
123abc = don't work
IERestool check and let you know, if you enter an illegal protocol name.
Protocol names are case in-sensitive.
IERestool creates a new unique indetifier for each new protocol name,
but it saves protocol names you have used before and the GUID associated
with it. You can use the dropdown box to re-select protocol names. This is
important if you for instance create an updated version of a DLL with a
permanent pluggable protocol. (see more about this later).

Select if you want to save source file for the created DLL-files and
the temporary HTML-files. The default setting is shown above, and you
should only save modified HTML-files for debugging if unexpected errors
occurs.
Now you are ready to go. Click "Create" button. If you store
large websites inside resource files it may take several minutes for
IERestool to finish the work, but in most cases it only takes few seconds.
The stored webpages and/or HTMLdialog-files are shown in the listbox,
and you can choose to see them in the default browser or as HTML-dialog.

Before closing IEResTool you should create featurestring for the HTML
dialogs in your resource file. Select the dialog files in the listbox and
click "Test as HTMLDialog".
a new window will open:

Use the options to select the window ornaments for the dialog box. More
info about each option is available in a hint-box when you select an item.
Whenever you want you can see the result by clicking "Test". The
Dialog is now showing with the options you have selected, and you can now
resize the dialog and drag it to the top/left location where you want it
to show up. When you resize or move the dialog it will be reflected in
top, left, height and width coordinates, so you dont have to enter these
manually.
When the HTML dialog looks the way you want it, you click "FeatureString
to Clipboard" and you can now paste it into your Delphi-code. The
string may look like this:
dialogHeight: 180px; dialogWidth: 405px; dialogTop: px;
dialogLeft: px;' center: 1; dialoghide: 0; edge: raised; help: 0;
resizable: 0; scroll: 0;' status: 0; unadorned: 0;
To show the Dialog in your program you can use something like:
procedure ShowAboutDialog;
var
Url: string;
Moniker: IMoniker;
v1, v2: Variant;
F: string;
begin
f := 'dialogHeight: 180px; dialogWidth: 405px; dialogTop: px;
dialogLeft: px;' +
' center: 1; dialoghide: 0; edge: raised; help: 0; resizable: 0;
scroll: 0;' +
' status: 0; unadorned: 0;';
Url := 'res://' + Application.Exename + '/about';
CreateUrlMoniker(nil, StringToOleStr(Url), Moniker);
ShowHTMLDialog(Handle, Moniker, v1, StringToOleStr(F), v2);
end; |
In this example the resources for the HTMLDialog is stored inside the
exe-file and no protocol is attached.
If protocol name was "iedelphi" and the protocol was
activated the url would be: "iedelphi:about".
The created files
When you close IEResTool you will find a subdirectory to the directory
where IERestool is located. The name of the subdirectory is the same as
the name you selected for the protocol.
IERerstool has created 9 files in the [ProtocolName] subdirectory:
[ProtocolName]res.res
[ProtocolName]res.rc
[ProtocolName]res.dll
[ProtocolName]res.dpr
[ProtocolName]protocol.dll
[ProtocolName]protocol.dpr
_[ProtocolName]protocol.pas
[ProtocolName]EXEprotocol.pas
[ProtocolName]DLLprotocol.pas
If you in IERestool chose not to save source files only the following
files would be created:
[ProtocolName]res.res
[ProtocolName]res.dll
[ProtocolName]protocol.dll
[ProtocolName]EXEprotocol.pas
[ProtocolName]DLLprotocol.pas
The files gives you different ways to implement the resource files in your
application. Running the following demo will give some more information
about differences between permanent and temporary pluggable protocols and
sample code.
Running the Demo
1. Unzip all files and keep the subdirectories, so you have a
subdirectory called "demo".
The demo-files includes the following:
coua.css (A cascading stylesheet used by the About-dialog
and all webpages).
hhwani.gif (An animated gif-file used by the about dialog and
all webpages).
About.htm (The About HTMLDialog).
page1.htm
page2.htm
page3.htm
page4.htm (the helpfiles for IERestool).
2. Start IERestool. Make sure IERestool knows where to find your
Delphi\bin directory.
3. Set the files-directory to the demo-subdirectory. (Default).
4. Set protocol name to IEDemo
5. Click the Create-button.
The Listbox shows the following files:
about
page1
page2
page3
It is described earlier how you can create a featurestring for the
About-dialog. Here we will go directly to creating temporary and permanent
pluggable protocols.
6. Close IEResTool. The following files are created in a new subdirectory "IEDemo":
iedemores.res
iedemores.rc
iedemores.dll
iedemores.dpr
iedemoprotocol.dll
iedemoprotocol.dpr
_iedemoprotocol.pas
iedemoEXEprotocol.pas
iedemoDLLprotocol.pas
Create a permanent pluggable protocol.
IEDemoProtocol.dll
Source:
_iedemoprotocol.pas
iedemoprotocol.dpr
If you want to be able to activate your protocol in Internet Explorer
and not only in your webbrowser application, you need a permanent
pluggable protocol.
Register iedemoProtocol.dll:
"regsvr32 iedemoProtocol.dll" from the command-line.
You can now open Internet Explorer and show your stored webpages using
<Protocolname>:<filename> e.g.:
"iedemo:page1"
to unregister the protocol:
regsvr32 /u iedemoProtocol.dll.
The source code for iedemoProtocol.dll is in _iedemoprotocol.pas
and iedemoprotocol.dpr.
Create temporary pluggable protocol.
To activate your protocol from the webbrowser application you don't need a
permanent protocol, but can create a temporary protocol.
IERestool offers you two different ways to make your stored webpages
avaiable for the application. Inside the executable file or in a DLL-file.
a. Store webpages inside your executable webbrowser application.
Use:
IEDemoExeProtocol.pas
IEDemo.res
Copy IEDemoEXEprotocol.pas and IEDemo.res to your project directory.
Add iedemoEXEprotocol to the uses section in your webbrowser
application.
You can now call two procedures:
register<Protolcolname>protocol;
unregister<protocolname>protocol;
After registering the temporary protocol you can show the stored
webpages in the browser by typing
"iedemo:page1" in the addressbar.
to unregister use:
"UnregisterIEDemoProtocol;"
//How to register the
IEDemo-protocol
procedure TForm1.Button1Click(Sender: TObject);
begin
RegisterIEDemoProtocol;
end;
//How to show the page in your webbrowser
procedure TForm1.Button2Click(Sender: TObject);
begin
embeddedwb1.go('iedemo:page1');
end;
//How to unregister the IEDemo-protocol
procedure TForm1.Button3Click(Sender: TObject);
begin
UnRegisterIEDemoProtocol;
end;
|
b. Store webpages and temporary protocol in a DLL-file.
Use:
IEDemoDLLProtocol.pas
IEDemoRes.Dll
Copy IEDemoDLLprotocol.pas and IEDemoRes.DLL to your project directory.
Add iedemoDLLprotocol to the uses section in your webbrowser
application.
You can now call two procedures:
register<Protolcolname>protocol;
unregister<protocolname>protocol;
After registering the temporary protocol you can show the stored
webpages in the browser by typing
"iedemo:page1" in the addressbar.
to unregister use:
"UnregisterIEDemoProtocol;"
Remember that you need to distribute the dll-file along with your
application.
I prefer using DLL-file to store webpages. The overhead is only 16 Kb
and resources in a DLL-file is much easier to upgrade from the main
application.
Store HTML-Resources in executabler file without protocol.
use:
IEDemo.res
If you only store HTML-dialog resources you probably not need a pluggable
protocol and you can add
{$R IEDemo.Res}
to your application and call a dialog this way:
procedure TForm1.Button1Click(Sender: TObject);
begin
Embeddedwb1.go('res://' + Application.Exename + '/about');
end;
|
Download
Useful links:
The Importance of Good Dialog
How to build Dynamic HTML dialog boxes and customize them for your Web
application.
Creating HTML Dialogs in Borland Delphi
A short paper describing how to use Microsoft Internet
Explorer HTML Dialog technology with Delphi. (by David J. Fiddes).
|