We help IT Professionals succeed at work.

VB6: Detect Webbrowser button click

tvtech
tvtech asked
on
Hi,

I've tried a few non-E-E solutions, but none seem to work for me.

I need to detect mouse click on a button in a WebBrowser OCX HTML page, in order to send the code to one of two Subs.

Does anyone have a bullet proof method to do this?

Thanks.
Comment
Watch Question

Commented:
If you are writing an ActiveX control that is then being added to a web page - then the built in OnClick function is where you would place the code.

This, however, seems to be a very basic question, though, so I don't think I am understanding the question correctly.

Perhaps you are writing an ActiveX control that you want to then execute JavaScript code within the same page or something?  Can you expand your question?

Author

Commented:
I'm using a standard Webbrowser OCX on a VB6 form. The Webbrowser displays an intranet web page,  which has four named buttons. I need to know when the OnClick event occurs, when one of the buttons is clicked, so that I tell my code what to do when that specific button is clicked.

The Webbrowser does not have an OnClick event and no, I am not writing an OCX.

Thanks.
Commented:
Take a look at the article on MSDN about handling events within a VB6 application called from source HTML hosted in a WebBrowser control, this looks like what you want to do.

https://msdn.microsoft.com/en-ca/library/aa752045%28v=vs.85%29.aspx

Author

Commented:
Rob, thanks very much. Works great!

Author

Commented:
Great answer. Just don't forget to set 'My_Default_Method' as the Default, or it won't show the Button.onClick msgbox. :-)