Platforms to show: All Mac Windows Linux Cross-Platform
/WinFrameworks/WebView2/WebView2BrowserMBS test
Last modified Tue, 22th Jun 2026.
You find this example project in your MBS Xojo Plugin download as a Xojo project file within the examples folder: /WinFrameworks/WebView2/WebView2BrowserMBS test
Download this example: WebView2BrowserMBS test.zip
Project "WebView2BrowserMBS test.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open()
If TargetWindows and XojoVersion >= 2026.02 Then
// MessageBox "OK"
Else
MessageBox "Please run on Windows in Xojo 2026r2."
End If
End EventHandler
EventHandler Function UnhandledException(error As RuntimeException) As Boolean
MsgBox Introspection.GetType(error).fullname+EndOfLine+error.Message+_
EndOfLine+EndOfLine+Join(error.Stack, EndOfLine)
Return true
End EventHandler
End Class
Class MainWindow Inherits Window
Control HTMLViewer1 Inherits HTMLViewer
ControlInstance HTMLViewer1 Inherits HTMLViewer
EventHandler Sub Open()
Me.LoadUrl "https://www.mbsplugins.de/"
End EventHandler
EventHandler Sub TitleChanged(newTitle as String)
Self.Title = newTitle
End EventHandler
End Control
Control ReloadButton Inherits PushButton
ControlInstance ReloadButton Inherits PushButton
EventHandler Sub Action()
// Take a look at the cef_browser_t structure in cef_browser_capi.h
// The reload method is 44 bytes down this structure, hence the 44 you see here
Var b As WebView2BrowserMBS = HTMLViewer1.WebView2BrowserMBS
If b <> Nil Then
b.Reload
Else
Break // no WebView2
end if
End EventHandler
End Control
Control TextButton Inherits PushButton
ControlInstance TextButton Inherits PushButton
EventHandler Sub Action()
dim b as WebView2BrowserMBS = HTMLViewer1.WebView2BrowserMBS
if b<>Nil then
dim t as string = b.PlainText
dim w as new TextWindow
w.TextArea1.Text = t
end if
End EventHandler
End Control
Control Sourcebutton Inherits PushButton
ControlInstance Sourcebutton Inherits PushButton
EventHandler Sub Action()
dim b as WebView2BrowserMBS = HTMLViewer1.WebView2BrowserMBS
if b<>Nil then
dim t as string = b.HTMLText
dim w as new TextWindow
w.TextArea1.Text = t
end if
End EventHandler
End Control
Control PictureButton Inherits PushButton
ControlInstance PictureButton Inherits PushButton
EventHandler Sub Action()
Var b As WebView2BrowserMBS = HTMLViewer1.WebView2BrowserMBS
b.CapturePreview AddressOf CapturePreviewCompleted
End EventHandler
End Control
Control ScriptButton Inherits PushButton
ControlInstance ScriptButton Inherits PushButton
EventHandler Sub Action()
dim b as WebView2BrowserMBS = HTMLViewer1.WebView2BrowserMBS
if b<>Nil then
b.ExecuteScript("alert('Hello');", nil)
end if
End EventHandler
End Control
Control URLButton Inherits PushButton
ControlInstance URLButton Inherits PushButton
EventHandler Sub Action()
dim b as WebView2BrowserMBS = HTMLViewer1.WebView2BrowserMBS
if b<>Nil then
MsgBox b.URL
end if
End EventHandler
End Control
Control VersionText Inherits Label
ControlInstance VersionText Inherits Label
EventHandler Sub Open()
me.Text = RBVersionString
End EventHandler
End Control
EventHandler Sub Open()
End EventHandler
Sub CapturePreviewCompleted(Browser as WebView2BrowserMBS, ImageFormat as Integer, ErrorCode as Integer, PictureData as String)
Var p As New PicWindow
p.Backdrop = Picture.FromData(PictureData)
p.show
End Sub
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class PicWindow Inherits Window
End Class
Class TextWindow Inherits Window
Control TextArea1 Inherits TextArea
ControlInstance TextArea1 Inherits TextArea
End Control
End Class
Sign
End Sign
End Project
Download this example: WebView2BrowserMBS test.zip
The items on this page are in the following plugins: MBS WinFrameworks Plugin.