Customizing

Adding Your Own Protocols

The Connection concept makes it easy to add or modify protocols. A few possible reasons that you might want to do this are:

The various connection types are defined in URLConId.pas. To add a new protocol, it's necessary to define a descendent to TURLConnection, the base class. In most cases, this is a two step process:

  1. Add your new protocol string to TURLConnection.GetConnection. This makes your new connection available for use.
  2. Override the TURLConnection.Get method. The code you add here should use the URL to determine what stream to return. It's also necessary to specify the content type (HTMLtype, TEXTtype, or ImgType) of the return.

URL Format Considerations

TFrameBrowser has the capability of assembling full URLs from partial URLs. The syntax for doing this is detemined by the standard http and file protocols. This means that any special protocols that are added should use URLs that resemble those used by the http and file protocols.

The general form of a special URL should be:

     proto://dir1/dir2/file.ext
  or
     proto:///file.ext

The important points are:


Adding HTML documents to an Application's Resources

To construct a resource file containing HTML documents and images suitable for the res protocol, proceed as follows:

A typical resource compiler file might look like:

  //   usage:  BRCC32.EXE -foHelp32.res proghelp.rc
  
  		agif2       GIF   "agif2.gif"
  		readme3     HTML  "readme3.htm"
  		readme1     HTML  "readme1.htm"
  		readme2     HTML  "readme2.htm"
  		leftwin     HTML  "leftwin.htm"
  		index       HTML  "help.htm"
  		style       HTML  "style.css"
  		borders	    TEXT  "borders.txt"
  

The first column is the name by which the resource is referenced. Column two is the resource type. The res protocol as defined recognizes HTML, HTM, GIF, JPG, JPEG, BMP, PNG, and TEXT types. The third column is the file which defined the HTML document.

In the above, the URL, res:///index.htm, would load the resource defined by the file, help.htm.