WebView
Delphi and C++Builder component to host web content in your applications.
- uses Microsoft WebView2 API
- requires WebView2 Runtime version 131.0.2903.51 or newer
- supports Delphi/C++Builder 5 - 12 and Lazarus 3.6
- source code included in the registered version
- royalty-free distribution in applications
Download and order
Order WebView license $120 USD (license for one developer)
Order WebView multi-license $360 USD (license for all developers in the company)
Order WebView year upgrades license $60 USD (registered users only)
Order WebView year upgrades multi-license $180 USD (registered multi-license users only)
FAQ
What version of Edge (Chromium) browser is required?
WebView2 Runtime has to be installed. WebView2 API can't use Edge browser: path containing \Edge\Application\ is explicitly tested and disallowed.
WebView2 Runtime is deployed with many applications, including Microsoft Office, and it's included in Windows 11 machines.
How can I allow OnWebResourceRequested events?
Set a URI filter:
The format is language[-country] where language is the 2-letter code from ISO 639 and country is the 2-letter code from ISO 3166. Examples: SK, SK-SK, EN-SK, EN-US.
Why is the Active property False after setting it to True?
Active property is updated asynchronously. Use the OnActive event to detect when the Active value is changed.
How can I convert a web page to PDF format?
Set the user agent in OnActive event handler to some non-default value:
Use the additionalObjects property of the event:
WebView2 Runtime has to be installed. WebView2 API can't use Edge browser: path containing \Edge\Application\ is explicitly tested and disallowed.
WebView2 Runtime is deployed with many applications, including Microsoft Office, and it's included in Windows 11 machines.
How can I allow OnWebResourceRequested events?
Set a URI filter:
WebView.AddFilter;How can I set a custom response?
procedure TFormMain.WebViewWebResourceRequested(Sender: TObject; Resource: TWebResource; Source: TWebSource; const Request: IWebResourceRequest; var Response: IWebResourceResponse; GetDeferral: TGetWebResourceRequestedDeferral); begin Response := WebView.CreateResponse(TEncoding.UTF8.GetBytes('Hello!')); end;How can I use a deferred event handler?
procedure TFormMain.WebViewWebResourceRequested(Sender: TObject; Resource: TWebResource; Source: TWebSource; const Request: IWebResourceRequest; var Response: IWebResourceResponse; GetDeferral: TGetWebResourceRequestedDeferral); begin // non-deferred code const Deferral = GetDeferral; // request deferral TThread.ForceQueue(nil, procedure begin // deferred code Deferral.Complete; // complete deferral end); end;What format is accepted in the Language property?
The format is language[-country] where language is the 2-letter code from ISO 639 and country is the 2-letter code from ISO 3166. Examples: SK, SK-SK, EN-SK, EN-US.
Why is the Active property False after setting it to True?
Active property is updated asynchronously. Use the OnActive event to detect when the Active value is changed.
How can I convert a web page to PDF format?
WebView.PrintToPdf('C:\webpage.pdf');How can I log in to Google account?
Set the user agent in OnActive event handler to some non-default value:
procedure TFormMain.WebViewActive(Sender: TObject); begin WebView.UserAgent := 'Embedded browser'; end;How can I navigate using a custom request?
procedure TFormMain.WebViewActive(Sender: TObject); begin WebView.Navigate(WebView.CreateRequest('https://www.winsoft.sk')); end;How can I retrieve files sent to DOM using PostJsonWebMessage method?
Use the additionalObjects property of the event:
// Delphi const FileHandle = WebView.CreateFileHandle('c:\test.txt'); const DirectoryHandle = WebView.CreateDirectoryHandle('c:\'); WebView.PostJsonWebMessage('"test message"', [FileHandle, DirectoryHandle]); // JavaScript window.chrome.webview.addEventListener('message', function (event) { var fileSystemHandle0 = event.additionalObjects[0]; // FileSystemHandle var fileSystemHandle1 = event.additionalObjects[1]; // FileSystemHandle ... });How can I set focus to WebView?
WebView.SetFocus;