TWebView2
Source: source/classes/twebview2.prg
Overview
TWebView2 embeds Microsoft Edge WebView2 in a FiveWin window or
dialog. Use it to host modern HTML/CSS/JS UIs next to native FWH controls.
Requires the WebView2 Runtime
(Evergreen or Fixed Version).
Desktop + Web with one UI
Sample samples/DesktopWeb/login.prg shows a full pattern where
desktop and browser share the same HTML/CSS/JS:
- An embedded multi-thread HTTP server listens on port
8080and serves login + dashboard pages generated in Harbour. - The desktop shell creates
TWebView2andNavigate("http://localhost:8080/"). - Any browser opens the same URL and gets the identical UI and API.
- Credential validation runs in PRG (
ValidateLogin), not in JavaScript. Sessions use cookieDWSESS.
// Desktop shell (simplified)
StartHttpServer( 8080 )
oWeb := TWebView2():New()
oWeb:Navigate( "http://localhost:8080/" )
oWeb:Run()
Build with multi-thread VM: samples\DesktopWeb\build.bat or
build_new.bat login hm64 -mt. Demo users:
admin/1234, demo/demo.
Key methods
New( oWndParent, cUserDataFolder, cBrowserExecutableFolder )Navigate( cUrl )/SetHtml( cHtml )Eval( cJavaScript )/InjectJavascript( cScript )bOnBind— receives arguments from JSSendToFWH(...)SetSize,SetTitle,SetUserAgent,OpenDevToolsWindow,End
For Remote View + WebView2 together, see
samples/RemoteView/testrvweb.prg and
Remote View.
See Classes Alphabetical for full class list.