CEF Package
The cefPackage wraps the Chromium Embedded Framework and exposes it as an ordinary twinBASIC control. Drop a CefBrowser onto a form and a Chromium browser renders web content inside it — navigate to URLs, run JavaScript, print pages to PDF, and exchange messages with the loaded page.
The package is a built-in package shipped with twinBASIC, but the CEF runtime itself is distributed separately — applications must ship the matching runtime ZIP alongside the executable. See Runtime files below.
Important
The CEF package is currently in BETA. Several features available on WebView2 are not yet exposed; see WebView2 parity below.
- Why CEF instead of WebView2?
- Supported runtimes
- Runtime files
- WebView2 parity
- Classes
- Enumerations
- Tutorials
Why CEF instead of WebView2?
CEF and WebView2 both wrap a Chromium-based browser inside a twinBASIC control. CEF brings advantages that matter for some applications:
- Cross-platform ready. CEF runs on Windows, Linux, and macOS. WebView2 is Windows-only.
- Full control over the runtime stack. The application targets a specific Chromium build and distributes it alongside the software. There is no runtime auto-update behind the developer’s back, so behavior stays consistent across deployments.
- Deeper runtime integration. CEF allows hosting twinBASIC code inside the renderer / JavaScript process — something the locked-down WebView2 object model cannot do.
Choose WebView2 when targeting only modern Windows and willing to rely on the system-installed Edge runtime; choose CEF when control over the Chromium version or cross-platform readiness matters.
Supported runtimes
Three CEF versions are supported, each carrying a different Chromium baseline and different OS reach:
| Runtime version | Supported OS | Notes |
|---|---|---|
| v49 | Windows XP+ | Last Chromium version that supports Windows XP. |
| v109 | Windows 7+ | Last Chromium version that supports Windows 7. |
| v145 | Windows 10+ | Recommended modern runtime. |
Warning
Older Chromium versions should not generally be used for unrestricted internet browsing — they carry unpatched security vulnerabilities. They remain appropriate for tightly controlled environments where the browser loads only trusted local or internal content.
The user picks a runtime in two places that must agree:
- At compile time — by adding the matching
[COMPILER PACKAGE] twinBASIC - Chromium Embedded Framework Package v<N>reference to the project. This sets theCEF_VERSIONconditional-compilation constant (49, 109, or 145) that the package’s own sources compile against. CefBrowser.CefMajorVersion returns this value at run time. - At deploy time — by shipping the matching runtime ZIP, extracted into the discovery folder or pointed at via EnvironmentOptions.BrowserExecutableFolder.
The runtime bitness must match the application bitness — a 32-bit application needs the 32-bit runtime ZIP, a 64-bit application needs the 64-bit ZIP.
Runtime files
The runtime ships separately from the package. Download the ZIP that matches both the CEF version and the application bitness:
| Version | Win32 | Win64 |
|---|---|---|
| v49 | cefRuntime49_win32.zip | cefRuntime49_win64.zip |
| v109 | cefRuntime109_win32.zip | cefRuntime109_win64.zip |
| v145 | cefRuntime145_win32.zip | cefRuntime145_win64.zip |
See also CEF Runtime Releases for the latest release.
Installing runtime files
Extract the ZIP into:
%LocalAppData%\twinBASIC_CEF_Runtime\
For example, the v145 Win64 runtime ends up at:
%LocalAppData%\twinBASIC_CEF_Runtime\145_0_7632_160_Win64\
The version-stamped folder must contain libcef.dll and its sibling runtime files.
At launch, CefBrowser searches for the runtime in this default location. If libcef.dll cannot be found, the Error event fires with the exact path that was searched.
Overriding the runtime location
To point at a different folder — for example a portable side-by-side deployment — assign EnvironmentOptions.BrowserExecutableFolder before or during the Create event:
Private Sub CefBrowser1_Create()
CefBrowser1.EnvironmentOptions.BrowserExecutableFolder = _
"D:\MyApp\CEF\145_0_7632_160_Win64"
End Sub
The folder must contain libcef.dll.
WebView2 parity
These WebView2 features are not yet exposed on CefBrowser and have no documented counterpart:
- Methods: OpenTaskManagerWindow, AddObject (host-object publication for JavaScript), AddWebResourceRequestedFilter and the surrounding request-interception machinery.
- Events: AcceleratorKeyPressed, PermissionRequested, WebResourceRequested, ProcessFailed, ScriptDialogOpening, UserContextMenu, SuspendCompleted, SuspendFailed, DownloadStarting, NewWindowRequested.
The NavigationComplete event carries IsSuccess and WebErrorStatus parameters in its signature but currently returns placeholder values (True and 0) — the underlying CEF callbacks that would populate them have not yet been wired in.
The surface will continue to grow; treat this list as a snapshot of the current beta and not a long-term limitation.
Classes
- CefBrowser – the control: navigation, scripting, virtual-host mapping, PDF printing, and lifecycle events driven by the matching CEF runtime
- CefEnvironmentOptions – pre-creation configuration for the CEF environment (executable folder, user-data folder, log file, log severity); reached via the control’s EnvironmentOptions property
Enumerations
- CefLogSeverity – the verbosity threshold for the CEF debug log; carried by EnvironmentOptions.LogSeverity
- cefPrintOrientation – page orientation passed to PrintToPdf
Tutorials
- Getting started – package reference, runtime download, install path
- Customize the UserDataFolder – relocating the runtime’s working folder
- Re-entrancy – the deferred-event model and the one place (JsRun) you still have to think about it
- Building a browser shell – back / forward / reload / zoom / PDF
- Hosting local web assets – virtual-host folder mappings
- JavaScript interop – messages and scripted calls between BASIC and the page
- Driving Monaco from twinBASIC – case study combining everything above