ActiveX (WebBrowser) and WebView2
Technical reference comparing both models for rendering web content inside a Harbour / HMG desktop application
01 Introduction
ActiveX and WebView are not the same category of technology, which is why they are compared differently. ActiveX is a Microsoft technology for embedding components (controls) into Windows desktop applications—and formerly into Internet Explorer. WebView2 is an embedded browser control powered by Chromium and the Microsoft Edge runtime.
In practice, the legacy WebBrowser (ActiveX) control relied on the Internet Explorer rendering engine (Trident), which is now deprecated. WebView2 is its modern successor.
Primary use cases:
- Rendering web pages or HTML views inside a desktop application.
- Querying web data or displaying formatted HTML reports.
- Executing JavaScript and exchanging messages with application code.
This document summarizes the analysis of both options. HMG integration specifics should be verified against your installed HMG/Harbour version (see Section 10).
02 The Two Models
2.1. ActiveX: Component Format
ActiveX is a component format (OCX/COM). The control runs with the current user's privileges, which historically created security concerns. Microsoft dropped ActiveX support in modern browsers, and Edge does not include it. Within Windows desktop applications, however, the COM container remains available and the legacy WebBrowser control is still present in the OS.
2.2. WebView2: Embedded Browser Control
WebView2 is a dedicated embedded browser control. It renders modern web content inside desktop applications using the Microsoft Edge (Chromium) runtime.
03 ActiveX WebBrowser (Legacy)
- Uses the Internet Explorer rendering engine (Trident), which is deprecated.
- Built into Windows: requires no additional installation. HMG supports it natively via
DEFINE ACTIVEX. - Fails on modern websites: modern JavaScript, CSS layouts, and current TLS/HTTPS standards often break or render improperly.
- Suitable only for simple local HTML or maintaining legacy functionality that already works.
ActiveX controls run under the user's security context. Because the IE engine receives no feature updates, it is unsuitable for new projects.
04 WebView2 (Modern)
- Uses Chromium, the same engine powering Microsoft Edge, providing full modern web compatibility.
- Requires the Microsoft Edge WebView2 Runtime on target machines. Windows 11 includes it by default; Windows 10 installations may require deploying the runtime.
- Microsoft does not ship WebView2 as an ActiveX control. In Harbour/HMG, it requires a third-party COM/ActiveX wrapper (such as SocketTools or AntView, which may be commercial) or a custom C/C++ wrapper library.
- Supports executing JavaScript and bidirectional messaging between the web page and host application code.
Applications using WebView2 must verify that the runtime is installed on the target PC or bundle the Microsoft WebView2 bootstrapper/installer during deployment.
05 Comparison
| Feature | ActiveX WebBrowser | WebView2 |
|---|---|---|
| Type | COM/OCX control (component format) | Embedded browser control |
| Engine | Internet Explorer (Trident) | Chromium (Microsoft Edge) |
| Status | Deprecated, no feature updates | Active, maintained by Microsoft |
| Installation | Pre-installed with Windows | Requires WebView2 Runtime (included in Windows 11) |
| Modern web (JS, CSS, HTTPS) | Limited or broken | Full support |
| HMG support | Native (DEFINE ACTIVEX) | Via third-party COM wrapper or C library |
| JavaScript & page ↔ host messaging | Limited | Yes (bidirectional messaging) |
| Cost | Free | Commercial COM wrappers may require a license |
| Recommended use | Simple local HTML or legacy maintenance | New projects |
06 Usage in Harbour / HMG
HMG provides native support for hosting ActiveX/COM controls inside a window using the DEFINE ACTIVEX command (or its alternative @ row, col ACTIVEX ... syntax). Once created, the underlying OLE interface is accessed through the control's Object property.
Because Microsoft does not expose WebView2 directly as an ActiveX control, HMG applications connect to it either through third-party COM/ActiveX wrappers (such as SocketTools or AntView) using the exact same HMG container syntax with a different PROGID, or through a native C wrapper around the ICoreWebView2 API.
Example of an ActiveX wrapper over WebView2: docs.sockettools.com — WebView ActiveX control.
#include "hmg.ch"
FUNCTION Main()
DEFINE WINDOW Win_Main ;
AT 0, 0 ;
WIDTH 900 ;
HEIGHT 650 ;
TITLE "HMG — ActiveX / WebView2 Web Container" ;
MAIN ;
ON INIT LoadPage()
// 1. Legacy WebBrowser (Trident): PROGID "Shell.Explorer.2"
// 2. WebView2 Wrapper (e.g., AntView / SocketTools): replace PROGID
DEFINE ACTIVEX oWeb
ROW 10
COL 10
WIDTH 860
HEIGHT 590
PROGID "Shell.Explorer.2"
END ACTIVEX
END WINDOW
CENTER WINDOW Win_Main
ACTIVATE WINDOW Win_Main
RETURN NIL
STATIC PROCEDURE LoadPage()
LOCAL oOle
// Retrieve the COM object hosted inside the HMG ActiveX control
oOle := Win_Main.oWeb.Object
IF HB_ISOBJECT( oOle )
// Optional: suppress legacy script error dialogs in Trident
oOle:Silent := .T.
oOle:Navigate( "https://example.com" )
ENDIF
RETURN- The
.ObjectProperty: In HMG,Win_Main.oWebreferences the GUI wrapper control, whereasWin_Main.oWeb.Objectreturns the underlying OLE object (TOleAuto) used to invoke COM methods (Navigate,GoBack,Refresh, etc.). - COM Events: The built-in
DEFINE ACTIVEXcontrol in HMG 3.4.x / 3.6 hosts visual controls and exposes methods/properties, but does not provide direct COM event sink clauses inside the command block without extending the C wrapper or using Harbour's__axRegisterHandler()(hbwin). - WebView2 Wrappers: When using a commercial wrapper (such as
AntViewAx.AntVieworSocketTools.WebView.12), simply replace thePROGIDstring and adjust method calls according to the vendor's API reference.
07 Properties and Features
Summary of each model in a control specification format:
- Engine: Internet Explorer.
- Dependencies: none.
- Simple and internal HTML.
- Limitations with modern web standards.
- Permissions: current user context.
- Engine: Chromium / Edge.
- Dependency: WebView2 Runtime.
- Full modern web support.
- JavaScript and page ↔ host messaging.
- Third-party COM wrapper or C wrapper in HMG.
08 Recommendation
Use WebView2, since the IE engine will receive no further improvements. Validate with a minimal test page first to confirm that both the runtime and wrapper behave as expected.
Only for simple static/internal HTML or existing legacy modules that already work and do not require modern web capabilities.
09 Sources
| Resource | Link | Purpose |
|---|---|---|
| WebView2 ActiveX Wrapper | docs.sockettools.com | Example of a third-party COM/ActiveX wrapper |
| WebView2 Documentation | Microsoft Learn (Edge WebView2) | Runtime, system requirements, and deployment |
| HMG Documentation | Reference Manual (DEFINE ACTIVEX) | ActiveX control syntax in HMG |
References to Microsoft and HMG documentation serve as general technical pointers to verify against your exact compiler and wrapper versions.
10 Verification Plan
- Verify that the runtime is installed on the target PC.
- Test across Windows 10 and Windows 11.
- Load a minimal HTML page inside the HMG control.
- Confirm the wrapper initializes and responds.
- Load a modern HTTPS web application.
- Compare rendering against ActiveX WebBrowser.
- Execute JavaScript from Harbour code.
- Receive web messages back from the page.
- Test on a clean PC without the runtime.
- Define the runtime installation strategy.
11 Conclusion
ActiveX WebBrowser is a legacy component with zero external dependencies, but it is severely constrained by the deprecated Internet Explorer engine. WebView2 delivers Chromium and modern web standards, at the cost of requiring the WebView2 Runtime and a third-party COM wrapper (or C library) in Harbour/HMG.
For new projects, WebView2 is the recommended choice, validated early with a simple proof-of-concept page.