Hallo!
Nach einigem suchen, ausprobieren und experimentieren habe ich einen Weg gefunden, der auf diesem Artikel basiert:
http://codeproject.com/csharp/advhost.asp?df=100&forumid=4164&exp=0
Zunächst die "Source files" herunterladen, daraus die "Interop.SHDocVw.dll" in das bin-Verzeichnis eines neuen Projektes verschieben und als Verweis einbinden. Dann einen WebBrowser auf die Form ziehen und folgenden Code einfügen:
' API-Fubktion zum Ermitteln des STRG-Tastenstatus
<Runtime.InteropServices.DllImport("User32.dll")> _
Public Shared Function GetAsyncKeyState(ByVal vKey As Integer) As Short
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As _
System.EventArgs) Handles MyBase.Load
AxWebBrowser1.Navigate("search.msn.de")
End Sub
Private Sub AxWebBrowser1_DocumentComplete(ByVal sender As Object, ByVal e _
As AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent) Handles _
AxWebBrowser1.DocumentComplete
Dim MyCustomDoc As MsHtmHstInterop.ICustomDoc = CType( _
AxWebBrowser1.Document, MsHtmHstInterop.ICustomDoc)
MyCustomDoc.SetUIHandler(CType(Me, MsHtmHstInterop.IDocHostUIHandler))
End Sub
' Implementierung von IDocHostUIHandler
Public Sub EnableModeless(ByVal fEnable As Integer) Implements _
MsHtmHstInterop.IDocHostUIHandler.EnableModeless
End Sub
Public Sub FilterDataObject(ByVal pDO As MsHtmHstInterop.IDataObject, ByRef _
ppDORet As MsHtmHstInterop.IDataObject) Implements _
MsHtmHstInterop.IDocHostUIHandler.FilterDataObject
ppDORet = Nothing
End Sub
Public Sub GetDropTarget(ByVal pDropTarget As MsHtmHstInterop.IDropTarget, _
ByRef ppDropTarget As MsHtmHstInterop.IDropTarget) Implements _
MsHtmHstInterop.IDocHostUIHandler.GetDropTarget
ppDropTarget = Nothing
End Sub
Public Sub GetExternal(ByRef ppDispatch As Object) Implements _
MsHtmHstInterop.IDocHostUIHandler.GetExternal
ppDispatch = Nothing
End Sub
Public Sub GetHostInfo(ByRef pInfo As MsHtmHstInterop._DOCHOSTUIINFO) _
Implements MsHtmHstInterop.IDocHostUIHandler.GetHostInfo
End Sub
Public Sub GetOptionKeyPath(ByRef pchKey As String, ByVal dw As _
System.UInt32) Implements _
MsHtmHstInterop.IDocHostUIHandler.GetOptionKeyPath
pchKey = Nothing
End Sub
Public Sub HideUI() Implements MsHtmHstInterop.IDocHostUIHandler.HideUI
End Sub
Public Sub OnDocWindowActivate(ByVal fActivate As Integer) Implements _
MsHtmHstInterop.IDocHostUIHandler.OnDocWindowActivate
End Sub
Public Sub OnFrameWindowActivate(ByVal fActivate As Integer) Implements _
MsHtmHstInterop.IDocHostUIHandler.OnFrameWindowActivate
End Sub
Public Sub ResizeBorder(ByRef prcBorder As MsHtmHstInterop.tagRECT, ByVal _
pUIWindow As MsHtmHstInterop.IOleInPlaceUIWindow, ByVal fRameWindow As _
Integer) Implements MsHtmHstInterop.IDocHostUIHandler.ResizeBorder
End Sub
Public Sub ShowContextMenu(ByVal dwID As System.UInt32, ByRef ppt As _
MsHtmHstInterop.tagPOINT, ByVal pcmdtReserved As Object, ByVal _
pdispReserved As Object) Implements _
MsHtmHstInterop.IDocHostUIHandler.ShowContextMenu
' ContextMenü erlauben
Throw New Runtime.InteropServices.COMException("", 1)
End Sub
Public Sub ShowUI(ByVal dwID As System.UInt32, ByVal pActiveObject As _
MsHtmHstInterop.IOleInPlaceActiveObject, ByVal pCommandTarget As _
MsHtmHstInterop.IOleCommandTarget, ByVal pFrame As _
MsHtmHstInterop.IOleInPlaceFrame, ByVal pDoc As _
MsHtmHstInterop.IOleInPlaceUIWindow) Implements _
MsHtmHstInterop.IDocHostUIHandler.ShowUI
End Sub Fortsetzung im nächsten Post...
Meine Homepage: www.dartrax.de Posting wie es leibt und lebt
. . . und voll daneben geht!
|