TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
moloyb
NA
3
0
How to Capture Key-Press Event of "Web Browser Control" of a Win form
Feb 24 2004 1:54 PM
I have a web browser control attched to a win form. Now I have to capture the mousemove event,mouseclick event and keypress event ,, the moment someone moves his mouse or press a key on the document , I should be able to capture the event. I could able to capture the mouse move and mouse click but no key press. I have to somehow capture the keypress event. I donot know how and it is very urgent. Any help would be really appreciated. follwing is my partial code . private void Form1_Load(object sender, System.EventArgs e) { object oURL = "http://www.google.com"; object oEmpty = ""; axWebBrowser1.Navigate2(ref oURL, ref oEmpty, ref oEmpty, ref oEmpty, ref oEmpty); } private void DocumentComplete(object sender,AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e) { mshtml.HTMLDocument doc; doc=(mshtml.HTMLDocument)axWebBrowser1.Document; mshtml.HTMLDocumentEvents2_Event iEvent; iEvent=(mshtml.HTMLDocumentEvents2_Event)doc; iEvent.onclick+=new mshtml.HTMLDocumentEvents2_onclickEventHandler(ClickEventHandler); iEvent.onmouseover += new mshtml.HTMLDocumentEvents2_onmouseoverEventHandler(MouseOverEventHandler); iEvent.onkeypress+= new mshtml.HTMLDocumentEvents2_onkeypressEventHandler(KeyPressEventHandler); iEvent.onkeydown+= new mshtml.HTMLDocumentEvents2_onkeydownEventHandler(KeyDownEventHandler); listBox1.Items.Clear(); } private bool ClickEventHandler(mshtml.IHTMLEventObj e) { if( e.srcElement.tagName == "INPUT" ) { } listBox1.Items.Insert(0, e.type + ":" + e.clientX.ToString()+","+e.clientY.ToString()); return true; } private void MouseOverEventHandler(mshtml.IHTMLEventObj e) { listBox1.Items.Insert(0, e.type + ":" + e.x.ToString()+","+ e.y.ToString()); } private bool KeyPressEventHandler(mshtml.IHTMLEventObj e) { listBox1.Items.Insert(0,e.type + ":" + e.srcElement.recordNumber.ToString()); return true; } private void KeyDownEventHandler(mshtml.IHTMLEventObj e) { listBox1.Items.Insert(0,e.type+":"+e.srcElement.innerText.ToString() ); } How can I capture the Key Press Event. Thanks Moloy
Reply
Answers (
0
)
Trying to hide the "border" of a Win Button control.
winForms