Hi Gokul
Ok, here goes. It works something like this.
First, include the following interface definition stuff somewhere convenient
(I have a separate module with these kind of interfaces in):
<code>
Public Enum DOCHOSTUIFLAG
DOCHOSTUIFLAG_D IALOG = &H1
DOCHOSTUIFLAG_D ISABLE_HELP_MEN U = &H2
DOCHOSTUIFLAG_N O3DBORDER = &H4
DOCHOSTUIFLAG_S CROLL_NO = &H8
DOCHOSTUIFLAG_D ISABLE_SCRIPT_I NACTIVE = &H10
DOCHOSTUIFLAG_O PENNEWWIN = &H20
DOCHOSTUIFLAG_D ISABLE_OFFSCREE N = &H40
DOCHOSTUIFLAG_F LAT_SCROLLBAR = &H80
DOCHOSTUIFLAG_D IV_BLOCKDEFAULT = &H100
DOCHOSTUIFLAG_A CTIVATE_CLIENTH IT_ONLY = &H200
DOCHOSTUIFLAG_O VERRIDEBEHAVIOR FACTORY = &H400
DOCHOSTUIFLAG_C ODEPAGELINKEDFO NTS = &H800
DOCHOSTUIFLAG_U RL_ENCODING_DIS ABLE_UTF8 = &H1000
DOCHOSTUIFLAG_U RL_ENCODING_ENA BLE_UTF8 = &H2000
DOCHOSTUIFLAG_E NABLE_FORMS_AUT OCOMPLETE = &H4000
DOCHOSTUIFLAG_E NABLE_INPLACE_N AVIGATION = &H10000
DOCHOSTUIFLAG_I ME_ENABLE_RECON VERSION = &H20000
DOCHOSTUIFLAG_T HEME = &H40000
DOCHOSTUIFLAG_N OTHEME = &H80000
DOCHOSTUIFLAG_N OPICS = &H100000
DOCHOSTUIFLAG_N O3DOUTERBORDER = &H200000
End Enum
Public Enum DOCHOSTUIDBLCLK
DOCHOSTUIDBLCLK _DEFAULT = 0
DOCHOSTUIDBLCLK _SHOWPROPERTIES = 1
DOCHOSTUIDBLCLK _SHOWCODE = 2
End Enum
' MSG structure
<StructLayout(L ayoutKind.Seque ntial)> _
Public Structure MSG
Dim hwnd As IntPtr
Dim message As Integer
Dim wParam As Integer
Dim lParam As Integer
Dim time As Integer
Dim pt As tagPOINT
End Structure
' DOCHOSTUIINFO structure
<StructLayout(L ayoutKind.Seque ntial)> _
Public Structure DOCHOSTUIINFO
Dim cbSize As Integer
Dim dwFlags As DOCHOSTUIFLAG
Dim dwDoubleClick As DOCHOSTUIDBLCLK
Dim pchHostCss As String
Dim pchHostNS As String
End Structure
' OLEMENUGROUPWID THS structure
<StructLayout(L ayoutKind.Seque ntial)> _
Public Structure OLEMENUGROUPWID THS
<MarshalAs(Unma nagedType.ByVal Array, SizeConst:=6)> _
Dim width() As Integer
End Structure
' ICustomDoc interface
<ComVisible(Tru e), ComImport(),
Guid("3050f3f0-98b5-11cf-bb82-00aa00bdce0b"), _
InterfaceTypeAt tribute(ComInte rfaceType.Inter faceIsIUnknown) > _
Public Interface ICustomDoc
Sub SetUIHandler(By Val pUIHandler As IDocHostUIHandl er)
End Interface
' IOleWindow interface
<ComVisible(Tru e), ComImport(),
Guid("00000114-0000-0000-C000-000000000046"), _
InterfaceTypeAt tribute(ComInte rfaceType.Inter faceIsIUnknown) > _
Public Interface IOleWindow
Sub GetWindow(ByVal phwnd As IntPtr)
Sub ContextSensitiv eHelp(ByVal fEnterMode As Boolean)
End Interface
' IOleInPlaceActi veObject interface
<ComVisible(Tru e), ComImport(),
Guid("00000117-0000-0000-C000-000000000046"), _
InterfaceTypeAt tribute(ComInte rfaceType.Inter faceIsIUnknown) > _
Public Interface IOleInPlaceActi veObject : Inherits IOleWindow
' IOleWindow interface
Shadows Sub GetWindow(ByVal phwnd As IntPtr)
Shadows Sub ContextSensitiv eHelp(ByVal fEnterMode As Boolean)
Sub TranslateAccele rator(ByRef lpmsg As MSG)
Sub OnFrameWindowAc tivate(ByVal fActivate As Boolean)
Sub OnDocWindowActi vate(ByVal fActivate As Boolean)
Sub ResizeBorder(By Ref prcBorder As tagRECT, ByVal pUIWindow As
IOleInPlaceUIWi ndow, ByVal fFrameWindow As Boolean)
Sub EnableModeless( ByVal fEnable As Boolean)
End Interface
' IOleInPlaceUIWi ndow interface
<ComVisible(Tru e), ComImport(),
Guid("00000115-0000-0000-C000-000000000046"), _
InterfaceTypeAt tribute(ComInte rfaceType.Inter faceIsIUnknown) > _
Public Interface IOleInPlaceUIWi ndow : Inherits IOleWindow
' IOleWindow interface
Shadows Sub GetWindow(ByVal phwnd As IntPtr)
Shadows Sub ContextSensitiv eHelp(ByVal fEnterMode As Boolean)
Sub GetBorder(ByRef lprectBorder As tagRECT)
Sub RequestBorderSp ace(ByRef pborderwidths As tagRECT)
Sub SetBorderSpace( ByRef pborderwidths As tagRECT)
Sub SetActiveObject (ByVal pActiveObject As IOleInPlaceActi veObject,
ByVal pszObjName As String)
End Interface
' IDropTarget interface
<ComVisible(Tru e), ComImport(),
Guid("00000122-0000-0000-C000-000000000046"), _
InterfaceTypeAt tribute(ComInte rfaceType.Inter faceIsIUnknown) > _
Public Interface IDropTarget
Sub DragEnter(ByVal pDataObj As IDataObject, ByVal grfKeyState As
Integer, ByVal pt As tagPOINT, ByRef pdwEffect As Integer)
Sub DragOver(ByVal grfKeyState As Integer, ByVal pt As tagPOINT, ByRef
pdwEffect As Integer)
Sub DragLeave()
Sub Drop(ByVal pDataObj As IDataObject, ByVal grfKeyState As Integer,
ByVal pt As tagPOINT, ByRef pdwEffect As Integer)
End Interface
' IOleInPlaceFram e interface
<ComVisible(Tru e), ComImport(),
Guid("00000116-0000-0000-C000-000000000046"), _
InterfaceTypeAt tribute(ComInte rfaceType.Inter faceIsIUnknown) > _
Public Interface IOleInPlaceFram e : Inherits IOleInPlaceUIWi ndow
' IOleWindow interface
Shadows Sub GetWindow(ByVal phwnd As IntPtr)
Shadows Sub ContextSensitiv eHelp(ByVal fEnterMode As Boolean)
' IOleInPlaceUIWi ndow interface
Shadows Sub GetBorder(ByRef lprectBorder As tagRECT)
Shadows Sub RequestBorderSp ace(ByRef pborderwidths As tagRECT)
Shadows Sub SetBorderSpace( ByRef pborderwidths As tagRECT)
Shadows Sub SetActiveObject (ByVal pActiveObject As
IOleInPlaceActi veObject, ByVal pszObjName As String)
' TODO: hmenuShared should be a reference to a remotable handle
Sub InsertMenus(ByV al hmenuShared As IntPtr, ByRef lpMenuWidths As
OLEMENUGROUPWID THS)
Sub SetMenu(ByVal hmenuShared As IntPtr, ByVal holemenu As IntPtr, ByVal
hwndActiveObjec t As IntPtr)
Sub RemoveMenus(ByV al hmenuShared As IntPtr)
Sub SetStatusText(B yVal pszStatusText As String)
Sub EnableModeless( ByVal fEnable As Boolean)
Sub TranslateAccele rator(ByRef lpmsg As MSG, ByVal wID As UInt16)
End Interface
' IDocHostUIHandl er interface
<ComVisible(Tru e), ComImport(),
Guid("bd3f23c0-d43e-11cf-893b-00aa00bdce1a"), _
InterfaceTypeAt tribute(ComInte rfaceType.Inter faceIsIUnknown) > _
Public Interface IDocHostUIHandl er
<PreserveSig( )> _
Function ShowContextMenu ( _
ByVal dwID As Integer, _
ByRef ppt As tagPOINT, _
<MarshalAs(Unma nagedType.IUnkn own)> ByVal pcmdtReserved As Object, _
<MarshalAs(Unma nagedType.IDisp atch)> ByVal pdispReserved As Object)
As Integer
Sub GetHostInfo(ByR ef pInfo As DOCHOSTUIINFO)
<PreserveSig( )> _
Function ShowUI( _
ByVal dwID As Integer, _
ByVal pActiveObject As IOleInPlaceActi veObject, _
ByVal pCommandTarget As IOleCommandTarg et, _
ByVal pFrame As IOleInPlaceFram e, _
ByVal pDoc As IOleInPlaceUIWi ndow) As Integer
Sub HideUI()
Sub UpdateUI()
Sub EnableModeless( ByVal fEnable As Boolean)
Sub OnDocWindowActi vate(ByVal fActivate As Boolean)
Sub OnFrameWindowAc tivate(ByVal fActivate As Boolean)
Sub ResizeBorder( _
ByRef prcBorder As tagRECT, _
ByVal pUIWindow As IOleInPlaceUIWi ndow, _
ByVal fFrameWindow As Boolean)
<PreserveSig( )> _
Function TranslateAccele rator( _
ByRef lpMsg As MSG, _
ByRef pguidCmdGroup As Guid, _
ByVal nCmdID As Integer) As Integer
Sub GetOptionKeyPat h( _
ByRef pchKey As String, _
ByVal dw As Integer)
Sub GetDropTarget( _
ByVal pDropTarget As IDropTarget, _
ByRef ppDropTarget As IDropTarget)
Sub GetExternal(<Ma rshalAs(Unmanag edType.IDispatc h)> ByRef ppDispatch As
Object)
<PreserveSig( )> _
Function TranslateUrl( _
ByVal dwTranslate As Integer, _
ByRef pchURLIn As UInt16, _
ByVal ppchURLOut As IntPtr) As Integer
<PreserveSig( )> _
Function FilterDataObjec t( _
ByVal pDO As IDataObject, _
ByRef ppDORet As IDataObject) As Integer
End Interface
</code>
Next, create a class (I call mine DocHostUIHandle r) and implement
IDocHostUIHandl er. If you are using V2003 you will get all the subs and
functions filled in for you; wonderful.
For convenience, define the following at the top of the class.
<code>
Private Const S_OK As Integer = 0
Private Const S_FALSE As Integer = 1
</code>
For every function that you are not going to intercept, return S_FALSE. That
will signal that you have not provided your own implementation. If you want
to prevent something, like the context menu, you can return S_TRUE in
ShowContextMenu (), for example. To change it, provide your own and then
return S_TRUE.
Now create a function in you main code, somewhere:
<code>
Private Sub SetUIHandler()
' Get a handle to the ICustomDoc interface on the document
Dim icd As ICustomDoc
icd = CType(AxWebBrow ser1.Document, ICustomDoc)
icd.SetUIHandle r(New DocHostUIHandle r)
' *** Make sure you wait for a readystate of DocumentComplet e here ***
End Sub
</code>
Now, call SetUIHandler in the DocumentComplet e event of the AxWebBrowser1.
Finally, going back to the class that implements IDocHostUIHandl er, my
GetHostInfo does this:
<code>
With pInfo
.cbSize = Len(pInfo)
.dwFlags = DOCHOSTUIFLAG.D OCHOSTUIFLAG_DI V_BLOCKDEFAULT
.dwDoubleClick = DOCHOSTUIDBLCLK .DOCHOSTUIDBLCL K_DEFAULT
End With
</code>
You can set the flags to what you like, for example, one of them affects the
3D border. The definition of the flags is in the MSDN.
Well, that's it. I hope I've included everything. Let me know how you get
on.
HTH
Charles
"gokul" <go********@yah oo.com> wrote in message
news:c1******** *************** ***@posting.goo gle.com...
Dear Charles Law,
I need to remove the 3D border of the Webbrowser control, they say it
could be achieved using IDocHostUIHandl er.
and also Iam trying to change the Context menu.
Apart from it Iam trying to capture the word/text on which the mouse
is pointing using API calls.....do u have any idea about it!!!!?
Thank You for the prompt replies.
Letz work on it to make a wonderful product and share the Concepts and
ideas.
Regards
Gokul