Hi George
Try this (watch for wrapping)
<code>
Private SID_SProfferService As New
Guid("cb728b20-f786-11ce-92ad-00aa00a74cd0")
Private IID_IProfferService As New
Guid("cb728b20-f786-11ce-92ad-00aa00a74cd0")
Private SID_SHTMLEditHost As New
Guid("3050f6a0-98b5-11cf-bb82-00aa00bdce0b")
' IServiceProvider interface
<ComVisible(True), ComImport(),
Guid("6d5140c1-7436-11ce-8034-00aa006009fa"), _
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)> _
Public Interface UCOMIServiceProvider
Function QueryService(ByRef guidService As Guid, ByRef riid As Guid) As
IntPtr
End Interface
' IProfferService interface
<ComVisible(True), ComImport(),
Guid("cb728b20-f786-11ce-92ad-00aa00a74cd0"), _
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)> _
Public Interface IProfferService
Sub ProfferService(ByRef guidService As Guid, ByVal psp As
UCOMIServiceProvider, ByRef cookie As Integer)
Sub RevokeService(ByVal cookie As Integer)
End Interface
Private Sub SetEditHost()
Dim ips As IProfferService
Dim objBrowser As Object
Dim ispBrowser As UCOMIServiceProvider
Dim ip As IntPtr
Try
' Get a handle to the browser ocx
objBrowser = AxWebBrowser1.GetOcx()
ispBrowser = DirectCast(objBrowser, UCOMIServiceProvider)
' Query the browser for the IProfferService interface
ip = ispBrowser.QueryService(SID_SProfferService,
IID_IProfferService)
ips = DirectCast(Marshal.GetObjectForIUnknown(ip), IProfferService)
' Proffer the new object as the provider of the IHTMLEditHost
interface handler
ips.ProfferService(SID_SHTMLEditHost, New ServiceProvider,
m_EditHostCookie)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Class ServiceProvider
Implements UCOMIServiceProvider
Public Function QueryService(ByRef guidService As System.Guid, ByRef
riid As System.Guid) As IntPtr Implements
UCOMIServiceProvider.QueryService
If guidService.Equals(SID_SHTMLEditHost) Then
If riid.Equals(IID_IHTMLEditHost) Then
Dim ieh As IHTMLEditHost
ieh = New EditHost
Return Helper.GetInterface(ieh, IID_IHTMLEditHost)
Else
Return Nothing
End If
Else
Return Nothing
End If
End Function
End Class
Public Class EditHost
Implements IHTMLEditHost
Public Sub SnapRect(ByVal pIElement As mshtml.IHTMLElement, ByRef prcNew
As mshtml.tagRECT, ByVal eHandle As mshtml._ELEMENT_CORNER) Implements
IHTMLEditHost.SnapRect
' TODO: Implementation here
End Sub
</code>
You can call SetEditHost() during initialisation, before you navigate to
about:blank for the first time, as it does not require a document.
I hope I have included everything.
HTH
Charles
> Hello group,
>
[quoted text clipped - 5 lines]
> Regards,
> George Ionescu
George Ionescu - 28 Jan 2004 15:37 GMT
Thanks Charles,
I forgot something: VB6 NOT VB.NET :-)
Thanks.
> Hi George
>
[quoted text clipped - 111 lines]
> > Regards,
> > George Ionescu
Charles Law - 28 Jan 2004 15:53 GMT
I haven't implemented it in VB6, but I suspect it could be converted without
too much difficulty.
I also forgot the following helper function:
<code>
Public Shared Function GetInterface(ByVal obj As Object, ByRef iid As Guid)
As IntPtr
Dim pUnk As IntPtr
Dim pInterface As IntPtr
Dim hr As Integer
pUnk = Marshal.GetIUnknownForObject(obj)
hr = Marshal.QueryInterface(pUnk, iid, pInterface)
If hr < 0 Then
Marshal.ThrowExceptionForHR(hr)
End If
Marshal.Release(pUnk)
Return pInterface
End Function
</code>
Charles
> Thanks Charles,
>
[quoted text clipped - 120 lines]
> > > Regards,
> > > George Ionescu