Resource Builder - Visual Resource Editor for WindowsWhats New
English version German version Russian version
homeoverviewfeaturesdownloadordercontact usforum

Using HTML resources to create user interface for your applications

Usually modern applications use standard way to create user interface using buttons, windows and other controls. Considering the growing Internet usage these days it is possible to suppose that end-users spend a lot of time browsing web sites. So it could be a good idea to offer them new applications with user interface built using HTML.

More at all, it is very easy!

Let's describe using of HTML resources stored inside Resource-Only-DLL:

  1. Run Resource Builder and in menu select Resources | Add new type | HTML:
Adding HTML resource.

Figure 1. Adding HTML resource.

  1. Define the name for resource as SAMPLE.HTML in appeared dialog and click OK button.
  2. Double-click on SAMPLE.HTML resource in resource tree and type the following HTML code in appeared editor:
    <html>
    <head>
    <title>Sample HTML file for res:\\ protocol.</title>
    </head>
    <body>
    <h1>Hello World!</h1>
    <img src="/LOGO.PNG">
    </body>
    </html>
    
    So you will see the following on your screen:
HTML resource sample.

Figure 2. HTML resource sample.

  1. Add another HTML resource with LOGO.PNG name and load it from the PNG file on your disk.
  2. Select in Resource Builder menu Tools | Create Resource-Only-DLL and specify the file name for DLL.
  3. Run your Internet browser and type the following in address bar:
    res://[PATH_TO_YOUR_DLL_FOLDER]sample.dll/SAMPLE.HTML
    and click Go button.
  4. You will see something like the following in your browser:
HTML resource from DLL.

Figure 3. HTML resources in DLL and res:// protocol.

As you see there is nothing difficult!

We've just demonstrated the usage of HTML resources stored in Resource-Only-DLL. Let's try to use HTML resources inside our EXE itself. Create simply application containing one window and WebBrowser control on it. Add the following code to the application start-up code to navigate WebBrowser control to HTML page stored in executable resources:
WebBrowser1.Navigate('res://' + Application.ExeName + '/sample.html'); (Pascal code)

After application run we will see the following:

Starting application without HTML resources.

Figure 4. Starting application without HTML resources.

Let's modify our RC file created earlier, compile it to RES and add to our project. If we run our application after recompilation we will see the following:

Application with HTML resources.

Figure 5. Application with HTML resources.

As you can see we can use links to another HTML resources stored inside our EXE (as well as inside other modules). This allows us to create any user interface we want using the HTML code. More at all, using Resource Builder we can modify HTML and graphical resources of our application even without recompilation. This brings us the powerful and easy solution to update and improve our application as well as to create customized or localized builds.

You can download the sample source code and resources from: http://www.resource-builder.com/files/res_protocol.zip

Read more at: http://www.resource-builder.com

Download the trial version at: http://www.resource-builder.com/download.html


  See Also
TsiLang Components Suite complete set of tools and components to create multilanguage applications.
 
  Articles
A quick look at Resource Builder
 
  Pain-free Ability to Edit Resources  
  Using HTML resources to create user interface for your applications
 
  Awards
Award cupResource Builder has been awarded by many software sites. Check out the Awards page.
 
     
© 1999-2016 Igor Siticov, SiComponents® http://www.sicomponents.com
Resource Builder® and SiComponents® are registered trademarks of Igor Siticov.
Privacy SiteMap Terms