473,414 Members | 1,716 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

MSHTML event weirdness

In the excerpt below, the onclick event fires my handler, but the onkeypress
event does not. I've got a WebBrowser control on a form and I'm trying to
bind element events. I can bind weird events like onmouseenter and
onmousemove (omitted for brevity, they require a different method signature)
but according to MSDN the two events illustrated in the following code
should have identical signatures. One works and the other does not. I would
just love it if someone could put me out of my misery and explain why. For
extra credit you could also explain why the onchange event shows the same
problem. As a matter of interest, MSDN says onchange is a void function but
the typelib requires a bool function.

private void PaneMain_DocumentComplete(object sender,
AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e) {

DocMain = (HTMLDocument)PaneMain.Document;

DocTools = (HTMLDocument)PaneTools.Document;

IHTMLElement theBody = (IHTMLElement)DocMain.body;

theBody.innerHTML = "<button id='B1'>New style</button> <a id='B2'
href=''>Anchor</a><FORM ACTION='http://localhost/' METHOD='POST'><INPUT
ID='W1' VALUE='BLAH BLAH'></FORM>";

IHTMLElementCollection cAll = (IHTMLElementCollection)DocMain.all;

HTMLInputTextElement W1 = (HTMLInputTextElement)cAll.item("W1",0);

((HTMLInputTextElementEvents2_Event)W1).onclick += new
HTMLInputTextElementEvents2_onclickEventHandler(th is.HandlerClick);

((HTMLInputTextElementEvents2_Event)W1).onkeypress += new
HTMLInputTextElementEvents2_onkeypressEventHandler (this.HandlerKeypress);

}

private bool HandlerClick(IHTMLEventObj e) {

IHTMLElement Element = e.srcElement;

Console.Write("Click:");

Console.WriteLine(Element.tagName);

return true;

}

private bool HandlerKeypress(IHTMLEventObj e) {

HTMLInputTextElement Element = (HTMLInputTextElement)e.srcElement;

Console.Write("KeyPress:");

Console.WriteLine(Element.value);

return true;

}
Nov 15 '05 #1
0 1978

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Simon | last post by:
Hi, I have a webapp that allows an HTML description for an object to be saved. It used to be pure text with no formatting. This caused problems if the user entered (for example) and iframe tag,...
10
by: Sunny | last post by:
Hi all, dev. env.: VS.Net2003/C# I have a windows form application with web browser control. I need to capture the onsubmit event of the forms in the document in order to get the values and log...
1
by: Oliver | last post by:
hi - my foray into 'autobrowsing' using mshtml etc is going ok - but rather slow (partly) because I'm struggling to find documentation. anyone have any idea how to achieve authentication in an...
7
by: Robert May | last post by:
I have an application that uses the Ax web browser object. When I call the IHTMLElement.click() method on an input button (<input type="submit"> or <input type="button">), the click fires...
1
by: Dean Hallman | last post by:
I need to ensure client machine has Microsoft.mshtml installed in the GAC. And if not, deploy it. My app is a Browser Helper Object and depends on mshtml. Initially, I thought I could take care...
4
by: Lars-Erik Aabech | last post by:
Hi! I've been walking in extacy since reading the article about test automation with IE in the latest MSDN mag. (http://msdn.microsoft.com/msdnmag/issues/05/10/TestRun/default.aspx) After a...
0
by: Giuseppe | last post by:
Hi I've this problem Inside a winform application I've put a "webbrowser" control I've tried to catch the oncontextmenu event of the loaded HTML document with the following approach 1) In...
5
by: miktro | last post by:
I have an VB.Net desktop application where I am hosting a WebBrowser. I need to interact with the events in the browser. I encountered the normal problem of, after adding events the normal click...
2
by: Michael Schwarz | last post by:
Hi, I have several customers reporting IE crashes when using different web pages. When looking in the event log I noticed something like "application error" or "application hang", and each time...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.