Mirror

How to load HTML pages from a resource file into a TWebBrowser (Views: 100)


Problem/Question/Abstract:

How I can save HTML pages, including *.jpg and *.gif images, into a resource file? Finally all of this stuff will be inside one compiled application. The canvas for my HTML pages will be a TWebBrowser.

Answer:

MY_HTMLFILE.RC contents: MY_HTMLFILE 23 "my_htmlfile.html"
Compiled using BRCC32 to MY_HTMLFILE.RES.

Do not ask me what the 23 resource identifier is, I got it from the MS web site.

To load into a TWebBrowser from a resource:

procedure TForm1.Button1Click(Sender: TObject);
var
  Flags, TargetFrameName, PostData, Headers: OleVariant;
begin
  WebBrowser1.Navigate('res://' + Application.ExeName + '/MY_HTMLFILE', Flags,
    TargetFrameName, PostData, Headers);
end;

<< Back to main page