Embedding WebKit
From Visual Basic Wiki
To embed WebKit in your Visual Basic application, try this:
Add a reference to WebKit's dynamic link library and the AsmPatcher module to your project.
Create a form with scalemode set to pixels and the following code:
Option Explicit
Private Declare Function MoveWindow Lib "User32" _
(ByVal hWnd As Long, ByVal Left As Long, ByVal Top As Long, _
ByVal Width As Long, ByVal Height As Long, ByVal Repaint As Long) As Long
Dim V As New WebView, W As Long
Private Sub Form_Load()
Dim P As IWebViewPrivate
'Note: there are currently several different flavours of Webkit.
'Some of them need support libraries; if these are not in the
'current search path you will need to make them visible like so:
' ChDrive "C"
' ChDir "C:\WebKit"
'Note that this only selects the location to search for the
'support libraries; WebKit will be found in the registry.
V.setHostWindow hWnd
Asm.initWithFrame V, 0, 0, ScaleWidth, ScaleHeight, vbNullString, vbNullString
V.mainFrame.loadHTMLString "Some HTML", vbNullString
Set P = V
W = P.viewWindow
End Sub
Private Sub Form_Resize()
MoveWindow W, 0, 0, ScaleWidth, ScaleHeight, 1
End Sub
Create a class named "Asm" with the following code:
Option Explicit
Dim A(1 To 3) As Long
Sub initWithFrame(ByVal V As IWebView, _
ByVal Left As Long, ByVal Top As Long, _
ByVal Right As Long, ByVal Bottom As Long, _
ByVal frameName As String, ByVal groupName As String)
Error 1
End Sub
Private Sub Class_Initialize()
A(1) = -1957603239
A(2) = -1962662836
A(3) = 610402057
Set Asm = Me
AsmFunction 1, A
End Sub
This compensates for the little problem that Visual Basic refuses to pass user defined types by value.
