Skip to content

Quick Symbian Factoid #4 : Loading local html file using S60 BrowserControl.



I had been looking around for a small code snippet to add the S60 Browser control to the app view to display a local html file. So here is the code that worked for me.

//header to include
#include <brctlinterface.h>

//add this to construct the browser control
    CBrCtlInterface* brCtl = ::CreateBrowserControlL(
            this,
            iBrCtlRect,
            TBrCtlDefs::ECapabilityDisplayScrollBar,
            TBrCtlDefs::ECommandIdBase,
            NULL,
            NULL,
            NULL);
    
    RFile htmlfile;
    htmlfile.Open(CEikonEnv::Static()->FsSession(),KHtmlFileName,EFileRead);
    brCtl->LoadFileL(htmlfile);
    brCtl->ActivateL();

//do this in the SizeChanged of the parent control
     brCtl->SetRect(newRect);

Don’t forget to add the browser control to the parent control’s ComponentControl() and CountComponentControls() functions. Also the local html file being loaded can either be in the applications private folder or in the public folders.