 |
| VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1).
** Please don't post code questions here **
For issues specific to a particular language in .NET, please see the other forum categories. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

October 16th, 2003, 02:50 PM
|
|
Registered User
|
|
Join Date: Sep 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
consuming events from axWebBrowser
Hi.
I have some qusetion, I couldn't find almost any documentation about it.
I hope that someone can help.
I embedded a Activex IE browser in a win app ( .NET ).
I was able to raise events from the axWebBrowser and to bind it to an event handler on the win form container.
1. I wasn't able to pass arguments with the event
(for example, passing the value of a text box on
chage event, from the axWebBrowser to the container(win
app).
2. How can I respond to events in the axWebBrowser that were raised on the container ( my idea is that I need to trigger an event in the axWebBrowser , because it is an event driven environment, and then call a javascript function ( "event handler").
How can I trigger a btn click event, in the axWebBrowser from the container?
3. Is it possible to exchange COM objects ( not just a simple string),
between the container and the axWebBrowser ?
Thank you very much
roy
|
|

August 1st, 2005, 10:59 AM
|
|
Registered User
|
|
Join Date: Aug 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by roy
Hi.
I have some qusetion, I couldn't find almost any documentation about it.
I hope that someone can help.
I embedded a Activex IE browser in a win app ( .NET ).
I was able to raise events from the axWebBrowser and to bind it to an event handler on the win form container.
1. I wasn't able to pass arguments with the event
(for example, passing the value of a text box on
chage event, from the axWebBrowser to the container(win
app).
2. How can I respond to events in the axWebBrowser that were raised on the container ( my idea is that I need to trigger an event in the axWebBrowser , because it is an event driven environment, and then call a javascript function ( "event handler").
How can I trigger a btn click event, in the axWebBrowser from the container?
3. Is it possible to exchange COM objects ( not just a simple string),
between the container and the axWebBrowser ?
Thank you very much
roy
|
I am trying to do the same thing
Can you please post how you were able tp raise events from the axWebBrowser and to bind it to an event handler on the win form container?
It would be a great help
|
|

August 1st, 2005, 11:04 AM
|
|
Registered User
|
|
Join Date: Aug 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I found out how to click button from the container but could not found out how to raise event from the AxWebBrowser to the conatiner
I did it something like this in axWebBrowser1_DocumentComplete event
HTMLDocument myDoc = new HTMLDocumentClass();
myDoc = (HTMLDocument) axWebBrowser1.Document;
HTMLInputElement btnSearch = (HTMLInputElement) myDoc.all.item("btnI", 0);
btnSearch.click();
|
|

March 9th, 2007, 04:08 AM
|
|
Registered User
|
|
Join Date: Aug 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Two ways to do it.
1.
On Document_complete event,
Iterate through all tags, find it and add an appropriate handler to it
Code would be something like
Private Sub WBBrowser_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEv entArgs) Handles WBBrowser.DocumentCompleted
' Now find the object as in the previous comment and now
AddHandler htmlElement.Click, AddressOf Document_OnClick
2. The other and bit lengthy way is
Handle the click event of Document
Make a function which can return you the focused element
that would be something like
Public Function GetFocusedElement() As mshtml.IHTMLElement
Dim focusedControl As mshtml.IHTMLElement
If CType(CType(oldDocument, mshtml.HTMLDocument).selection, mshtml.IHTMLSelectionObject).type = "Control" Then
focusedControl = CType(oldDocument.selection.createRange(), mshtml.IHTMLControlRange).item(0)
Else
focusedControl = CType(oldDocument.selection.createRange(), mshtml.IHTMLTxtRange).parentElement
End If
Return focusedControl
End Function
Now see if it is the required element. if it is .. do what ever you want to do with it
|
|
 |