Related KB Artcicle : 236312
<<http://support.microso ft.com/default.aspx?sc id=http://support.microso ft.com:80/support/kb/articles/Q236/3/12.asp&NoWebCon tent=1>>
Attached find the code snippet for the same, I got this soem somewhere
in usenet.
I remember, I had some problems doing this way .But was able to
solve. If you need any help drop me a mail : nirmalkannan at
myfastmail dot com.
Cheers
Nirmal
<code snippet>
...
using mshtml;
using SHDocVw;
using System.Runtime. InteropServices ;
...
namespace WindowsApplicat ion1
{
/// <summary>
/// Summary description for Form1.
/// </summary>
///
public enum DOCHOSTUITYPE
{
DOCHOSTUITYPE_B ROWSE = 0,
DOCHOSTUITYPE_A UTHOR = 1
}
public enum DOCHOSTUIDBLCLK
{
DOCHOSTUIDBLCLK _DEFAULT = 0,
DOCHOSTUIDBLCLK _SHOWPROPERTIES = 1,
DOCHOSTUIDBLCLK _SHOWCODE = 2
}
public enum DOCHOSTUIFLAG
{
DOCHOSTUIFLAG_D IALOG = 0x00000001,
DOCHOSTUIFLAG_D ISABLE_HELP_MEN U = 0x00000002,
DOCHOSTUIFLAG_N O3DBORDER = 0x00000004,
DOCHOSTUIFLAG_S CROLL_NO = 0x00000008,
DOCHOSTUIFLAG_D ISABLE_SCRIPT_I NACTIVE = 0x00000010,
DOCHOSTUIFLAG_O PENNEWWIN = 0x00000020,
DOCHOSTUIFLAG_D ISABLE_OFFSCREE N = 0x00000040,
DOCHOSTUIFLAG_F LAT_SCROLLBAR = 0x00000080,
DOCHOSTUIFLAG_D IV_BLOCKDEFAULT = 0x00000100,
DOCHOSTUIFLAG_A CTIVATE_CLIENTH IT_ONLY = 0x00000200,
DOCHOSTUIFLAG_O VERRIDEBEHAVIOR FACTORY = 0x00000400,
DOCHOSTUIFLAG_C ODEPAGELINKEDFO NTS = 0x00000800,
DOCHOSTUIFLAG_U RL_ENCODING_DIS ABLE_UTF8 = 0x00001000,
DOCHOSTUIFLAG_U RL_ENCODING_ENA BLE_UTF8 = 0x00002000,
DOCHOSTUIFLAG_E NABLE_FORMS_AUT OCOMPLETE = 0x00004000,
DOCHOSTUIFLAG_E NABLE_INPLACE_N AVIGATION = 0x00010000,
DOCHOSTUIFLAG_I ME_ENABLE_RECON VERSION = 0x00020000,
DOCHOSTUIFLAG_T HEME = 0x00040000,
DOCHOSTUIFLAG_N OTHEME = 0x00080000,
DOCHOSTUIFLAG_N OPICS = 0x00100000,
DOCHOSTUIFLAG_N O3DOUTERBORDER = 0x00200000,
DOCHOSTUIFLAG_D ELEGATESIDOFDIS PATCH = 0x00400000
}
[ StructLayout( LayoutKind.Sequ ential )]
public struct DOCHOSTUIINFO
{
uint cbSize;
uint dwFlags;
uint dwDoubleClick;
[MarshalAs(Unman agedType.BStr)] string pchHostCss;
[MarshalAs(Unman agedType.BStr)] string pchHostNS;
}
[StructLayout( LayoutKind.Sequ ential )]
public struct tagMSG
{
IntPtr hwnd;
int lParam;
uint message;
tagPOINT pt;
uint time;
uint wParam;
}
[ComImport(), InterfaceType(C omInterfaceType .InterfaceIsIUn known),
GuidAttribute(" bd3f23c0-d43e-11cf-893b-00aa00bdce1a")]
public interface IDocHostUIHandl er
{
[PreserveSig]
void ShowContextMenu (uint dwID, ref tagPOINT ppt,
[MarshalAs(Unman agedType.IUnkno wn)] object pcmdtReserved,
[MarshalAs(Unman agedType.IDispa tch)]object pdispReserved);
[PreserveSig]
void GetHostInfo(ref DOCHOSTUIINFO pInfo);
[PreserveSig]
void ShowUI(uint dwID, [MarshalAs(Unman agedType.Interf ace)] IntPtr
pActiveObject, [MarshalAs(Unman agedType.Interf ace)] IntPtr
pCommandTarget, [MarshalAs(Unman agedType.Interf ace)] IntPtr pFrame,
[MarshalAs(Unman agedType.Interf ace)] IntPtr pDoc);
[PreserveSig]
void HideUI();
[PreserveSig]
void UpdateUI();
[PreserveSig]
void EnableModeless( int fEnable);
[PreserveSig]
void OnDocWindowActi vate(int fActivate);
[PreserveSig]
void OnFrameWindowAc tivate(int fActivate);
[PreserveSig]
void ResizeBorder(re f tagRECT prcBorder,
[MarshalAs(Unman agedType.Interf ace)] IntPtr pUIWindow, int
fRameWindow);
[PreserveSig]
void TranslateAccele rator(ref tagMSG lpmsg, ref Guid pguidCmdGroup,
uint nCmdID);
[PreserveSig]
void GetOptionKeyPat h(ref string pchKey, uint dw);
[PreserveSig]
void GetDropTarget([MarshalAs(Unman agedType.Interf ace)] IntPtr
pDropTarget, [MarshalAs(Unman agedType.Interf ace)] ref IntPtr
ppDropTarget);
[PreserveSig]
void GetExternal(ref object ppDispatch);
[PreserveSig]
void TranslateUrl(ui nt dwTranslate, ref ushort pchURLIn, IntPtr
ppchURLOut);
[PreserveSig]
void FilterDataObjec t(IDataObject pDO, ref IDataObject ppDORet); }
[ComImport(), InterfaceType(C omInterfaceType .InterfaceIsIUn known),
GuidAttribute(" 3050f3f0-98b5-11cf-bb82-00aa00bdce0b")]
public interface ICustomDoc
{
[PreserveSig]
void SetUIHandler(ID ocHostUIHandler pUIHandler);
}
public class Form1 : System.Windows. Forms.Form, IDocHostUIHandl er {
private AxSHDocVw.AxWeb Browser axWebBrowser1;
private Object refmissing = System.Reflecti on.Missing.Valu e;
// ... usual declarations for your form - textboxes, buttons etc. //
....
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeCompo nent();
//
// TODO: Add any constructor code after InitializeCompo nent call
//
// The following is necessary before accessing any browser
properties:
// initialise the browser by navigating to a blank page.
string sAddr = "about
:Blan k";
axWebBrowser1.N avigate(sAddr, ref refmissing, ref refmissing, ref
refmissing, ref refmissing);
IHTMLDocument2 hDoc = (IHTMLDocument2 )axWebBrowser1. Document;
// The missing link! Set the UI handler for this browser to this
application!!
((ICustomDoc) hDoc).SetUIHand ler((IDocHostUI Handler) this);
}
// other form code, event handlers, your code etc.
/*************** *************** *************** *************** ***************
************/
//
// IDocHostUIHandl er implementation
//
/*************** *************** *************** *************** ***************
************/
public void ShowContextMenu (uint dwID, ref tagPOINT ppt,
[MarshalAs(Unman agedType.IUnkno wn)] object pcmdtReserved,
[MarshalAs(Unman agedType.IDispa tch)]object pdispReserved)
{
Console.WriteLi ne("ShowContext Menu");
}
public void GetHostInfo(ref DOCHOSTUIINFO pInfo)
{
Console.WriteLi ne("GetHostInfo ");
}
public void ShowUI(uint dwID, [MarshalAs(Unman agedType.Interf ace)]
IntPtr pActiveObject, [MarshalAs(Unman agedType.Interf ace)] IntPtr
pCommandTarget, [MarshalAs(Unman agedType.Interf ace)] IntPtr pFrame,
[MarshalAs(Unman agedType.Interf ace)] IntPtr pDoc)
{
Console.WriteLi ne("ShowUI");
}
public void HideUI()
{
Console.WriteLi ne("HideUI");
}
public void UpdateUI()
{
Console.WriteLi ne("UpdateUI") ;
}
public void EnableModeless( int fEnable)
{
Console.WriteLi ne("EnableModel ess");
}
public void OnDocWindowActi vate(int fActivate)
{
Console.WriteLi ne("OnDocWindow Activate");
}
public void OnFrameWindowAc tivate(int fActivate)
{
Console.WriteLi ne("OnFrameWind owActivate");
}
public void ResizeBorder(re f tagRECT prcBorder,
[MarshalAs(Unman agedType.Interf ace)] IntPtr pUIWindow, int
fRameWindow)
{
Console.WriteLi ne("ResizeBorde r");
}
public void TranslateAccele rator(ref tagMSG lpmsg, ref Guid
pguidCmdGroup, uint nCmdID)
{
Console.WriteLi ne("TranslateAc celerator");
}
public void GetOptionKeyPat h(ref string pchKey, uint dw)
{
Console.WriteLi ne("GetOptionKe yPath");
}
public void GetDropTarget([MarshalAs(Unman agedType.Interf ace)]
IntPtr pDropTarget, [MarshalAs(Unman agedType.Interf ace)] ref IntPtr
ppDropTarget)
{
Console.WriteLi ne("GetDropTarg et");
}
public void GetExternal(ref object ppDispatch)
{
Console.WriteLi ne("GetExternal ");
}
public void TranslateUrl(ui nt dwTranslate, ref ushort pchURLIn,
IntPtr ppchURLOut)
{
Console.WriteLi ne("TranslateUr l");
}
public void FilterDataObjec t(IDataObject pDO, ref IDataObject
ppDORet)
{
Console.WriteLi ne("FilterDataO bject");
}
}
}
</codesnippet>
"John Bowman" <<Remove this before reply>
jo*********@the rmo.com> wrote in message news:<ef******* *******@TK2MSFT NGP09.phx.gbl>. ..
ISMAILRAJPUT,
That's what I was hoping for, but no click events appear in the list of
events in VS designer to implement. A few others do appear, but nothing
apparently useful. How can I get at the OnClick event when it's not there?
John
"ISMAILRAJP UT" <hu************ @hotmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. .. Just a Guess
Right click event will occure but i think what you need is "Do not Handle
the Event" or if there is a contextmenu attached, remove it.
---------------------------------------------------------
"John Bowman jo*********@the rmo.com>" <<Remove this before reply> wrote in
message news:Od******** ******@TK2MSFTN GP11.phx.gbl... Hi,
How can I disable the right click capability of the Web Browser control
that's on a form? I only want it to display the HTML, w/ no popup menu.
TIA,
--
John C. Bowman
Software Engineer
Thermo Electron Scientific Instruments Div.
<Remove this before reply> jo*********@the rmo.com