.NET Framework - Question about WebBrowser
Asked By Adam
01-Nov-07 02:06 PM
Hello,
I want to disable context menu on WebBrowser component.
Is possible to catch mouse clik on WebBrowser component? To catch key
events I have to set KeyPreview to true. OK, but what with mouse click.
Or maybe some special html tag? I tried with JavaScrip scripts to disable
right click but they works only on Internet Explorer (full IE, like in XP
windows etc...)
How disable context menu on WebBrowser in mobile device?
Adam replied...
Dnia Thu, 1 Nov 2007 19:06:40 +0100, Adam napisa³(a):
[cut]
I found something like this:
http://tinyurl.com/38f4vc
It works but
--
//instead of the normal Application.Run(new Form1); we must manually
display
the form
Form1 formInstance = new Form1();
formInstance.Visible = true;
PeekMsg msg = new PeekMsg();
while (1 == 1)
{
PeekMessage(out msg, formInstance.Handle, 0, 0, WM_REMOVE);
--
is crazy. Never ending loop on windows mobile?
What about battery life?
Is there any PROPER WAY?
Is possible to set Hook on mouse? How can I do this?
Adam replied...
Dnia Mon, 5 Nov 2007 15:01:16 +0100, Peter Foot [MVP] napisa³(a):
I have a problem with this.
I simply put a WebBrowser and button component on a form and add this code
to Button onClick event:
IntPtr handle = webbrowser1.Handle;
const int WM_CLOSE = 0x10;
const int WM_USER = 0x0400;
const int DTM_ENABLECONTEXTMENU = WM_USER + 110;
1.//Message msg = Message.Create(handle, DTM_ENABLECONTEXTMENU,
IntPtr.Zero, (IntPtr) 1);
1.//MessageWindow.SendMessage(ref msg);
2.SendMessage(handle, DTM_ENABLECONTEXTMENU, 0, 0);
and
[DllImport("coredll.dll")]
public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int
lParam);
If I use 1 (Message etc..) with WM_CLOSE, webbrowser1 dissapear.
If I use 2 (with native SendMessage) with WM_CLOSE, webbrowser1 dissapear.
If I use 1 or 2 with DTM_ENABLECONTEXTMENU nothing change and webbrowser
still have a context menu.
What am I doing wrong and what is the correct way of doing it?
Adam replied...
Dnia Mon, 5 Nov 2007 15:01:16 +0100, Peter Foot [MVP] napisa³(a):
I have a problem with this.
I simply put a WebBrowser and button component on a form and add this code
to Button onClick event:
IntPtr handle = webbrowser1.Handle;
const int WM_CLOSE = 0x10;
const int WM_USER = 0x0400;
const int DTM_ENABLECONTEXTMENU = WM_USER + 110;
1.//Message msg = Message.Create(handle, DTM_ENABLECONTEXTMENU,
IntPtr.Zero, (IntPtr) 0);
1.//MessageWindow.SendMessage(ref msg);
2.SendMessage(handle, DTM_ENABLECONTEXTMENU, 0, 0);
and
[DllImport("coredll.dll")]
public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int
lParam);
If I use 1 (Message etc..) with WM_CLOSE, webbrowser1 dissapear.
If I use 2 (with native SendMessage) with WM_CLOSE, webbrowser1 dissapear.
If I use 1 or 2 with DTM_ENABLECONTEXTMENU nothing change and webbrowser
still have a context menu.
What am I doing wrong and what is the correct way of doing it?
function "?? _ _Elogger@@YAXXZ" (??_ _Elogger@@YAXXZ) dasdk.lib(DaSessionImp.obj) : error LNK2019: unresolved external symbol "_ _declspec(dllimport) public: long _ _thiscall uima::CAS::reset(void)" (_ _imp_?reset@CAS@uima@@QAEJXZ) referenced in function function _ _ehhandler$?initLogger@DaManagerImp@@AAEXXZ dasdk.lib(DaSessionImp.obj) : error LNK2019: unresolved external symbol "_ _declspec(dllimport) public: void _ _thiscall uima::SofaFS::setRemoteSofaURI(char const *)" (_ _imp_? setRemoteSofaURI@SofaFS@uima@@QAEXPBD@Z) referenced processURI@DaSessionImp@@EAEPAUFilteredDocument@@PBD@Z) dasdk.lib(DaSessionImp.obj) : error LNK2019: unresolved external symbol "_ _declspec(dllimport) public: _ _thiscall uima::SofaFS::SofaFS(void)" (_ _imp_??0SofaFS@uima@@QAE@XZ) referenced in function "private const *, . . .)" (?info@Category@log4cpp@@QAAXPBDZZ) dasdk.lib(DaSessionImp.obj) : error LNK2019: unresolved external symbol "_ _declspec(dllimport) public: virtual _ _thiscall icu_3_0::UnicodeString::~UnicodeString(void)" (_ _imp_?? 1UnicodeString@icu_3_0@@UAE@XZ) referenced in function createSourceSofa@DaSessionImp@@IAEXAAVSofaFS@uima@@@Z) dasdk.lib(DaManagerImp.obj) : error LNK2001: unresolved external symbol "_ _declspec(dllimport) public: virtual _ _thiscall icu_3_0::UnicodeString::~UnicodeString(void)" (_ _imp_?? 1UnicodeString@icu_3_0@@UAE@XZ) dasdk.lib(DaSessionImp.obj) : error LNK2019: unresolved external symbol "_ _declspec(dllimport) public: class uima::SofaFS _ _thiscall uima::CAS::createSofa(class uima::SofaID const &, char const *)" (_ _imp_ createSourceSofa@DaSessionImp@@IAEXAAVSofaFS@uima@@@Z) dasdk.lib(DaSessionImp.obj) : error LNK2019: unresolved external symbol "_ _declspec(dllimport) public: class uima::SofaID const & _ _thiscall uima::AnnotatorContext::mapToSofaID(class icu_3_0::UnicodeString const &)" (_ _imp_? mapToSofaID createSourceSofa@DaSessionImp@@IAEXAAVSofaFS@uima@@@Z) dasdk.lib(DaSessionImp.obj) : error LNK2019: unresolved external symbol "_ _declspec(dllimport) public: class uima::AnnotatorContext * _ _thiscall uima::AnnotatorContext::getDelegate(class icu_3_0::UnicodeString const &)const " (_ _imp_? getDelegate
Control.CreateControl() vid System.Windows.Forms.Control.WmShowWindow(Message& m) vid System.Windows.Forms.Control.WndProc(Message& m) vid System.Windows.Forms.ScrollableControl.WndProc(Message& m) vid System.Windows.Forms.ContainerControl.WndProc(Message& m) vid System.Windows.Forms.Form.WmShowWindow(Message& m) vid System.Windows.Forms.Form WndProc(Message& m) vid = System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) vid System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& = m) vid System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 = msg, IntPtr wparam, IntPtr 20 System.Windows.Forms.Control.WmShowWindow(Message& = m)<BR> vid = 20 System.Windows.Forms.Control.WndProc(Message& m)<BR> vid = System.Windows.Forms.ScrollableControl.WndProc(Message& = m)<BR> = 20 vid System.Windows.Forms.ContainerControl.WndProc(Message& = 20 m)<BR> vid = System.Windows.Forms.Form.WmShowWindow(Message& = 20 m)<BR> vid
dwSize; public IntPtr hrasconn; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = (int) (RasFieldSizeConstants.RAS_MaxEntryName + 1))] public string szEntryName; } [DllImport("coredll.dll", CharSet = CharSet.Auto)] public extern static uint RasEnumEntries( string reserved, / / reserved, must be occurred uint dwExtendedError / / extended error information for some errors ); public partial class RASWrapper { protected RASWrapper() { } [DllImport("coredll.dll", CharSet = CharSet.Auto)] public extern static uint RasDial( [In]RASDIALEXTENSIONS lpRasDialExtensions, / / pointer to a handler for RasDial events ref IntPtr lphRasConn / / pointer to variable to receive / / connection handle ); [DllImport("coredll.dll", CharSet = CharSet.Auto)] public extern static uint RasHangUp( IntPtr hrasconn / / handle to the RAS connection to hang up ); [DllImport("coredll.dll", CharSet = CharSet.Auto)] public extern static uint RasGetErrorString( uint uErrorValue, / / error to get StringBuilder lpszErrorString, / / buffer to hold error string [In]int cBufSize / / size, in characters, of buffer ); [DllImport("coredll.dll", CharSet = CharSet.Auto)] public extern static uint RasEnumConnections( [In, Out]RASCONN[] lprasconn, / / buffer lpcb, / / size in bytes of buffer out int lpcConnections / / number of connections written to buffer ); [DllImport("coredll.dll", CharSet = CharSet.Auto)] public extern static uint RasEnumDevices( [In, Out]RASDEVINFO[] lpRasDevInfo, / / buffer of the buffer out int lpcDevices / / receives the number of / / entries written to the buffer ); [DllImport("coredll.dll", CharSet = CharSet.Auto)] public extern static uint RasGetConnectStatus( IntPtr hrasconn, / / handle to RAS connection of interest [In, Out]RASCONNSTATUS lprasconnstatus / / buffer to receive status data ); [DllImport("coredll.dll", CharSet = CharSet.Auto)] public extern static uint RasConnectionNotification( IntPtr hrasconn, / / handle to a